-
Notifications
You must be signed in to change notification settings - Fork 0
/
velonimo.action.php
125 lines (99 loc) · 3.61 KB
/
velonimo.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
<?php
/**
*------
* BGA framework: © Gregory Isabelli <[email protected]> & Emmanuel Colin <[email protected]>
* Velonimo implementation : © Oliver THEBAULT (a.k.a. Oliboy50)
*
* This code has been produced on the BGA studio platform for use on https://boardgamearena.com.
* See http://en.doc.boardgamearena.com/Studio for more information.
* -----
*
* velonimo.action.php
*
* Velonimo 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( "/velonimo/velonimo/myAction.html", ...)
*
*/
declare(strict_types=1);
class action_velonimo 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 = 'velonimo_velonimo';
self::trace('Complete reinitialization of board game');
}
}
public function playCards()
{
self::setAjaxMode();
$cardsArg = trim(self::getArg('cards', AT_numberlist, true), ';');
$cardIds = explode(';', $cardsArg);
$withJerseyArg = (bool) self::getArg('withJersey', AT_bool, true);
$withLegendsBroomWagonArg = (bool) self::getArg('withLegendsBroomWagon', AT_bool, true);
$withLegendsEagleArg = (bool) self::getArg('withLegendsEagle', AT_bool, true);
$withLegendsPandaArg = (bool) self::getArg('withLegendsPanda', AT_bool, true);
$withLegendsSharkArg = (bool) self::getArg('withLegendsShark', AT_bool, true);
$withLegendsBadgerArg = (bool) self::getArg('withLegendsBadger', AT_bool, true);
$withLegendsElephantArg = (bool) self::getArg('withLegendsElephant', AT_bool, true);
$this->game->playCards(
array_map(fn ($id) => (int) $id, $cardIds),
$withJerseyArg,
$withLegendsBroomWagonArg,
$withLegendsEagleArg,
$withLegendsPandaArg,
$withLegendsSharkArg,
$withLegendsBadgerArg,
$withLegendsElephantArg
);
self::ajaxResponse();
}
public function passTurn()
{
self::setAjaxMode();
$this->game->passTurn();
self::ajaxResponse();
}
public function selectNextPlayer()
{
self::setAjaxMode();
$selectedPlayerId = trim(self::getArg('selectedPlayerId', AT_int, true));
$this->game->selectNextPlayer((int) $selectedPlayerId);
self::ajaxResponse();
}
/**
* /!\ 2P mode only
*/
public function selectWhoTakeAttackReward()
{
self::setAjaxMode();
$selectedPlayerId = trim(self::getArg('selectedPlayerId', AT_int, true));
$this->game->selectWhoTakeAttackReward((int) $selectedPlayerId);
self::ajaxResponse();
}
public function selectPlayerToPickCards()
{
self::setAjaxMode();
$selectedPlayerId = trim(self::getArg('selectedPlayerId', AT_int, true));
$this->game->selectPlayerToPickCards((int) $selectedPlayerId);
self::ajaxResponse();
}
public function selectCardsToGiveBack()
{
self::setAjaxMode();
$cardsArg = trim(self::getArg('cards', AT_numberlist, true), ';');
$cardIds = explode(';', $cardsArg);
$this->game->selectCardsToGiveBack(array_map(fn ($id) => (int) $id, $cardIds));
self::ajaxResponse();
}
}