1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by Gorlum 11.10.2017 13:17 |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Fleet; |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
use Core\GlobalContainer; |
10
|
|
|
|
11
|
|
|
class MissionData { |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @var Fleet $fleetEntity |
15
|
|
|
*/ |
16
|
|
|
protected $fleetEntity; |
17
|
|
|
|
18
|
|
|
/** @var array|null $fleet Fleet row from DB */ |
19
|
|
|
public $fleet; |
20
|
|
|
/** @var array|null */ |
21
|
|
|
public $dstUserRow; |
22
|
|
|
/** @var array|null */ |
23
|
|
|
public $dstPlanetRow; |
24
|
|
|
/** @var array|null */ |
25
|
|
|
public $fleetOwnerRow; |
26
|
|
|
/** @var array|null */ |
27
|
|
|
public $srcPlanetRow; |
28
|
|
|
/** @var array|null */ |
29
|
|
|
public $fleet_event; |
30
|
|
|
|
31
|
|
|
/** @var \General $general */ |
32
|
|
|
protected $general; |
33
|
|
|
/** @var \classLocale $lang */ |
34
|
|
|
protected $lang; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param FleetDispatchEvent $fleetEvent |
38
|
|
|
* |
39
|
|
|
* @return static |
40
|
|
|
*/ |
41
|
|
|
public static function buildFromArray($fleetEvent) { |
42
|
|
|
return new static($fleetEvent); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* MissionData constructor. |
47
|
|
|
* |
48
|
|
|
* @param ?FleetDispatchEvent $fleetEvent |
49
|
|
|
*/ |
50
|
|
|
public function __construct($fleetEvent) { |
51
|
|
|
$this->general = $this->getDefaultGeneral(); |
52
|
|
|
$this->lang = $this->getDefaultLang(); |
53
|
|
|
|
54
|
|
|
$this->fromMissionArray($fleetEvent); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @param GlobalContainer $gc |
59
|
|
|
*/ |
60
|
|
|
public function changeGc($gc) { |
61
|
|
|
$this->general = $gc->general; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param ?FleetDispatchEvent $fleetEvent |
66
|
|
|
*/ |
67
|
|
|
protected function fromMissionArray($fleetEvent) { |
68
|
|
|
$this->fleet = $fleetEvent->fleet; |
69
|
|
|
$this->dstUserRow = $fleetEvent->dstPlanetOwnerId ? db_user_by_id($fleetEvent->dstPlanetOwnerId) : null; |
|
|
|
|
70
|
|
|
$this->dstPlanetRow = $fleetEvent->dstPlanetId ? $fleetEvent->dstPlanetRow : null; |
|
|
|
|
71
|
|
|
$this->fleetOwnerRow = $fleetEvent->srcPlanetOwnerId ? db_user_by_id($fleetEvent->fleet['fleet_owner']) : null; |
|
|
|
|
72
|
|
|
$this->srcPlanetRow = $fleetEvent->srcPlanetId ? $fleetEvent->srcPlanetRow : null; |
|
|
|
|
73
|
|
|
$this->fleet_event = $fleetEvent->event; |
|
|
|
|
74
|
|
|
|
75
|
|
|
$this->fleetEntity = new Fleet(); |
76
|
|
|
$this->fleetEntity->dbLoadRecord($this->fleet['fleet_id']); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
protected function dbFleetFindRecordById($fleetId) { |
80
|
|
|
return RecordFleet::findById($fleetId); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @return \classLocale |
85
|
|
|
*/ |
86
|
|
|
protected function getDefaultLang() { |
87
|
|
|
return \SN::$lang; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @return \General |
92
|
|
|
*/ |
93
|
|
|
protected function getDefaultGeneral() { |
94
|
|
|
return \SN::$gc->general; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
} |
98
|
|
|
|