jhylands

123

Apr 7th, 2013
99
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. } 
  98. function play(gamid){
  99. loading();
  100. gameid = gamid;
  101. //check weather it is this users go or not
  102.     var xmlhttp;
  103.     if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
  104.     xmlhttp=new XMLHttpRequest();
  105.     }
  106.     else{// code for IE6, IE5
  107.         xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  108.     }
  109.     xmlhttp.onreadystatechange=function(){
  110.     if (xmlhttp.readyState==4 && xmlhttp.status==200){
  111.     var response=xmlhttp.responseText;
  112.         if(response.substring(0,1) == "1"){
  113.            //its the users go
  114.            isgo(gamid);
  115.         }
  116.         else{
  117.            //its not the users go
  118.            isngo(gamid);
  119.         }
  120.        
  121.     }
  122.     }
  123.     xmlhttp.open("GET","isgo.php?gid=" + gamid + "&id=" + id0,true);
  124.     xmlhttp.send();
  125. }
  126. function sub(){
  127.         //The request takes time, tell the user this
  128.         document.getElementById("the").innerHTML= "<h1>Creating your game, please wait...</h1>";
  129.    //build request
  130.     var reques = "creategame.php" + "?p6=" + id0;
  131.         var n = 0;
  132.     for(i=0;i<6;i++){
  133.         if (Players[i] != null){
  134.         reques = reques + "&p" + i + "=" + Players[i];
  135.         }
  136.         else
  137.         {
  138.                 n++;
  139.         }
  140.     }
  141.         if(n>5){
  142.                 alert('Hay, no players selected!');
  143.         }
  144.         else{
  145.     //send request
  146.     var xmlhttp;
  147.     if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
  148.     xmlhttp=new XMLHttpRequest();
  149.     }
  150.     else{// code for IE6, IE5
  151.         xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  152.     }
  153.     xmlhttp.onreadystatechange=function(){
  154.     if (xmlhttp.readyState==4 && xmlhttp.status==200){
  155.     document.getElementById("the").innerHTML=xmlhttp.responseText;
  156.           
  157.     }
  158.     }
  159.     xmlhttp.open("GET",reques,true);
  160.     xmlhttp.send();
  161.        }
  162. }
  163. function senddata(dieval){
  164. dieval = dieval.substring(1,10);
  165. //id#game id, id1#playerid, prop1#properistion
  166. var req = "noti.php?id=" + gameid + "&id1=" + id0 + "&prop1=" + dieval;
  167. //alert(req);
  168. //loading();
  169.                         var xmlhttp;
  170.                         if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
  171.                             xmlhttp=new XMLHttpRequest();
  172.                         }
  173.                         else{// code for IE6, IE5
  174.                             xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  175.                         }
  176.                             xmlhttp.onreadystatechange=function(){
  177.                             if (xmlhttp.readyState==4 && xmlhttp.status==200){
  178.                                                                 var resp = xmlhttp.responseText;
  179.                                 moveme(gameid,id0,dieval);
  180.                                                         }
  181.                         }
  182.                         xmlhttp.open("GET",req ,true);
  183.                         xmlhttp.send();
  184.  
  185. }
  186. function End(){
  187. if(rolled){
  188. nextgo(gameid);
  189. alert('Go ended!');
  190. play(gameid);
  191. }else
  192. {
  193. alert('You must roll before ending your turn');
  194. }
  195. }
  196. function checkend(){
  197. if (gameid!=0){
  198. //check weather it is this users go or not
  199.     var xmlhttp;
  200.     if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
  201.     xmlhttp=new XMLHttpRequest();
  202.     }
  203.     else{// code for IE6, IE5
  204.         xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  205.     }
  206.     xmlhttp.onreadystatechange=function(){
  207.     if (xmlhttp.readyState==4 && xmlhttp.status==200){
  208.     var response=xmlhttp.responseText;
  209.         if(response.substring(0,1) == "1"){
  210.            //its the users go
  211.            End();
  212.         }        
  213.     }
  214.     }
  215.     xmlhttp.open("GET","isgo.php?gid=" + gamid + "&id=" + id0,true);
  216.     xmlhttp.send();
  217. } 
  218. }
  219. </script>
  220. </head>
  221. <body onload="loadMain();">
  222.  
  223. <table border="1" class="a1" style=""><tr>
  224. <?php
  225. //Draw the map
  226. // Create connection to database
  227. include 'scripts/sql.php';
  228. //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)
  229. $i=0
  230. //SQL Table Property
  231. $result = mysqli_query($con,"SELECT * FROM Property");
  232. while($row = mysqli_fetch_array($result))
  233.   {
  234.     if($i=11 or $i=13){
  235.         //before the 12th,13th: </tr><tr>
  236.         echo "</tr><tr>";
  237.     }
  238.     if($i == 12){
  239.         //if middle needs putting in
  240.         echo '<td id="the" colspan="9" rowspan="9">';
  241.         echo '<h1>Loading please wait...</h1>';
  242.         echo '</td>';
  243.     }
  244.     if($i % 2 == 1 and $i<28 and $i>13){
  245.         //even i in main body
  246.         echo "</tr><tr>";
  247.     }
  248.    
  249.     //Draw this [sql] row's property
  250.     if($row['Band']==null){
  251.         //not a banded place
  252.         echo '<td class="property">' . $row['name'] . "</td>";
  253.     }elseif($row['Band']=="Train" OR $row['Band']=="Utility"){
  254.         //Train or utility
  255.         //show the ablilty to show deed but not the colored band
  256.         echo '<td class="property" onclick="loadDeed(' . "'" . $row['id'] . "'" . ')">';
  257.         echo $row['name'] . "</td>";
  258.     }else{
  259.         //property with band
  260.         echo '<td class="property" ><table class="property"><tr>';
  261.         echo '<td id="' . $row['Band'] . '"</td></tr>';
  262.         echo '<tr><td onclick="loadDeed(' . "'" . $row['id'] . "'" . ')">';
  263.         echo $row['name'] . '</td></tr></table></td>';
  264.     }
  265.     //increase the counter
  266.     $i++;
  267.   }
  268. //close connection to db
  269. mysqli_close($con);
  270. ?>
  271. </tr></table>
  272.  
  273. </body>
Advertisement
Add Comment
Please, Sign In to add comment