예제 #1
0
function move_active_unit($account, $dir)
{
    global $player_data;
    global $map_data;
    if (player_ready($account) == False) {
        return False;
    }
    $dir_x = array(0, 1, 0, -1);
    $dir_y = array(-1, 0, 1, 0);
    $captions = array("up", "right", "down", "left");
    if (isset($player_data[$account]["active"]) == True) {
        $active = $player_data[$account]["active"];
        $old_x = $player_data[$account]["units"][$active]["x"];
        $old_y = $player_data[$account]["units"][$active]["y"];
        $x = $old_x + $dir_x[$dir];
        $y = $old_y + $dir_y[$dir];
        $caption = $captions[$dir];
        if ($x < 0 or $x >= $map_data["cols"] or $y < 0 or $y >= $map_data["rows"]) {
            $player_data[$account]["status_messages"][] = "move {$caption} failed for active unit (already @ edge of map)";
        } elseif ($map_data["coords"][map_coord($map_data["cols"], $x, $y)] != TERRAIN_LAND) {
            $player_data[$account]["status_messages"][] = "move {$caption} failed for active unit (already @ edge of landmass)";
        } else {
            $forein_unit = False;
            $forein_city = False;
            $player_unit = is_foreign_unit($account, $x, $y, $forein_unit);
            $player_city = is_foreign_city($account, $x, $y, $forein_city);
            if ($player_unit !== False) {
                $player_data[$account]["status_messages"][] = "move {$caption} failed for active unit (player \"{$player_unit}\" has occupying unit)";
                # if player is enemy, attack!
                unit_attack($account, $player_unit, $player_data[$account]["units"][$active], $forein_unit);
            } elseif ($player_city !== False) {
                $player_data[$account]["status_messages"][] = "move {$caption} failed for active unit (player \"{$player_city}\" has occupying city)";
                # if player is enemy, attack!
            } else {
                $player_data[$account]["units"][$active]["x"] = $x;
                $player_data[$account]["units"][$active]["y"] = $y;
                unfog($account, $x, $y, $player_data[$account]["units"][$active]["sight_range"]);
                $type = $player_data[$account]["units"][$active]["type"];
                $player_data[$account]["status_messages"][] = "successfully moved {$type} {$caption} from ({$old_x},{$old_y}) to ({$x},{$y})";
                update_other_players($account, $active);
                cycle_active($account);
            }
        }
        status($account);
    }
}
예제 #2
0
         } else {
             var_dump($player_data);
         }
     }
     break;
 case "move-unit":
     if (is_gm() == True) {
         if (count($parts) == 4) {
             $player = $parts[0];
             $index = $parts[1];
             $x = $parts[2];
             $y = $parts[3];
             if (isset($player_data[$player]["units"][$index]) == True) {
                 $player_data[$player]["units"][$index]["x"] = $x;
                 $player_data[$player]["units"][$index]["y"] = $y;
                 unfog($player, $x, $y, $player_data[$player]["units"][$index]["sight_range"]);
                 $irciv_data_changed = True;
                 update_other_players($player, $index);
                 output_map($player);
                 status($player);
             } else {
                 irciv_privmsg("players[{$player}][units][{$index}] not found");
             }
         } else {
             irciv_privmsg("syntax: [~civ] move-unit <account> <index> <x> <y>");
         }
     }
     break;
 case "object-edit":
     if (is_gm() == True) {
         if (count($parts) >= 4) {