diff options
Diffstat (limited to 'pages/games.php')
-rw-r--r-- | pages/games.php | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/pages/games.php b/pages/games.php new file mode 100644 index 0000000..b68a530 --- /dev/null +++ b/pages/games.php @@ -0,0 +1,151 @@ +<?php
+htmlHeader(
+ array('stats'), 'Game Lobby',
+ 'Match',
+ array('scores', 'dateformat')
+);
+
+htmlHeader(array(), 'Game Lobby', 'Game Lobby');
+echo soundManager2();
+topbar($headerLinks);
+
+
+if (is_int($_GET['ID'])) {
+ $matchID = $_GET['ID'];
+}
+
+
+?>
+
+
+<script>
+
+mapID = 222;
+pointerPage = 1;
+
+displayMap(mapID, "mapDisplay", 600);
+scoresShowPage(pointerPage, mapID);
+
+
+var matchUpdateTimerDelay = 6000;
+
+
+var playerIsReady = false;
+var matchMapReceived = false;
+var matchCountdownStarted = false;
+var matchStarted = false;
+
+matchUpdateTimer();
+function matchUpdateTimer() {
+ setTimeout("matchUpdateTimer()", matchUpdateTimerDelay);
+
+}
+
+function pollMatchStatus() {
+ var dataString = 'requestUpdate=1';
+ dataString += '&matchID=<? echo $matchID; ?>';
+ dataString += '&playerIsReady='+playerIsReady;
+
+ $.ajax({
+ //type: "POST",
+ url: "ajax/match.ajax.php?" + dataString,
+ error: function() {
+ console.log('Error: Failed pollMatchStatus');
+ },
+ success: function(data) {
+ console.log("Data recieved", data);
+ pollMatchStatusDone(data);
+ }
+ });
+}
+
+function pollMatchStatusDone(data) {
+
+ console.log('data recieved:', data);
+ if (data.length < 3 || data == 'false') return;
+ json = jQuery.parseJSON(data);
+
+ if (json.gameStarted == true) {
+ // Show the game if it's ready
+ if (json.mapReady == true && matchMapReceived == false) {
+ console.log("match countdown start!");
+ displayMap(json.mapID, "mapDisplay", 600);
+ matchMapReceived = true;
+
+ displayCountDownToGame(json.secondsTillGameExpires);
+
+ }
+
+ //This will be a negative number if the game is going.
+ if (json.secondsTillGameStarts > 0 && matchCountdownStarted == false) {
+ displayCountDownToGame(json.secondsTillGameStarts);
+
+ //Make sure we're making a call when the map is ready.
+ setTimeout("pollMatchStatus()", ((json.secondsTillGameStarts) * 1000) - 10);
+ matchCountdownStarted = true;
+ }
+
+ // json.secondsTillGameStarts
+ // var gameStartsDate = new Date();
+ //gameStartsDate.setTime(gameStartsDate.getTime() + json.secondsTillGameStarts * 1000);
+ }
+
+}
+
+function isInt(n) {
+ return n % 1 === 0;
+}
+
+
+function displayCountDownToGame(seconds) {
+ decSeconds = Math.round(seconds * 10);
+ var x = 0;
+ for (var i = decSeconds; i > 0; i--) {
+ x++;
+ setTimeout("setDisplay(" + i / 10 + ")", x * 100);
+ }
+}
+function setDisplay(newContent) {
+ $("#countDown").html(newContent);
+}
+
+function setReady() {
+ playerIsReady = true;
+ pollMatchStatus();
+}
+
+</script>
+
+
+<div class="wrapper">
+
+<br />
+<br /><h2>Game Lobby</h2>
+<br /><h2 id='countDown'>X</h2>
+<br />
+ <div>
+ <div class='scoreCol' id='scoreDisplay'></div>
+ <div class="mapCol" id='mapDisplay' style='display:none; float:left;'></div>
+ </div>
+
+ <div style='clear:both'></div>
+</div>
+
+
+<div class="wrapper">
+ <form id='markReady' onsubmit="return false">
+ <input type="hidden" name="stuff" value="1724">
+
+ <?
+ echo "
+ <a title='TmpBtn?' class='readyButton_unready unselectable' href='javascript:setReady()' id='readyButton'/>BTN!</a>";
+ ?>
+ </form>
+</div>
+
+
+
+
+<?php
+htmlFooter();
+?>
\ No newline at end of file |