diff options
author | Snap <snapwilliam@gmail.com> | 2015-05-01 16:26:15 -0700 |
---|---|---|
committer | Snap <snapwilliam@gmail.com> | 2015-05-01 16:26:15 -0700 |
commit | 01cb30b61739780e680b501e7719fb23749ecaeb (patch) | |
tree | 714598bf80266232290c2591225f72b4f6a1042c /pages | |
parent | e6b60448bc08df316daf220db8ecfddc58aefe84 (diff) | |
download | pathery-01cb30b61739780e680b501e7719fb23749ecaeb.tar.xz |
Versus Matches - Initial code and testing.
Diffstat (limited to 'pages')
-rw-r--r-- | pages/creategame.php (renamed from pages/gamecreate.php) | 21 | ||||
-rw-r--r-- | pages/games.php | 142 |
2 files changed, 159 insertions, 4 deletions
diff --git a/pages/gamecreate.php b/pages/creategame.php index 44fe2d1..ee8af67 100644 --- a/pages/gamecreate.php +++ b/pages/creategame.php @@ -1,14 +1,28 @@ <?php
+//If thar be a game to be creatin
+if (isset($_POST['playerCount'])) {
+
+ //Confirm yarn data and fill them be databases. Hah har!
+
+
+
+ $gameID = 22;
+
+ //Return tiz be the gameID and change yarn header location! to games?id=ID
+ header("Location: $mydomain"."games?ID=" . $gameID);
+}
+
+htmlHeader(array(), 'Create Game', 'Create a game');
topbar($headerLinks);
-
?>
<div class="wrapper" style="width:600px;">
<h2>Create Game</h2>
-<h3>Send us a line!</h3>
<p>
+
+Doesn't matter what you do - you'll go to games?ID=22 ! (Testing still; sorry)
</p>
<form action="createGame" method="post" name="gameOptions">
@@ -18,11 +32,10 @@ topbar($headerLinks); <option value='3'>3</option>
<option value='4'>4</option>
<option value='5'>5</option>
- <option value='6'>6</option>
+
</select>
<br /><br />
-<textarea name='body' rows="10" cols="30"></textarea><br />
<input type="checkbox" name="smartTime" value="yes" /> Use Smart-Time? *
<br /><br />
<input type="submit" value="Create Game" />
diff --git a/pages/games.php b/pages/games.php new file mode 100644 index 0000000..bee6cd3 --- /dev/null +++ b/pages/games.php @@ -0,0 +1,142 @@ +<?php
+htmlHeader(
+ array('stats'), 'Game Lobby',
+ 'Match',
+ array('scores', 'dateformat')
+);
+
+htmlHeader(array(), 'Game Lobby', 'Game Lobby');
+echo soundManager2();
+topbar($headerLinks);
+
+?>
+
+
+<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 = '&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 (isInt(json.mapID) && matchMapReceived == false) {
+ displayMap(json.mapID, "mapDisplay", 600);
+ matchMapReceived = true;
+ }
+
+ //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 |