jhylands

123

Apr 7th, 2013
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.48 KB | None | 0 0
  1. <?php
  2. include 'scripts/fblog.php';
  3. // Create connection to database
  4. include 'scripts/sql.php';
  5. //SQL Table Persons - PID key, Firstname, Lastname,Gender
  6. $result = mysqli_query($con,"SELECT PID FROM Persons WHERE PID='" . $user_profile['id'] . "'");
  7. $Signedup = "";
  8. while($row = mysqli_fetch_array($result))
  9.   {
  10.   $signedup = $row['PID'];
  11.   }
  12. if ($signedup == "")
  13.   {
  14.   echo "<script> window.location = 'http://calander.site90.net/monopoly/signup.php' </script>";
  15.   }
  16. //close connection to db
  17. mysqli_close($con);
  18. ?>
  19. <head>
  20. <link rel="stylesheet" type="text/css" href="style.css">
  21. <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
  22. <script src="scripts/deed.js"></script>
  23. <script src="scripts/create.js"></script>
  24. <script src="scripts/play.js"></script>
  25. <script>
  26. var Vdeed = true;
  27. function loadMain(){
  28.                         if(Vdeed){
  29.             if(gameid==0){
  30.                         loading();
  31.                         var xmlhttp;
  32.                         if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
  33.                             xmlhttp=new XMLHttpRequest();
  34.                         }
  35.                         else{// code for IE6, IE5
  36.                             xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  37.                         }
  38.                             xmlhttp.onreadystatechange=function(){
  39.                             if (xmlhttp.readyState==4 && xmlhttp.status==200){
  40.                                 document.getElementById("the").innerHTML=xmlhttp.responseText;
  41.                                    
  42.                                                         }
  43.                         }
  44.                         xmlhttp.open("GET","main.php?id=" + <?php echo $user_profile['id']; ?> ,true);
  45.                         xmlhttp.send();  
  46.                         }else{
  47.                         play(gameid);
  48.                         }
  49. }}
  50.  
  51. function AllowDeed(){
  52. Vdeed =true;
  53. }
  54. var Players = new Array();
  55. function loading(){
  56. document.getElementById("the").innerHTML="<h1>Loading stuff...</h1>";
  57. }
  58.  
  59. var id0 = <?php echo $user_profile['id']; ?>;
  60. var gameid = 0;
  61. //is it this users go?
  62. function isgo(gamid){
  63.     //send request
  64.         var xmlhttp;
  65.     if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
  66.     xmlhttp=new XMLHttpRequest();
  67.     }
  68.     else{// code for IE6, IE5
  69.         xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  70.     }
  71.     xmlhttp.onreadystatechange=function(){
  72.     if (xmlhttp.readyState==4 && xmlhttp.status==200){
  73.     document.getElementById("the").innerHTML=xmlhttp.responseText;
  74.           
  75.     }
  76.     }
  77.     xmlhttp.open("GET","game.php?gid=" + gamid + "&id=" + id0,true);
  78.     xmlhttp.send();
  79. }  
  80. function isngo(gamid){
  81.     //send request
  82.         var xmlhttp;
  83.     if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
  84.     xmlhttp=new XMLHttpRequest();
  85.     }
  86.     else{// code for IE6, IE5
  87.         xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  88.     }
  89.     xmlhttp.onreadystatechange=function(){
  90.     if (xmlhttp.readyState==4 && xmlhttp.status==200){
  91.     document.getElementById("the").innerHTML=xmlhttp.responseText;
  92.           
  93.     }
  94.     }
  95.     xmlhttp.open("GET","ogame.php?gid=" + gamid + "&id=" + id0,true);
  96.     xmlhttp.send();
  97. function play(gamid){
  98. loading();
  99. gameid = gamid;
  100. //check weather it is this users go or not
  101.     var xmlhttp;
  102.     if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
  103.     xmlhttp=new XMLHttpRequest();
  104.     }
  105.     else{// code for IE6, IE5
  106.         xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  107.     }
  108.     xmlhttp.onreadystatechange=function(){
  109.     if (xmlhttp.readyState==4 && xmlhttp.status==200){
  110.     var response=xmlhttp.responseText;
  111.         if(response.substring(0,1) == "1"){
  112.            //its the users go
  113.            isgo(gamid);
  114.         }
  115.         else{
  116.            //its not the users go
  117.            isngo(gamid);
  118.         }
  119.        
  120.     }
  121.     }
  122.     xmlhttp.open("GET","isgo.php?gid=" + gamid + "&id=" + id0,true);
  123.     xmlhttp.send();
  124. }
  125. function sub(){
  126.         //The request takes time, tell the user this
  127.         document.getElementById("the").innerHTML= "<h1>Creating your game, please wait...</h1>";
  128.    //build request
  129.     var reques = "creategame.php" + "?p6=" + id0;
  130.         var n = 0;
  131.     for(i=0;i<6;i++){
  132.         if (Players[i] != null){
  133.         reques = reques + "&p" + i + "=" + Players[i];
  134.         }
  135.         else
  136.         {
  137.                 n++;
  138.         }
  139.     }
  140.         if(n>5){
  141.                 alert('Hay, no players selected!');
  142.         }
  143.         else{
  144.     //send request
  145.     var xmlhttp;
  146.     if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
  147.     xmlhttp=new XMLHttpRequest();
  148.     }
  149.     else{// code for IE6, IE5
  150.         xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  151.     }
  152.     xmlhttp.onreadystatechange=function(){
  153.     if (xmlhttp.readyState==4 && xmlhttp.status==200){
  154.     document.getElementById("the").innerHTML=xmlhttp.responseText;
  155.           
  156.     }
  157.     }
  158.     xmlhttp.open("GET",reques,true);
  159.     xmlhttp.send();
  160.        }
  161. }
  162. function senddata(dieval){
  163. dieval = dieval.substring(1,10);
  164. //id#game id, id1#playerid, prop1#properistion
  165. var req = "noti.php?id=" + gameid + "&id1=" + id0 + "&prop1=" + dieval;
  166. //alert(req);
  167. //loading();
  168.                         var xmlhttp;
  169.                         if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
  170.                             xmlhttp=new XMLHttpRequest();
  171.                         }
  172.                         else{// code for IE6, IE5
  173.                             xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  174.                         }
  175.                             xmlhttp.onreadystatechange=function(){
  176.                             if (xmlhttp.readyState==4 && xmlhttp.status==200){
  177.                                                                 var resp = xmlhttp.responseText;
  178.                                 moveme(gameid,id0,dieval);
  179.                                                         }
  180.                         }
  181.                         xmlhttp.open("GET",req ,true);
  182.                         xmlhttp.send();
  183.  
  184. }
  185. function End(){
  186. if(rolled){
  187. nextgo(gameid);
  188. alert('Go ended!');
  189. play(gameid);
  190. }else
  191. {
  192. alert('You must roll before ending your turn');
  193. }
  194. }
  195. function checkend(){
  196. if (gameid!=0){
  197. //check weather it is this users go or not
  198.     var xmlhttp;
  199.     if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
  200.     xmlhttp=new XMLHttpRequest();
  201.     }
  202.     else{// code for IE6, IE5
  203.         xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  204.     }
  205.     xmlhttp.onreadystatechange=function(){
  206.     if (xmlhttp.readyState==4 && xmlhttp.status==200){
  207.     var response=xmlhttp.responseText;
  208.         if(response.substring(0,1) == "1"){
  209.            //its the users go
  210.            End();
  211.         }        
  212.     }
  213.     }
  214.     xmlhttp.open("GET","isgo.php?gid=" + gamid + "&id=" + id0,true);
  215.     xmlhttp.send();
  216. }
  217. </script>
  218. </head>
  219. <body onload="loadMain();">
  220.  
  221. <table border="1" class="a1" style=""><tr>
  222. <?php
  223. //Draw the map
  224. // Create connection to database
  225. include 'scripts/sql.php';
  226. //use $i as a counter, for 0<$i<=10{first line} for 10<$i<=28{[($i-10)/2]th line} for 28<$i<38{10th line)
  227. $i=0
  228. //SQL Table Property
  229. $result = mysqli_query($con,"SELECT * FROM Property");
  230. while($row = mysqli_fetch_array($result))
  231.   {
  232.     if($i=11 or $i=13){
  233.         //before the 12th,13th: </tr><tr>
  234.         echo "</tr><tr>";
  235.     }
  236.     if($i == 12){
  237.         //if middle needs putting in
  238.         echo '<td id="the" colspan="9" rowspan="9">';
  239.         echo '<h1>Loading please wait...</h1>';
  240.         echo '</td>';
  241.     }
  242.     if($i % 2 == 1 and $i<28 and $i>13){
  243.         //even i in main body
  244.         echo "</tr><tr>";
  245.     }
  246.    
  247.     //Draw this [sql] row's property
  248.     if($row['Band']==null){
  249.         //not a banded place
  250.         echo '<td class="property">' . $row['name'] . "</td>";
  251.     }elseif($row['Band']=="Train" OR $row['Band']=="Utility"){
  252.         //Train or utility
  253.         //show the ablilty to show deed but not the colored band
  254.         echo '<td class="property" onclick="loadDeed(' . "'" . $row['id'] . "'" . ')">';
  255.         echo $row['name'] . "</td>";
  256.     }else{
  257.         //property with band
  258.         echo '<td class="property" ><table class="property"><tr>';
  259.         echo '<td id="' . $row['Band'] . '"</td></tr>';
  260.         echo '<tr><td onclick="loadDeed(' . "'" . $row['id'] . "'" . ')">';
  261.         echo $row['name'] . '</td></tr></table></td>';
  262.     }
  263.     //increase the counter
  264.     $i++;
  265.   }
  266. //close connection to db
  267. mysqli_close($con);
  268. ?>
  269. </tr></table>
  270.  
  271. </body>
Advertisement
Add Comment
Please, Sign In to add comment