-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathupdate.php
executable file
·73 lines (63 loc) · 1.7 KB
/
update.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
<?php
require_once('resources/php/uno.class.php');
$updateId = isset($_GET['updateId']) ? $_GET['updateId'] : null;
if(Uno::getUpdateIdForGame(Uno::getStartedGameId()) == $updateId){
$return = array(
'update'=>false
);
if(isset($error)){
$return['error'] = $error;
}
echo JSON_Encode($return);
}
else {
$game = Uno::getStartedGame();
$return = array(
'update' => true,
'updateId' => Uno::getUpdateIdForGame(Uno::getStartedGameId()),
'html' => array(
'front' => '',
'playerCards' => '',
'players' => ''
)
);
if(isset($error)){
$return['error'] = $error;
}
/*foreach($game->getPlayers() as $player){
$return['players'][$player->getId()] = array(
'cardCount' => $player->getDeck()->getCount()
);
}*/
/*foreach($game->getPlayer(Uno::getStartedGamePlayerId())->getDeck()->getCards() as $card){
$return['playerCards'][] = array(
'label' => $card->getLabel(),
'color' => $card->getColor(),
'isWild' => $card->getIsWild()
);
}*/
/*foreach($game->getFront()->getCards() as $card){
$return['front'][] = array(
'label' => $card->getLabel(),
'color' => $card->getColor(),
'isWild' => $card->getIsWild()
);
}*/
ob_start();
$cards = $game->getFront()->getCards();
include('resources/templates/front.php');
$html = ob_get_clean();
$return['html']['front'] = $html;
ob_start();
$cards = $game->getPlayer(Uno::getStartedGamePlayerId())->getDeck()->getCards();
include('resources/templates/cards.php');
$html = ob_get_clean();
$return['html']['playerCards'] = $html;
ob_start();
$players = $game->getPlayers();
include('resources/templates/players.php');
$html = ob_get_clean();
$return['html']['players'] = $html;
echo JSON_Encode($return);
}
?>