From 3a81d46a97e1f9c30c35ee9764155ae0979efded Mon Sep 17 00:00:00 2001 From: Goose Date: Tue, 19 May 2020 22:21:46 -0400 Subject: [PATCH] Tweaks and fixes --- application/config/config.php | 2 +- application/controllers/Game.php | 2 +- application/models/Game_model.php | 4 ++-- application/views/scripts/unit_script.php | 8 ++++++-- notes.txt | 1 + sql/landgrab.sql | 2 +- sql/world.sql | 2 +- 7 files changed, 13 insertions(+), 8 deletions(-) diff --git a/application/config/config.php b/application/config/config.php index 60b04e2..48ec0b4 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -23,7 +23,7 @@ | */ -$default_domain = 'localhost/landgrab.xyz'; +$default_domain = 'landgrab.xyz/alpha'; $allowed_domains = array( 'localhost/landgrab', diff --git a/application/controllers/Game.php b/application/controllers/Game.php index d1ebad3..1a7db07 100644 --- a/application/controllers/Game.php +++ b/application/controllers/Game.php @@ -100,7 +100,7 @@ public function update_world($world_key) $data['account'] = $this->user_model->this_account($data['world']['id']); - $server_map_update_interval_s = (MAP_UPDATE_INTERVAL_MS / 1000) * 2; + $server_map_update_interval_s = (MAP_UPDATE_INTERVAL_MS / 1000) * 3; $data['tiles'] = $this->game_model->get_all_tiles_in_world_recently_updated($data['world']['id'], $server_map_update_interval_s); api_response($data); } diff --git a/application/models/Game_model.php b/application/models/Game_model.php index dd20fb7..e694e3f 100644 --- a/application/models/Game_model.php +++ b/application/models/Game_model.php @@ -840,7 +840,7 @@ function can_claim($account, $tile, $previous_tile) { api_error_response('attack_requires_war', 'You must declare war before attacking this nation'); } } - if (!$this->unit_can_take_settlement($tile['settlement_key'], $previous_tile['unit_key'])) { + if ($tile['account_key'] != $account['id'] && !$this->unit_can_take_settlement($tile['settlement_key'], $previous_tile['unit_key'])) { api_error_response('unit_not_able_to_take_square', 'This unit is not able to take this size of township'); } return true; @@ -860,7 +860,7 @@ function can_move_to($account, $tile, $previous_tile) { api_error_response('tile_is_occupied', 'There is already a friendly unit on this tile'); } } - if (!$this->unit_can_take_settlement($tile['settlement_key'], $previous_tile['unit_key'])) { + if ($tile['account_key'] != $account['id'] && !$this->unit_can_take_settlement($tile['settlement_key'], $previous_tile['unit_key'])) { api_error_response('unit_not_able_to_take_square', 'This unit is not able to take this size of township'); } return true; diff --git a/application/views/scripts/unit_script.php b/application/views/scripts/unit_script.php index 8307c37..22bcded 100644 --- a/application/views/scripts/unit_script.php +++ b/application/views/scripts/unit_script.php @@ -162,6 +162,7 @@ function unit_can_move_to_new_tile(marker, start_lat, start_lng, end_lat, end_ln let allowed_move_to_new_position = false; let start_tile_id = tiles_by_coord[start_lat + ',' + start_lng].tile_key; let end_tile_id = tiles_by_coord[end_lat + ',' + end_lng].tile_key; + let end_tile_account_key = tiles_by_coord[end_lat + ',' + end_lng].account_key; let settlement_key = tiles_by_coord[end_lat + ',' + end_lng].settlement_key; // Check conditions @@ -180,7 +181,7 @@ function unit_can_move_to_new_tile(marker, start_lat, start_lng, end_lat, end_ln else if (is_friendly_square(end_lat, end_lng)) { alert('You must declare war through diplomacy before you can attack this land'); } - else if (!unit_can_take_settlement(settlement_key, marker.unit.unit_key)) { + else if (!unit_can_take_settlement(end_tile_account_key, settlement_key, marker.unit.unit_key)) { alert('This unit is not able to take this size of township'); } else { @@ -213,7 +214,10 @@ function move_unit_to_new_tile(marker, combat, start_lat, start_lng, end_lat, en } } - function unit_can_take_settlement(settlement_key, unit_key) { + function unit_can_take_settlement(end_tile_account_key, settlement_key, unit_key) { + if (end_tile_account_key == account.id) { + return true; + } if (settlement_key == town_key) { if (unit_key == airforce_key) { return false; diff --git a/notes.txt b/notes.txt index 514a41e..59de526 100644 --- a/notes.txt +++ b/notes.txt @@ -14,6 +14,7 @@ HIGH PRIORITY make trade screen more clear on existing for offer reset cron MEDIUM PRIORITY + Show current supplies of relevant settlement or industry card shortages more clear default to terrain view settlement/industry require round of feed to establish diff --git a/sql/landgrab.sql b/sql/landgrab.sql index 27c5192..de377ed 100644 --- a/sql/landgrab.sql +++ b/sql/landgrab.sql @@ -547,7 +547,7 @@ INSERT INTO `settlement` ( ), (11, 'Timber', 'timber', 3, FALSE, FALSE, TRUE, FALSE, FALSE, - TRUE, TRUE, FALSE, FALSE, FALSE, + TRUE, TRUE, FALSE, TRUE, FALSE, 10, '', 5, 10, 1 ), (12, 'Fiber', 'fiber', 3, diff --git a/sql/world.sql b/sql/world.sql index 3d8156b..13eb5a3 100644 --- a/sql/world.sql +++ b/sql/world.sql @@ -4211,7 +4211,7 @@ INSERT INTO `tile` (`id`, `lat`, `lng`, `world_key`, `account_key`, `terrain_key (4165, 12, -80, 1, NULL, 6, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, NULL, NULL, NULL, '2020-02-29 11:09:56'), (4166, 14, -80, 1, NULL, 6, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, NULL, NULL, NULL, '2020-02-29 11:09:56'), (4167, 16, -80, 1, NULL, 6, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, NULL, NULL, NULL, '2020-02-29 11:09:56'), -(4168, 18, -80, 1, NULL, 6, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, NULL, NULL, NULL, '2020-02-29 11:09:56'), +(4168, 18, -80, 1, NULL, 5, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, NULL, NULL, NULL, '2020-02-29 11:09:56'), (4169, 20, -80, 1, NULL, 5, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, NULL, NULL, NULL, '2020-03-01 06:00:56'), (4170, 22, -80, 1, NULL, 5, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, NULL, NULL, NULL, '2020-03-03 01:37:53'), (4171, 24, -80, 1, NULL, 5, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, NULL, NULL, NULL, '2020-05-18 00:39:22'),