Ejemplo n.º 1
0
 $_SESSION['num_of_opps'] = rand(1, ceil(sqrt($opponent_level)));
 $opponent_id = intval(@$_GET['opponent_id']);
 DEBUG and $_SESSION['disp_msg'][] = "DEBUG: choosing opponent {$opponent_id}, lvl {$_SESSION['opp_level']} , {$_SESSION['num_of_opps']} foes";
 //find or create an arena location
 //FIXME
 //find out whether there is a city or special here, and use the name
 $result = mysql_query("select name from tower_locations where id={$character->location} LIMIT 1");
 @(list($locationname) = mysql_fetch_row($result));
 $arenaat = isset($locationname) ? $locationname : "Unknown " . rand(0, 99);
 $arenaname = "Arena " . rand(1, 3) . " at {$arenaat}";
 //check whether this arena exists already
 $result = mysql_query("select id from tower_locations where name='{$arenaname}' order by id DESC");
 @(list($arenalocation) = mysql_fetch_row($result));
 if (!@$arenalocation) {
     DEBUG and $_SESSION['disp_msg'][] = "DEBUG: adding new arena ";
     $arenalocation = nextLocationIdFromRange('arena_fighting_location', __FILE__, __LINE__);
     //insert if not exists
     $query = "insert into tower_locations\n                 (id, name, image_path, special, buildings, pass, explore)\n                 values\n                 ({$arenalocation}, '{$arenaname}','images/arena.gif',1,0,1,0)\n                  ";
     $req = mysql_query($query);
     if (!$req) {
         showError(__FILE__, __LINE__, __FUNCTION__);
         exit;
     }
     $result = mysql_query("select id from tower_locations where name='{$arenaname}' order by id DESC");
     @(list($arenalocation) = mysql_fetch_row($result));
     //make arena point to itself so that monsters don't wander off
     $query = "update tower_locations\n                 set\n                `above_left`= {$arenalocation},\n                `above`= {$arenalocation},\n                `above_right`= {$arenalocation},\n                `leftside`= {$arenalocation},\n                `rightside`= {$arenalocation},\n                `below_left`= {$arenalocation},\n                `below`= {$arenalocation},\n                `below_right`= {$arenalocation}\n                where id= {$arenalocation}";
     $req = mysql_query($query);
     if (!$req) {
         showError(__FILE__, __LINE__, __FUNCTION__);
         exit;
Ejemplo n.º 2
0
<?php

include_once "items.php";
include_once "shop_functions.php";
include_once "class_character.php";
$current_time = time();
$basicsquery = "SELECT phaos_shop_basics.*, phaos_buildings.name, phaos_buildings.location FROM phaos_buildings LEFT JOIN phaos_shop_basics USING(shop_id) WHERE location = '" . $character->location . "' AND phaos_shop_basics.shop_id='{$shop_id}'";
$shop_basics = fetch_first($basicsquery, __FILE__, __LINE__);
@$shop_basics['shop_id'] or die("shop({$shop_id}), {$shop_basics['name']} at({$shop_basics['location']}) has no shop_basics entry");
//FIXME:
// auto-generate the location the shop stores its items at
if (!$shop_basics['item_location_id']) {
    $new_item_location_id = nextLocationIdFromRange('item_storage_location', __FILE__, __LINE__);
    $storage_name = "Store of Shop at {$shop_basics['location']}";
    $query = "insert into phaos_locations (id,name,special) values ({$new_item_location_id},'{$storage_name}',1)";
    $req = mysql_query($query);
    if (!$req) {
        showError(__FILE__, __LINE__, __FUNCTION__, $query);
        exit;
    }
    //check
    $new_item_location_id = fetch_value("select id from phaos_locations where name='{$storage_name}' LIMIT 1", __FILE__, __LINE__);
    if ($new_item_location_id) {
        $query = "update phaos_shop_basics set item_location_id={$new_item_location_id} where shop_id='{$shop_id}'";
        $req = mysql_query($query);
        if (!$req) {
            showError(__FILE__, __LINE__, __FUNCTION__, $query);
            exit;
        }
        //rerun query
        $shop_basics = fetch_first($basicsquery, __FILE__, __LINE__);