-
Notifications
You must be signed in to change notification settings - Fork 3
/
santorini.action.php
222 lines (197 loc) · 5.57 KB
/
santorini.action.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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<?php
/**
*------
* BGA framework: © Gregory Isabelli <gisabelli@boardgamearena.com> & Emmanuel Colin <ecolin@boardgamearena.com>
* santorini implementation : © Emmanuel Colin <ecolin@boardgamearena.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.
* -----
*
* santorini.action.php
*
* santorini main action entry point
*
*
* In this file, you are describing all the methods that can be called from your
* user interface logic (javascript).
*
* If you define a method "myAction" here, then you can call it from your javascript code with:
* this.ajaxcall( "/santorini/santorini/myAction.html", ...)
*
*/
class action_santorini extends APP_GameAction
{
// Constructor: please do not modify
public function __default()
{
if (self::isArg('notifwindow')) {
$this->view = 'common_notifwindow';
$this->viewArgs['table'] = self::getArg('table', AT_posint, true);
} else {
$this->view = 'santorini_santorini';
self::trace('Complete reinitialization of board game');
}
}
public function addOffer()
{
self::setAjaxMode();
$this->game->checkAction('addOffer');
$powerId = (int) self::getArg('powerId', AT_int, true);
$this->game->addOffer($powerId);
self::ajaxResponse();
}
public function removeOffer()
{
self::setAjaxMode();
$this->game->checkAction('removeOffer');
$powerId = (int) self::getArg('powerId', AT_int, true);
$this->game->removeOffer($powerId);
self::ajaxResponse();
}
public function confirmOffer()
{
self::setAjaxMode();
$this->game->checkAction('confirmOffer');
$this->game->confirmOffer();
self::ajaxResponse();
}
public function chooseNyxNightPower()
{
$this->game->checkAction('chooseNyxNightPower');
self::setAjaxMode();
$powerId = (int) self::getArg('powerId', AT_int, true);
$this->game->chooseNyxNightPower($powerId);
self::ajaxResponse();
}
public function chooseFirstPlayer()
{
$this->game->checkAction('chooseFirstPlayer');
self::setAjaxMode();
$powerId = (int) self::getArg('powerId', AT_int, true);
$this->game->chooseFirstPlayer($powerId);
self::ajaxResponse();
}
public function choosePower()
{
$this->game->checkAction('choosePower');
self::setAjaxMode();
$powerId = (int) self::getArg('powerId', AT_int, true);
$this->game->choosePower($powerId);
self::ajaxResponse();
}
/*
* TODO
*/
public function skipPower()
{
self::setAjaxMode();
$this->game->checkAction('skip');
$this->game->skipPower();
self::ajaxResponse();
}
public function usePowerWork()
{
self::setAjaxMode();
$this->game->checkAction('use');
$powerId = (int) self::getArg('powerId', AT_posint, true);
$workerId = (int) self::getArg('workerId', AT_posint, true);
$x = (int) self::getArg('x', AT_int, true);
$y = (int) self::getArg('y', AT_int, true);
$z = (int) self::getArg('z', AT_posint, true);
$arg = self::getArg('arg', AT_int, false, null);
if ($arg != null) {
$arg = (int) $arg;
}
$this->game->usePowerWork($powerId, $workerId, $x, $y, $z, $arg);
self::ajaxResponse();
}
public function placeSetup()
{
self::setAjaxMode();
$this->game->checkAction('placeSetup');
$powerId = (int) self::getArg('powerId', AT_posint, true);
$workerId = (int) self::getArg('workerId', AT_posint, true);
$x = (int) self::getArg('x', AT_int, true);
$y = (int) self::getArg('y', AT_int, true);
$z = (int) self::getArg('z', AT_posint, true);
$arg = self::getArg('arg', AT_int, false, null);
if ($arg != null) {
$arg = (int) $arg;
}
$this->game->placeSetup($powerId, $x, $y, $z);
self::ajaxResponse();
}
/*
* TODO
*/
public function placeWorker()
{
self::setAjaxMode();
$this->game->checkAction('placeWorker');
$workerId = (int) self::getArg('workerId', AT_int, true);
$x = (int) self::getArg('x', AT_int, true);
$y = (int) self::getArg('y', AT_int, true);
$z = (int) self::getArg('z', AT_posint, true);
$this->game->placeWorker($workerId, $x, $y, $z);
self::ajaxResponse();
}
/*
* TODO
*/
public function work()
{
self::setAjaxMode();
$workerId = (int) self::getArg('workerId', AT_posint, true);
$x = (int) self::getArg('x', AT_int, true);
$y = (int) self::getArg('y', AT_int, true);
$z = (int) self::getArg('z', AT_posint, true);
$arg = self::getArg('arg', AT_int, false, null);
if ($arg != null) {
$arg = (int) $arg;
}
$this->game->work($workerId, $x, $y, $z, $arg);
self::ajaxResponse();
}
/*
* TODO
*/
public function skipWork()
{
self::setAjaxMode();
$this->game->checkAction('skip');
$this->game->skipWork();
self::ajaxResponse();
}
public function resign()
{
self::setAjaxMode();
$this->game->checkAction('resign');
$this->game->resign();
self::ajaxResponse();
}
/*
* TODO
*/
public function cancelPreviousWorks()
{
self::setAjaxMode();
$this->game->checkAction('cancel');
$this->game->cancelPreviousWorks();
self::ajaxResponse();
}
public function confirmTurn()
{
self::setAjaxMode();
$this->game->checkAction('confirm');
$this->game->confirmTurn();
self::ajaxResponse();
}
public function loadBugSQL()
{
self::setAjaxMode();
$reportId = (int) self::getArg('report_id', AT_int, true);
$this->game->loadBugSQL($reportId);
echo '{"status":1,"data":{"valid":1,"data":null}}';
}
}