-
Notifications
You must be signed in to change notification settings - Fork 0
/
newton.game.php
196 lines (144 loc) · 4.6 KB
/
newton.game.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?php
/**
*------
* BGA framework: © Gregory Isabelli <gisabelli@boardgamearena.com> & Emmanuel Colin <ecolin@boardgamearena.com>
* pasboilerplate implementation : © <Pietro Luigi Porcedda> <pietro.l.porcedda@gmail.com>
*
* This code has been produced on the BGA studio platform for use on http://boardgamearena.com.
* See http://en.boardgamearena.com/#!doc/Studio for more information.
* -----
*
* pasboilerplate.game.php
*
* This is the main file for your game logic.
*
* In this PHP file, you are going to defines the rules of the game.
*
*/
require_once( APP_GAMEMODULE_PATH.'module/table/table.game.php' );
/////////////////////////////////////
/// -- REQUIRE AND USE MODULES -- ///
/////////////////////////////////////
#region
// require base modules
require_once('modules/boilerplate/php/DB.php');
require_once('modules/boilerplate/php/Game.php');
use Newton\Game;
use Newton\DB;
// require entity modules
require_once('modules/php/Entities/Player.php');
use Newton\Entities\Player;
// require manager modules
require_once('modules/php/Managers/Players.php');
use Newton\Managers\PlayersManager;
#endregion
/////////////////////////////////////
class newton extends Table {
///////////////////
/// -- SETUP -- ///
///////////////////
#region
public static $instance = null; // class member to expose instance to access its methods from outside
function __construct() {
parent::__construct();
self::$instance = $this;
self::initGameStateLabels( array(
// "my_first_global_variable" => 10,
// "my_second_global_variable" => 11,
// ...
// "my_first_game_variant" => 100,
// "my_second_game_variant" => 101,
// ...
) );
}
// get class instance to access dynamic methods;
public static function get() {
return self::$instance;
}
protected function getGameName() {
return "newton";
}
protected function setupNewGame($players, $options = []) {
PlayersManager::setupNewGame($players, $options);
$this->activeNextPlayer();
}
protected function getAllDatas() {
$data = [];
// return only informations visible by this current player (client sending page load request to server)
//$currPlayer = self::getCurrentPlayerId();
$sql = "SELECT player_id id, player_score score FROM player ";
$data['players'] = PlayersManager::getUiData();
return $data;
}
function getGameProgression() {
return 0;
}
#endregion
///////////////////
/////////////////////
/// -- UTILITY -- ///
/////////////////////
#region
function test() {
Game::clog("HELLO");
Game::cdump("HELLO");
}
function getCurrent() {
self::getCurrentPlayerId();
}
#endregion
/////////////////////
////////////////////////////
/// -- PLAYER ACTIONS -- ///
////////////////////////////
#region
#endregion
////////////////////////////
/////////////////////////////
/// -- STATE ARGUMENTS -- ///
/////////////////////////////
#region
#endregion
/////////////////////////////
///////////////////////////
/// -- STATE ACTIONS -- ///
///////////////////////////
#region
#endregion
///////////////////////////
/////////////////////////
/// -- ZOMBIE TURN -- ///
/////////////////////////
#region
function zombieTurn($state, $active_player) {
$statename = $state['name'];
if ($state['type'] === "activeplayer") {
switch ($statename) {
default:
$this->gamestate->nextState( "zombiePass" );
break;
}
return;
}
if ($state['type'] === "multipleactiveplayer") {
// Make sure player is in a non blocking status for role turn
$this->gamestate->setPlayerNonMultiactive( $active_player, '' );
return;
}
throw new feException( "Zombie mode not supported at this game state: ".$statename );
}
#endregion
/////////////////////////
/////////////////////////
/// -- DB UPGRADES -- ///
/////////////////////////
#region
#endregion
/////////////////////////
function upgradeTableDb($from_version) {
// if ($from_version <= 1404301345) {
// $sql = "ALTER TABLE DBPREFIX_xxxxxxx ....";
// self::applyDbUpgradeToAllDB( $sql );
// }
}
}