/
victoryCore.php
134 lines (116 loc) · 4.2 KB
/
victoryCore.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
namespace Wargame\TMCW;
use stdClass;
use Wargame\Battle;
/**
*
* Copyright 2012-2015 David Rodal
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation;
* either version 2 of the License, or (at your option) any later version
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Created by JetBrains PhpStorm.
* User: markarianr
* Date: 5/7/13
* Time: 7:06 PM
* To change this template use File | Settings | File Templates.
*/
//include "supplyRulesTraits.php";
class victoryCore extends \Wargame\VictoryCore
{
public $victoryPoints;
protected $movementCache;
protected $combatCache;
protected $supplyLen = false;
use \Wargame\TMCW\ModernSupplyRules;
function __construct($data)
{
parent::__construct($data);
if ($data) {
$this->victoryPoints = $data->victory->victoryPoints;
$this->movementCache = $data->victory->movementCache;
$this->combatCache = $data->victory->combatCache;
$this->supplyLen = $data->victory->supplyLen;
} else {
$this->victoryPoints = array(0, 0, 0);
$this->movementCache = new stdClass();
$this->combatCache = new stdClass();
}
}
public function save()
{
$ret = parent::save();
$ret->victoryPoints = $this->victoryPoints;
$ret->movementCache = $this->movementCache;
$ret->combatCache = $this->combatCache;
$ret->supplyLen = $this->supplyLen;
return $ret;
}
public function setSupplyLen($supplyLen){
$this->supplyLen = $supplyLen[0];
}
public function incrementTurn()
{
$battle = Battle::getBattle();
$theUnits = $battle->force->units;
foreach ($theUnits as $id => $unit) {
if ($unit->status == STATUS_CAN_REINFORCE && $unit->reinforceTurn <= $battle->gameRules->turn && $unit->hexagon->parent != "deployBox") {
$theUnits[$id]->hexagon->parent = "deployBox";
}
}
}
protected function checkVictory($attackingId, $battle){
if(!$this->gameOver){
}
return false;
}
public function playerTurnChange($arg){
$attackingId = $arg[0];
$battle = Battle::getBattle();
/* @var GameRules $gameRules */
$gameRules = $battle->gameRules;
$gameRules->flashMessages[] = "@hide crt";
if($this->checkVictory($attackingId,$battle)){
return;
}
}
public function phaseChange()
{
/* @var $battle MartianCivilWar */
$battle = Battle::getBattle();
/* @var $gameRules GameRules */
$gameRules = $battle->gameRules;
$forceId = $gameRules->attackingForceId;
$turn = $gameRules->turn;
if ($gameRules->phase == RED_COMBAT_PHASE || $gameRules->phase == BLUE_COMBAT_PHASE) {
$gameRules->flashMessages[] = "@hide deployWrapper";
} else {
$gameRules->flashMessages[] = "@hide crt";
/* Restore all un-supplied strengths */
$force = $battle->force;
$this->restoreAllCombatEffects($force);
}
if ($gameRules->phase == BLUE_REPLACEMENT_PHASE || $gameRules->phase == RED_REPLACEMENT_PHASE) {
$gameRules->flashMessages[] = "@show deadpile";
$forceId = $gameRules->attackingForceId;
}
if ($gameRules->phase == BLUE_MOVE_PHASE || $gameRules->phase == RED_MOVE_PHASE) {
$gameRules->flashMessages[] = "@hide deadpile";
if ($battle->force->reinforceTurns->$turn->$forceId) {
$gameRules->flashMessages[] = "@show `deployWrapper";
$gameRules->flashMessages[] = "Reinforcements have been moved to the Deploy/Staging Area";
}
}
}
}