-
Notifications
You must be signed in to change notification settings - Fork 2
/
innovation.action.php
406 lines (303 loc) · 11.7 KB
/
innovation.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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
<?php
/**
*------
* BGA framework: © Gregory Isabelli <gisabelli@boardgamearena.com> & Emmanuel Colin <ecolin@boardgamearena.com>
* Innovation implementation : © Jean Portemer <jportemer@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.
* -----
*
* innovation.action.php
*
* Innovation 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( "/innovation/innovation/myAction.html", ...)
*
*/
class action_innovation 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 = "innovation_innovation";
self::trace( "Complete reinitialization of board game" );
}
}
//****** DEBUG MODE
public function debug_draw() {
self::setAjaxMode();
$card_id = self::getArg("card_id", AT_posint, true);
$this->game->debug_draw($card_id);
self::ajaxResponse();
}
public function debug_meld() {
self::setAjaxMode();
$card_id = self::getArg("card_id", AT_posint, true);
$this->game->debug_meld($card_id);
self::ajaxResponse();
}
public function debug_tuck() {
self::setAjaxMode();
$card_id = self::getArg("card_id", AT_posint, true);
$this->game->debug_tuck($card_id);
self::ajaxResponse();
}
public function debug_score() {
self::setAjaxMode();
$card_id = self::getArg("card_id", AT_posint, true);
$this->game->debug_score($card_id);
self::ajaxResponse();
}
public function debug_achieve() {
self::setAjaxMode();
$card_id = self::getArg("card_id", AT_posint, true);
$this->game->debug_achieve($card_id);
self::ajaxResponse();
}
public function debug_return() {
self::setAjaxMode();
$card_id = self::getArg("card_id", AT_posint, true);
$this->game->debug_return($card_id);
self::ajaxResponse();
}
public function debug_topdeck() {
self::setAjaxMode();
$card_id = self::getArg("card_id", AT_posint, true);
$this->game->debug_topdeck($card_id);
self::ajaxResponse();
}
public function debug_dig() {
self::setAjaxMode();
$card_id = self::getArg("card_id", AT_posint, true);
$this->game->debug_dig($card_id);
self::ajaxResponse();
}
public function debug_foreshadow() {
self::setAjaxMode();
$card_id = self::getArg("card_id", AT_posint, true);
$this->game->debug_foreshadow($card_id);
self::ajaxResponse();
}
public function debug_splay() {
self::setAjaxMode();
$color = self::getArg("color", AT_posint, true);
$direction = self::getArg("direction", AT_posint, true);
$this->game->debug_splay($color, $direction);
self::ajaxResponse();
}
//******
public function initialMeld() {
self::setAjaxMode();
// Retrieve arguments
$card_id = self::getArg("card_id", AT_posint, true);
// Call initialMeld from game logic
$this->game->initialMeld($card_id);
self::ajaxResponse();
}
public function updateInitialMeld() {
self::setAjaxMode();
// Retrieve arguments
$card_id = self::getArg("card_id", AT_posint, true);
// Call updateInitialMeld from game logic
$this->game->updateInitialMeld($card_id);
self::ajaxResponse();
}
public function passSeizeRelic() {
self::setAjaxMode();
// Call passSeizeRelic from game logic
$this->game->passSeizeRelic();
self::ajaxResponse();
}
public function seizeRelicToHand() {
self::setAjaxMode();
// Call seizeRelicToHand from game logic
$this->game->seizeRelicToHand();
self::ajaxResponse();
}
public function seizeRelicToAchievements() {
self::setAjaxMode();
// Call seizeRelicToAchievements from game logic
$this->game->seizeRelicToAchievements();
self::ajaxResponse();
}
public function dogmaArtifactOnDisplay() {
self::setAjaxMode();
// Call dogmaArtifactOnDisplay from game logic
$this->game->dogmaArtifactOnDisplay();
self::ajaxResponse();
}
public function returnArtifactOnDisplay() {
self::setAjaxMode();
// Call returnArtifactOnDisplay from game logic
$this->game->returnArtifactOnDisplay();
self::ajaxResponse();
}
public function passArtifactOnDisplay() {
self::setAjaxMode();
// Call passArtifactOnDisplay from game logic
$this->game->passArtifactOnDisplay();
self::ajaxResponse();
}
public function passPromoteCard() {
self::setAjaxMode();
// Call passPromoteCard from game logic
$this->game->passPromoteCard();
self::ajaxResponse();
}
public function promoteCard() {
self::setAjaxMode();
// Retrieve arguments
$card_id = self::getArg("card_id", AT_posint, true);
// Call promoteCard from game logic
$this->game->promoteCard($card_id);
self::ajaxResponse();
}
public function promoteCardBack() {
self::setAjaxMode();
// Retrieve arguments
$owner = self::getArg("owner", AT_posint, true);
$location = self::getArg("location", AT_alphanum, true);
$age = self::getArg("age", AT_posint, true);
$type = self::getArg("type", AT_posint, true);
$is_relic = self::getArg("is_relic", AT_posint, true);
$position = self::getArg("position", AT_posint, true);
// Call promoteCardBack from game logic
$this->game->promoteCardBack($owner, $location, $age, $type, $is_relic, $position);
self::ajaxResponse();
}
public function passDogmaPromotedCard() {
self::setAjaxMode();
// Call passDogmaPromotedCard from game logic
$this->game->passDogmaPromotedCard();
self::ajaxResponse();
}
public function dogmaPromotedCard() {
self::setAjaxMode();
// Call dogmaPromotedCard from game logic
$this->game->dogmaPromotedCard();
self::ajaxResponse();
}
public function achieve() {
self::setAjaxMode();
// Retrieve arguments
$age = self::getArg("age", AT_posint, true);
// Call achieve from game logic
$this->game->achieve($age);
self::ajaxResponse();
}
public function draw() {
self::setAjaxMode();
// No argument
// Call draw from game logic
$this->game->draw();
self::ajaxResponse();
}
public function meld() {
self::setAjaxMode();
// Retrieve arguments
$card_id = self::getArg("card_id", AT_posint, true);
// Call meld from game logic
$this->game->meld($card_id);
self::ajaxResponse();
}
public function dogma() {
self::setAjaxMode();
// Retrieve arguments
$card_id = self::getArg("card_id", AT_posint, true);
// Call dogma from game logic
$this->game->dogma($card_id);
self::ajaxResponse();
}
public function endorse() {
self::setAjaxMode();
// Retrieve arguments
$card_to_endorse_id = self::getArg("card_to_endorse_id", AT_posint, true);
$card_to_tuck_id = self::getArg("card_to_tuck_id", AT_posint, true);
// Call endorse from game logic
$this->game->endorse($card_to_endorse_id, $card_to_tuck_id);
self::ajaxResponse();
}
public function choose() {
self::setAjaxMode();
// Retrieve arguments
$card_id = self::getArg("card_id", AT_int, true); // -1 if no choice
// Call choose from game logic
$this->game->choose($card_id);
self::ajaxResponse();
}
public function chooseRecto() {
self::setAjaxMode();
// Retrieve arguments
$owner = self::getArg("owner", AT_posint, true);
$location = self::getArg("location", AT_alphanum, true);
$age = self::getArg("age", AT_posint, true);
$type = self::getArg("type", AT_posint, true);
$is_relic = self::getArg("is_relic", AT_posint, true);
$position = self::getArg("position", AT_posint, true);
// Call choose from game logic
$this->game->chooseRecto($owner, $location, $age, $type, $is_relic, $position);
self::ajaxResponse();
}
public function chooseSpecialOption() {
self::setAjaxMode();
// Retrieve arguments
$choice = self::getArg("choice", AT_posint, true);
// Call chooseSpecialOption from game logic
$this->game->chooseSpecialOption($choice);
self::ajaxResponse();
}
public function publicationRearrange() {
self::setAjaxMode();
// Retrieve arguments
$color = self::getArg("color", AT_posint, true);
$permutations_done_raw = self::getArg("permutations_done", AT_numberlist, true);
// Reshape them a bit
$permutations_done = explode(';', $permutations_done_raw);
foreach($permutations_done as &$group) {
$group = explode(',', $group);
$group = array('position' => $group[0], 'delta' => $group[1]);
}
$choice = array('color' => $color, 'permutations_done' => $permutations_done);
// Call chooseSpecialOption from game logic
$this->game->chooseSpecialOption($choice);
self::ajaxResponse();
}
public function updateDisplayMode() {
self::setAjaxMode();
// Retrieve arguments
$display_mode = self::getArg("display_mode", AT_bool, true);
// Call updateDisplayMode from game logic
$this->game->updateDisplayMode($display_mode);
self::ajaxResponse();
}
public function updateViewFull() {
self::setAjaxMode();
// Retrieve arguments
$view_full = self::getArg("view_full", AT_bool, true);
// Call updateDisplayMode from game logic
$this->game->updateViewFull($view_full);
self::ajaxResponse();
}
/*
Example:
public function myAction()
{
self::setAjaxMode();
// Retrieve arguments
// Note: these arguments correspond to what has been sent through the javascript "ajaxcall" method
$arg1 = self::getArg("myArgument1", AT_posint, true);
$arg2 = self::getArg("myArgument2", AT_posint, true);
// Then, call the appropriate method in your game logic, like "playCard" or "myAction"
$this->game->myAction( $arg1, $arg2 );
self::ajaxResponse();
}
*/
}