-
Notifications
You must be signed in to change notification settings - Fork 6
/
fixedGameMenu.php
151 lines (148 loc) · 5.49 KB
/
fixedGameMenu.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
<?php
if (($gameID || ($pathAction == 'characters' && $pathOptions[0] != 'my')) && !isset($_GET['modal'])) {
?>
<div id="fixedMenu"><div id="fixedMenu_window">
<?php
$gameID = (int) $gameID;
$isUserGM = false;
if ($gameID) {
$game = $mysql->query("SELECT games.gmID, systems.name AS `system`, games.forumID, games.public, games.gameOptions FROM games INNER JOIN systems ON games.system = systems.id WHERE games.gameID = {$gameID}")->fetch();
$players = $mysql->query("SELECT users.userID, users.username, players.approved, players.isGM FROM players INNER JOIN users ON players.userID = users.userID WHERE players.gameID = {$gameID}");
$isGM = $game && $game['gmID'] == $currentUser->userID ? true : false;
?>
<ul style="display:none" id="playerList">
<?php
$approvedPlayer = false;
if ($players->rowCount()) {
foreach ($players->fetchAll() as $player) {
if ($player['userID'] == $currentUser->userID && $player['approved']) {
$approvedPlayer = true;
}
if ($player['isGM'] && $player['userID'] == $currentUser->userID) {
$isUserGM = true;
}
if ($player['approved']) {
?>
<li><?= $player['username']?></li>
<?php
}
}
}
?>
<script type="application/json" id="gameOptions">
<?= $game["gameOptions"] ?>
</script>
</ul>
<ul class="rightCol">
<li><a href="/games/<?=$gameID?>" class="menuLink">Game Details</a></li>
</ul>
<?php
}
?>
<ul class="leftCol">
<?php
if ($isGM || $pathAction == 'characters') {
?>
<li id="fm_tools" class="mob-hide">
<a href="/tools" class="menuLink">Tools</a>
<ul class="submenu" data-menu-group="tools">
<li id="fm_diceRoller">
<a href="/tools/dice" class="menuLink">Dice Roller</a>
<div class="subwindow">
<div class="floatLeft">
<div id="fm_customDiceRoll">
<input type="text"><button id="fm_roll">Roll</button>
</div>
<div><button name="d4" class="diceBtn">d4</button></div>
<div><button name="d6" class="diceBtn">d6</button></div>
<div><button name="d8" class="diceBtn">d8</button></div>
<div><button name="d10" class="diceBtn">d10</button></div>
<div><button name="d12" class="diceBtn">d12</button></div>
<div><button name="d20" class="diceBtn">d20</button></div>
<div><button name="d100" class="diceBtn">d100</button></div>
</div>
<div class="floatRight"></div>
</div>
</li>
<?php
if ($isGM || $pathAction == 'characters') {
?>
<li id="fm_cards">
<a href="/tools/cards" class="menuLink">Cards</a>
<div class="subwindow">
<?php $cardCount = isset($_SESSION['deck']) && count($_SESSION['deck']) ? array_count_values($_SESSION['deck']) : [0, 0]; ?>
<div class="cardControls">
<p class="deckName"><?=$_SESSION['deckName']?></p>
<p>Cards Left: <span class="cardsLeft"><?=$cardCount[1]?></span></p>
<div>Draw <input type="text" name="numCards" maxlength="2" value="<?=!isset($cardsDrawn) ? '' : (sizeof($cardsDrawn) > $cardCount[0] ? $cardCount[0] : sizeof($cardsDrawn))?>" autocomplete="off" class="numCards alignCenter"> Cards</div>
<button type="submit" name="drawCards" class="drawCards">Draw Cards</button>
<a href="?newDeck=1" class="newDeckLink button">New Deck</a>
</div>
<div id="fm_dispArea">
<div class="newDeck<?=$cardCount[0] > 0 ? ' hideDiv' : ''?>">
<h3>New Deck</h3>
<div class="deckType"><a id="newDeck_pcwj" href="?newDeck=pcwj">Playing Cards w/ Jokers</a></div>
<div class="deckType last"><a id="newDeck_pcwoj" href="?newDeck=pcwoj">Playing Cards w/o Jokers</a></div>
</div>
<div class="cardSpace"><div>
</div></div>
<div class="alignCenter">
<a id="fm_upArrow" href="" class="arrow hideArrow"></a>
<a id="fm_downArrow" href="" class="arrow hideArrow"></a>
</div>
</div>
</div>
</li>
</ul>
</li>
<?php
}
}
?>
<?php
if ($gameID) {
$where = "characters.gameID = {$gameID} AND characters.approved = TRUE";
// if (!$isGM) {
// $where .= " AND characters.userID = {$currentUser->userID}";
// }
$characters = $mysql->query("SELECT characters.characterID, characters.`system`, characters.label, characters.name, users.userID, users.username FROM characters INNER JOIN users ON characters.userID = users.userID WHERE {$where} ORDER BY users.username");
if ($characters->rowCount() && $pathAction != 'characters') {
?>
<li id="fm_characters">
<a href="" class="menuLink">Characters</a>
<ul class="submenu<?=$isUserGM ? ' isGM' : ''?>" data-menu-group="characters">
<?php
$currentUserID = 0;
foreach ($characters->fetchAll() as $charInfo) {
if ($currentUserID != $charInfo['userID']) {
if ($currentUserID != 0) {
echo " </li>\n";
}
$currentUserID = $charInfo['userID'];
echo " <li".($currentUser->userID == $currentUserID?" class='thisUser'":"").">\n";
// if ($isGM) {
?>
<p class="username"><i class="ra ra-quill-ink"></i> <a href="/user/<?=$charInfo['userID']?>" class="username"><?=$charInfo['username']?></a></p>
<?php
// }
}
?>
<p class="charName"><i class="ra ra-quill-ink"></i> <a href="/characters/<?=$charInfo['system']?>/<?=$charInfo['characterID']?>/" class="charid-<?=$charInfo['characterID']?>"><?=$charInfo['name']?></a></p>
<?php } ?>
</li>
</ul>
</li>
<?php
}
if ($pathAction != 'forums' && ($approvedPlayer || $game['public'])) {
?>
<li><a href="/forums/<?=$game['forumID']?>/" class="menuLink">Forum</a></li>
<?php
}
?>
</ul>
<?php
}
}
?>
</div></div>