Beispiel #1
0
function transfer_to_xy($village_id, $target_x, $target_y, $except_crop = false, $reserve_ratio = 0)
{
    list($result, $carts, $amount_per_cart, $market_id) = get_transfer_page($village_id);
    if (!$result) {
        return false;
    }
    $curr_res = get_res_info($result);
    $reserve_1 = round($curr_res[4] * $reserve_ratio / 100);
    // wood, brick, iron
    $reserve_2 = round($curr_res[7] * $reserve_ratio / 100);
    // crop
    $curr_res[0] = max(0, $curr_res[0] - $reserve_1);
    $curr_res[1] = max(0, $curr_res[1] - $reserve_1);
    $curr_res[2] = max(0, $curr_res[2] - $reserve_1);
    $curr_res[3] = max(0, $curr_res[3] - $reserve_2);
    if ($except_crop) {
        $curr_res[3] = 0;
    }
    $trans_res = calc_transfer_amount($carts, $amount_per_cart, $curr_res[0], $curr_res[1], $curr_res[2], $curr_res[3]);
    if ($trans_res) {
        transfer_confirm($market_id, $target_x, $target_y, $trans_res[0], $trans_res[1], $trans_res[2], $trans_res[3]);
    }
}
Beispiel #2
0
function transfer_crop_to_xy($village_from, $x, $y, $reserve = 0)
{
    list($result, $carts, $amount_per_cart, $market_id) = get_transfer_page($village_from);
    if (!$result) {
        return false;
    }
    $curr_res = get_res_info($result);
    if ($curr_res[3] <= $reserve) {
        return false;
    }
    $total = $curr_res[3] - $reserve;
    $carts_needed = ceil($total / $amount_per_cart);
    if ($carts_needed == 0) {
        return;
    }
    if ($carts <= 0) {
        return;
    }
    $total = min($carts, $carts_needed) * $amount_per_cart;
    transfer_confirm($market_id, $x, $y, 0, 0, 0, $total);
    echo "Transfering 0 | 0 | 0 | {$total} to ({$x}|{$y})\n";
}