1
|
|
|
<?php /** @noinspection PhpUnnecessaryCurlyVarSyntaxInspection */ |
2
|
|
|
|
3
|
|
|
use Fleet\DbFleetStatic; |
4
|
|
|
use Fleet\FleetDispatchEvent; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* @param FleetDispatchEvent $fleetEvent |
8
|
|
|
* |
9
|
|
|
* @return int|mixed |
10
|
|
|
*/ |
11
|
|
|
function flt_mission_colonize($fleetEvent) { |
12
|
|
|
$fleet_row = $fleetEvent->fleet; |
13
|
|
|
/** @noinspection PhpDeprecationInspection */ |
14
|
|
|
$fleetOwnerRow = db_user_by_id($fleetEvent->fleet['fleet_owner'], true); |
|
|
|
|
15
|
|
|
|
16
|
|
|
global $lang; |
17
|
|
|
|
18
|
|
|
$targetAddress = sprintf($lang['sys_address_planet'], $fleet_row['fleet_end_galaxy'], $fleet_row['fleet_end_system'], $fleet_row['fleet_end_planet']); |
19
|
|
|
|
20
|
|
|
$fleet_array = sys_unit_str2arr($fleet_row['fleet_array']); |
21
|
|
|
|
22
|
|
|
$TheMessage = $lang['sys_colo_no_colonizer']; |
23
|
|
|
if ($fleet_array[SHIP_COLONIZER] >= 1) { |
24
|
|
|
$TheMessage = $lang['sys_colo_not_free']; |
25
|
|
|
if (empty($fleetEvent->dstPlanetRow)) { |
26
|
|
|
$iPlanetCount = get_player_current_colonies($fleetOwnerRow); |
27
|
|
|
|
28
|
|
|
// Can we colonize more planets? |
29
|
|
|
$TheMessage = $lang['sys_colo_max_colo']; |
30
|
|
|
if ($iPlanetCount < get_player_max_colonies($fleetOwnerRow)) { |
31
|
|
|
// Yes, we can colonize |
32
|
|
|
$TheMessage = $lang['sys_colo_bad_pos']; |
33
|
|
|
$NewOwnerPlanet = uni_create_planet( |
34
|
|
|
$fleet_row['fleet_end_galaxy'], $fleet_row['fleet_end_system'], $fleet_row['fleet_end_planet'], |
35
|
|
|
$fleet_row['fleet_owner'], "{$lang['sys_colo_default_name']} {$iPlanetCount}", false, |
36
|
|
|
array('user_row' => $fleetOwnerRow)); |
37
|
|
|
if ($NewOwnerPlanet) { |
38
|
|
|
$TheMessage = $lang['sys_colo_arrival'] . $targetAddress . $lang['sys_colo_all_is_ok']; |
39
|
|
|
msg_send_simple_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_start_time'], MSG_TYPE_SPY, $lang['sys_colo_mess_from'], $lang['sys_colo_mess_report'], $TheMessage); |
40
|
|
|
|
41
|
|
|
$fleet_array[SHIP_COLONIZER]--; |
42
|
|
|
$fleet_row['fleet_amount']--; |
43
|
|
|
$fleet_row['fleet_array'] = sys_unit_arr2str($fleet_array); |
44
|
|
|
|
45
|
|
|
/** @noinspection PhpDeprecationInspection */ |
46
|
|
|
return RestoreFleetToPlanet($fleet_row, false); |
|
|
|
|
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
DbFleetStatic::fleet_send_back($fleet_row); |
53
|
|
|
msg_send_simple_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_start_time'], MSG_TYPE_SPY, $lang['sys_colo_mess_from'], $lang['sys_colo_mess_report'], "{$lang['sys_colo_arrival']}{$targetAddress}{$TheMessage}"); |
54
|
|
|
|
55
|
|
|
return CACHE_FLEET; |
56
|
|
|
} |
57
|
|
|
|