-
Notifications
You must be signed in to change notification settings - Fork 0
/
kingdombuilder.view.php
67 lines (61 loc) · 2.19 KB
/
kingdombuilder.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
<?php
/**
*------
* BGA framework: © Gregory Isabelli <gisabelli@boardgamearena.com> & Emmanuel Colin <ecolin@boardgamearena.com>
* KingdomBuilder implementation : © Timothée Pecatte tim.pecatte@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.
* -----
*
* KingdomBuilder.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 KingdomBuilder_KingdomBuilder.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_kingdombuilder_kingdombuilder extends game_view
{
function getGameName()
{
return 'kingdombuilder';
}
function build_page($viewArgs)
{
// Get players & players number
$players = $this->game->loadPlayersBasicInfos();
$players_nbr = count($players);
$quadrants = $this->game->board->getQuadrants();
$n = count(KingdomBuilderBoard::$boards);
for ($i = 0; $i < 4; $i++) {
$flipped = false;
$k = $quadrants[$i];
// TODO : remove
if ($k >= 8 || $k >= 100) {
$flipped = true;
$k -= $k >= 100 ? 100 : 8;
}
$this->tpl['QUAD' . $i] = $k . ($flipped ? ' flipped' : '');
}
// Create the board
$this->page->begin_block('kingdombuilder_kingdombuilder', 'cell');
for ($i = 0; $i < 20; $i++) {
for ($j = 0; $j < 20; $j++) {
$this->page->insert_block('cell', [
'I' => $i,
'J' => $j,
]);
}
}
}
}