Beispiel #1
0
function do_buy(&$character, $shop_basics)
{
    global $bought, $sorrys, $refresh;
    $ids = @$_REQUEST['buy_id'];
    $types = @$_REQUEST['buy_type'];
    $numbers = @$_REQUEST['buy_number'];
    $bought = 0;
    $sorrys = 0;
    if ($ids && is_array($ids) && $types && is_array($types)) {
        foreach ($ids as $key => $id) {
            $number = @$numbers[$key];
            if (!$number) {
                $number = 1;
            }
            $item = array('id' => $id, 'type' => $types[$key], 'number' => $number);
            $info = fetch_item_additional_info($item, &$character);
            if ($info['buy_price'] > 0 && $character->pay($info['buy_price'])) {
                $item['number'] = item_pickup($shop_basics['item_location_id'], $item);
                $bought += $character->pickup_item($item);
            } else {
                $sorrys += $number;
            }
            $refresh = 1;
        }
    }
}
Beispiel #2
0
function pickup_actions(&$character)
{
    if ($character->stamina_points <= 0) {
        return 0;
    }
    $location = $character->location;
    $ids = @$_REQUEST['pickup_id'];
    if (!$ids || !is_array($ids) || count($ids) == 0) {
        return 0;
    }
    $types = $_REQUEST['pickup_type'];
    $numbers = $_REQUEST['pickup_number'];
    $pickedup = 0;
    foreach ($ids as $key => $id) {
        $type = $types[$key];
        $number = $numbers[$key];
        $item = array('id' => $id, 'type' => $type, 'number' => $number);
        $item['number'] = item_pickup($location, $item);
        $pickedup += $character->pickup_item($item);
    }
    $character->stamina_points -= $pickedup * 3;
    $character->update_stamina();
    return $pickedup;
}
Beispiel #3
0
//HACK
//defined('DEBUG') and DEBUG and $restock=2;
defined('DEBUG') and DEBUG and $GLOBALS['debugmsgs'][] = "restock= {$restock}";
if ($restock > 0) {
    //set update time
    $query = "UPDATE phaos_shop_basics SET restock_time = {$current_time} WHERE shop_id = '{$shop_id}'";
    $req = mysql_query($query);
    if (!$req) {
        showError(__FILE__, __LINE__, __FUNCTION__, $query);
        exit;
    }
    //remove one item
    $item = fetch_random_item_for_location($shop_basics['item_location_id']);
    if ($item && $item['id'] && $item['type'] != 'gold') {
        $item['number'] = 1;
        $item['number'] = item_pickup($shop_basics['item_location_id'], $item);
        $restock += $item['number'];
    }
    //take inventory
    $items = fetch_items_for_location($shop_basics['item_location_id']);
    foreach ($items as $item) {
        @($inventory[$item['type']] += $item['number']);
    }
    //add items
    $tries = 40;
    //FIXME: replace the completely random selection of refill candidates by choosing only those with a deficit
    while ($restock > 0 && $tries-- > 0) {
        $shop_refill = fetch_first("SELECT * FROM phaos_shop_refill WHERE shop_id='{$shop_id}' order by rand()*item_count_min DESC LIMIT 1", __FILE__, __LINE__);
        if (!$shop_refill) {
            break;
            //stop loop