<?php

require_once dirname(__FILE__) . '/../classes/WarOfNations2.class.php';
require_once dirname(__FILE__) . '/../classes/data/DataLoad.class.php';
if (count($argv) == 2) {
    $world = $argv[1];
    echo "Got Command Line Argument for World [{$world}]\r\n";
} else {
    $world = 13;
    echo "No Command Line Argument Found.  Using Default World [{$world}]\r\n";
}
$won = new WarOfNations();
$won->setDataLoadId(DataLoadDAO::initNewLoad($won->db, 'JOIN_WORLD', 0, "World {$world}"));
DataLoadDAO::startLoad($won->db, $won->data_load_id);
$won->JoinNewWorld($world);
DataLoadDAO::loadComplete($won->db, $won->data_load_id);
<?php

require_once dirname(__FILE__) . '/../classes/WarOfNations2.class.php';
require_once dirname(__FILE__) . '/../classes/data/DataLoad.class.php';
$won = new WarOfNations();
$won->setDataLoadId(DataLoadDAO::initNewLoad($won->db, 'TEST_AUTHENTICATE2', 0));
DataLoadDAO::startLoad($won->db, $won->data_load_id);
$won->Authenticate();
DataLoadDAO::loadComplete($won->db, $won->data_load_id);
<?php

require_once dirname(__FILE__) . '/../classes/WarOfNations2.class.php';
require_once dirname(__FILE__) . '/../classes/data/DataLoad.class.php';
$won = new WarOfNations();
$won->setDataLoadId(DataLoadDAO::initNewLoad($won->db, 'TEST_WORLDMAP2', 0));
DataLoadDAO::startLoad($won->db, $won->data_load_id);
$won->GetWorldMap(-1000, 1400, 100, 100);
DataLoadDAO::loadComplete($won->db, $won->data_load_id);
<?php

require_once dirname(__FILE__) . '/../classes/WarOfNations2.class.php';
require_once dirname(__FILE__) . '/../classes/data/DataLoad.class.php';
$won = new WarOfNations();
$won->setDataLoadId(DataLoadDAO::initNewLoad($won->db, 'TEST_LEADERBOARDS2', 0));
DataLoadDAO::startLoad($won->db, $won->data_load_id);
$won->GetLeaderboard(1, 0);
// Recommended setting for detailed scanning: 1400
$min_radius = 0;
if (count($argv) == 2) {
    $world = $argv[1];
    echo "Got Command Line Argument for World [{$world}]\r\n";
} else {
    $world = 13;
    echo "No Command Line Argument Found.  Using Default World [{$world}]\r\n";
}
/*
=======================================================
============== Authenticate the Phone =================
=======================================================
*/
$won = new WarOfNations();
$won->setDataLoadId(DataLoadDAO::initNewLoad($won->db, 'WORLD_MAP', 0, "World {$world}"));
DataLoadDAO::startLoad($won->db, $won->data_load_id);
$won->Authenticate();
// Check if we're in the correct world
if ($won->auth->world_id != $world) {
    // Switch world if not
    if ($won->SwitchWorld($world) === false) {
        // If we didn't switch successfully, join a new world
        $won->JoinNewWorld($world);
    }
}
// If we're still not in the right world, quit
if ($won->auth->world_id != $world) {
    DataLoadDAO::loadFailed($won->db, $won->data_load_id);
    die("ERROR: Not Authenticated to World {$world}");
}
// Max number of waves that can be sent from 1 base
$preferred_distance = 700;
// Preferred flight distance, use this to balance flight time
// Timing Settings
$seconds_between_waves = 2;
$seconds_between_bases = 5;
$hours_between_sessions = 6;
// Order to fly troops out of base (most valuable first, except artillery)
$fly_order = array('Doom Walker', 'Heavy Gunship', 'Blaze Launcher', 'Railgun Tank', 'Titan', 'Hellfire', 'Centurion', 'Hailstorm', 'Arachnid', 'Hawk', 'Hammerhead', 'Rocket Truck', 'Transport', 'Bomber', 'Helicopter', 'Tank', 'Jeep', 'Artillery');
// Unit to use for ensuring all waves travel the same speed
$slow_unit = 'Artillery';
/*************** Program Setup ***************/
// Need this initalized so that we can use the database!
$won = new WarOfNations();
// Initalize the data load tracker
$won->setDataLoadId(DataLoadDAO::initNewLoad($won->db, 'FLY_TROOPS', 0));
DataLoadDAO::startLoad($won->db, $won->data_load_id);
// Get the Device ID to use (main account)
if ($device_id == false) {
    $device_id = PgrmConfigDAO::getConfigProperty($won->db, 'value1', 'MAIN_DEVICE_ID');
}
// Authenticate
$auth_result = $won->Authenticate(false, $device_id, true);
$last_session_time = time();
//$auth_result = json_decode(file_get_contents('auth_result.json'), true);
//print_r($auth_result['responses'][0]['return_value']['player_towns']);
//print_r($auth_result['responses'][0]['return_value']['player_town_reserves']);
// Get an instance of our game operations class
$game = $won->GetGameOperations();
$unit_map = $game::GetUnitMap();
$log_seq = 0;
// Use this when first == false
//$current = strtotime('2015-07-23 04:57:54');
//$training_landing_time = 1437645510;
//$training_landing_time->setTimezone(new DateTimeZone('America/Chicago'));
//echo "$current\r\n";
//echo "$training_landing_time\r\n";
//echo $training_landing_time - $current;
//die();
// Pause before starting
//usleep(45 * 60 * 1000000);
// TODO: Build something so that I can control this remotely
// TODO: If we run out of commanders to jeep with, make the program wait some time and then try to start again
// Need this initalized so that we can use the database!
$won = new WarOfNations();
// Initalize the data load tracker
$won->setDataLoadId(DataLoadDAO::initNewLoad($won->db, 'TRAIN_COMMANDERS', 0));
DataLoadDAO::startLoad($won->db, $won->data_load_id);
// Send a text message to tell us that this is starting.  This is really just a test of the texting feature.
$won->sendWarningText('Starting Commander Training!', false);
// Initialize Settings
$training_base_id = 2;
// Banner 38: 101013177372837
// Zion 38: 101013171988840
// HQ 38: 101013100928452
// My 34: 101013101930604
$npc_id = '101013177372837';
/* 
Commander IDs:
 207: Hellborn
 208: Iron Wing
 209: Fury Forge
<?php

require_once dirname(__FILE__) . '/../classes/WarOfNations2.class.php';
require_once dirname(__FILE__) . '/../classes/data/DataLoad.class.php';
require_once dirname(__FILE__) . '/../vendor/autoload.php';
use WebSocket\Client;
// Need this initalized so that we can use the database!
$won = new WarOfNations();
// Initalize the data load tracker
$won->setDataLoadId(DataLoadDAO::initNewLoad($won->db, 'SUBSCRIBE_SERVICE', 0));
DataLoadDAO::startLoad($won->db, $won->data_load_id);
// Get an instance of our game operations class
$game = $won->GetGameOperations();
// Subscribe
$purchase = $game->CheckPurchaseBundle('jp.gree.warofnations.gold01');
if ($won->auth->world_id != $world) {
    DataLoadDAO::loadFailed($won->db, $won->data_load_id);
    die("ERROR: Not Authenticated to World {$world}");
}
/*
=======================================================
===================== Do Stuff ========================
=======================================================
*/
echo "Getting Top {$top_x_players} Player Leaderboards\r\n";
$start = 0;
while ($start < $top_x_players) {
    echo "Getting Player Leaderboard {$start} - " . ($start + $interval) . "\r\n";
    DataLoadDAO::operationComplete($won->db, $won->data_load_id);
    $won->GetLeaderboard(1, $start);
    $start += $interval;
}
echo "Done!\r\n";
DataLoadDAO::loadComplete($won->db, $won->data_load_id);
$won->setDataLoadId(DataLoadDAO::initNewLoad($won->db, 'ALLIANCE_LEADERBOARDS', $top_x_alliances / $interval, "World {$world}"));
DataLoadDAO::startLoad($won->db, $won->data_load_id);
echo "\r\nGetting Top {$top_x_alliances} Alliance Leaderboards\r\n";
$start = 0;
while ($start < $top_x_alliances) {
    echo "Getting Alliance Leaderboard {$start} - " . ($start + $interval) . "\r\n";
    DataLoadDAO::operationComplete($won->db, $won->data_load_id);
    $won->GetLeaderboard(2, $start);
    $start += $interval;
}
echo "Done!\r\n";
DataLoadDAO::loadComplete($won->db, $won->data_load_id);
<?php

require_once dirname(__FILE__) . '/../classes/WarOfNations2.class.php';
require_once dirname(__FILE__) . '/../classes/data/DataLoad.class.php';
// Initialize Variables
$alliance_to_join = '101013232844480';
// 1st_HQ
$amount_needed = 58;
$amount_donated = 0;
// Login to Main
$won_main = new WarOfNations();
$won_main->setDataLoadId(DataLoadDAO::initNewLoad($won_main->db, 'OPERATION_CONCRETE', 0));
DataLoadDAO::startLoad($won_main->db, $won_main->data_load_id);
$won_main->Authenticate(false, 5);
$game_main = $won_main->GetGameOperations();
// Start Loop Here
while ($amount_donated < $amount_needed) {
    // Create Alt
    $won_alt = new WarOfNations();
    $won_alt->setDataLoadId($won_main->data_load_id);
    // Create a new account
    $won_alt->auth->CreateNewPlayer();
    //$won_alt->Authenticate(false, 17); // Use if something fails
    usleep(1000000);
    // Join World 13
    if ($won_alt->auth->world_id != 13) {
        $won_alt->auth->JoinNewWorld(13);
    }
    usleep(1000000);
    // Buy Reinforced Concrete (180000)
    $game_alt = $won_alt->GetGameOperations();