-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdontgointhere.view.php
146 lines (132 loc) · 4.28 KB
/
dontgointhere.view.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
<?php
/**
*------
* BGA framework: © Gregory Isabelli <[email protected]> & Emmanuel Colin <[email protected]>
* DontGoInThere implementation : © Evan Pulgino <[email protected]>
*
* 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.
* -----
*
* dontgointhere.view.php
*
* This is your "view" file.
*
* The method "build_page" below is called each time the game interface is displayed to a player, ie:
* _ when the game starts
* _ when a player refreshes the game page (F5)
*
* "build_page" method allows you to dynamically modify the HTML generated for the game interface. In
* particular, you can set here the values of variables elements defined in dontgointhere_dontgointhere.tpl (elements
* like {MY_VARIABLE_ELEMENT}), and insert HTML block elements (also defined in your HTML template file)
*
* Note: if the HTML of your game interface is always the same, you don't have to place anything here.
*
*/
require_once( APP_BASE_PATH."view/common/game.view.php" );
class view_dontgointhere_dontgointhere extends game_view
{
function getGameName() {
return "dontgointhere";
}
function build_page( $viewArgs )
{
// Template name
$template = self::getGameName().'_'.self::getGameName();
// Inflate players
$players = $this->game->playerManager->getPlayersInViewOrder();
$this->page->begin_block($template, 'playerscorerow');
$this->page->begin_block($template, 'playercardtype');
$this->page->begin_block($template, 'playerarea');
foreach($players as $playerKey => $player)
{
$this->page->reset_subblocks('playercardtype');
$this->page->insert_block(
'playerscorerow',
array(
'PLAYER_ID' => $player->getId(),
'PLAYER_NAME' => $player->getName(),
'PLAYER_COLOR' => $player->getColor(),
'PLAYER_GHOSTS' => $player->getGhostTokens(),
'PLAYER_CURSES' => $player->getCurses(),
'PLAYER_NATURAL_ORDER' => $player->getNaturalOrder(),
)
);
for ($cardType = AMULET; $cardType <= TWIN; $cardType++)
{
$this->page->insert_block(
'playercardtype',
array(
'PLAYER_ID' => $player->getId(),
'CARD_TYPE' => $cardType,
)
);
}
$this->page->insert_block(
'playerarea',
array(
'PLAYER_ID' => $player->getId(),
'PLAYER_NAME' => $player->getName(),
'PLAYER_COLOR' => $player->getColor(),
'PLAYER_NATURAL_ORDER' => $player->getNaturalOrder(),
)
);
}
// Inflate a pile of ghosts
$this->page->begin_block($template, 'ghost');
for($ghostNumber = 1; $ghostNumber <= 24; $ghostNumber++)
{
$this->page->insert_block(
'ghost',
array(
'GHOST_NUM' => $ghostNumber,
'GHOST_TYPE' => ceil($ghostNumber / 2),
'DELAY' => ($ghostNumber - 1) * 100,
'X_TIME' => bga_rand(10, 20),
'Y_TIME' => bga_rand(10, 20),
'SPIN_TIME' => bga_rand(10, 20),
'Z_INDEX' => bga_rand(1, 70),
)
);
}
// Inflate dice
$this->page->begin_block($template, 'die');
for ($dieNumber = 1; $dieNumber <= 6; $dieNumber++)
{
$this->page->insert_block(
'die',
array(
'DIE_NUM' => $dieNumber,
)
);
}
// Inflate rooms
$this->page->begin_block($template, 'roomspace');
$this->page->begin_block($template, 'room');
for($roomNumber = 1; $roomNumber <= 3; $roomNumber++)
{
$this->page->reset_subblocks('roomspace');
for ($spaceNumber = 1; $spaceNumber <= 4; $spaceNumber++)
{
$this->page->insert_block(
'roomspace',
array(
'ROOM_NUM' => $roomNumber,
'SPACE_NUM' => $spaceNumber,
)
);
}
$this->page->insert_block(
'room',
array(
'ROOM_NUM' => $roomNumber,
)
);
}
// Populate variables
$this->tpl['CHANGE'] = self::_("Change");
$this->tpl['DISPEL'] = self::_("Dispel");
$this->tpl['ROLL'] = self::_("Roll");
/*********** Do not change anything below this line ************/
}
}