jhylands

land.php

Jun 27th, 2013
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.60 KB | None | 0 0
  1. <?php
  2. //what to do when they have landed $_GET['gid'] $_GET['uid']
  3. /*
  4. =========================Key=============================
  5. Key for what to return and when                         |
  6. --------------------------------------------------------
  7. |TAX        |For a tax that has been levied             |
  8. |GO         |For passing go                             |
  9. |Free       |For an empty square such as jail           |
  10. |Chance     |Landed on a chance                         |
  11. |Chest      |Landed on a comunity chest sqr             |
  12. |Jailed     |Landed on goto jail                        |
  13. |Mortgaged  |The property is owned but under mortgage   |
  14. |Rent#n     |Where n is the build status of the property|
  15. |fair       |The property is not yet owned              |
  16. ---------------------------------------------------------
  17. =========================================================
  18. */
  19. // Create connection to database
  20. include 'sql.php';
  21. //get users position and other items from the X table
  22. $qur = "SELECT * FROM x" . $_GET['gid'] . " WHERE id = " . $_GET['uid'];
  23. $result = mysqli_query($con,$qur);
  24. while($row = mysqli_fetch_array($result))
  25.   {
  26.     $position = $row['Position'];
  27.     $Money = $row['Money'];
  28.     $Liberty = $row['Liberty'];
  29.     $Property = $row['Property'];
  30.   }
  31. if($Liberty = 1){
  32. //get property information
  33. $qur = "SELECT * FROM Properties WHERE ID=" . $position;
  34. $result = mysqli_query($con,"SELECT * FROM Properties WHERE ID=" . $position);
  35. while($row = mysqli_fetch_array($result))
  36.   {
  37.     //take all the data from the server
  38.     $prop = $row;
  39. echo $row['ID'];
  40.   }
  41. echo $prop['ID'];
  42. //check what type of property it is
  43. if($Prop['Band']=null){
  44. //its not a property
  45. switch($Prop['Name']){
  46. case "Chance":
  47.     //chance card
  48.     break;
  49. case "Chest":
  50.     //comunity chest
  51.     break;
  52. case "Go":
  53.     //passing go
  54.     echo "GO";
  55.     UpMoney($Money + 200);
  56.     break;
  57. case "Income tax":
  58.     //tax $200
  59.     echo "TAX";
  60.     UpMoney($Money - 200);
  61.     break;
  62. case "GOTO Jail":
  63.     //Liberty is removed
  64.     echo "Jailed";
  65.     mysqli_query($con,"UPDATE x" . $_GET['gid'] . " SET Liberty=0 WHERE id='" . $_GET['uid'] . "'");
  66.     mysqli_query($con,"UPDATE x" . $_GET['gid'] . " SET Position=10 WHERE id='" . $_GET['uid'] . "'");
  67.     break;
  68. case "Super tax":
  69.     //taxed $100
  70.     echo "TAX";
  71.     UpMoney($Money - 100);
  72.     break;
  73. default:
  74. //free parking or visiting jail
  75. echo "Free";
  76. }
  77. }else{
  78. //its a property
  79. //have a variable to look if its owned
  80. $owned = false;
  81. //look to see if the property is owned by someone
  82. $result = mysqli_query($con,"SELECT * FROM x" . $_GET['gid']);
  83. //WARNING!!! Script allows for money to go negative!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  84. while($row = mysqli_fetch_array($result))
  85.   {
  86.     //stop the program looking at the current users file
  87.     if($row['id']!=$_GET['uid']){
  88.     //if the property is not owned
  89.     if(substr($row['Property'],$position,1)!=0){
  90.     $owned=true;
  91.     switch(substr($row['Property'],$position,1)){
  92.     case 1:
  93.         //morgaged
  94.         echo "Mortgaged";
  95.         break;
  96.     case 2:
  97.         //owned - basic rent
  98.         echo "Rent#" . $prop['Rent0'];
  99.         UpMoney($Money - $prop['Rent0']);
  100.         mysqli_query($con,"UPDATE x" . $_GET['gid'] . " SET Money=" . ($row['Money'] + $prop['Rent0'])  . " WHERE id='" . $row['id'] . "'");
  101.         break;
  102.     case 3:
  103.         //1 house
  104.         echo "Rent#" . $prop['Rent1'];
  105.         UpMoney($Money - $prop['Rent1']);
  106.         mysqli_query($con,"UPDATE x" . $_GET['gid'] . " SET Money=" . ($row['Money'] + $prop['Rent1'])  . " WHERE id='" . $row['id'] . "'");
  107.         break;
  108.     case 4:
  109.         //2 houses
  110.         echo "Rent#" . $prop['Rent2'];
  111.         UpMoney($Money - $prop['Rent2']);
  112.         mysqli_query($con,"UPDATE x" . $_GET['gid'] . " SET Money=" . ($row['Money'] + $prop['Rent2'])  . " WHERE id='" . $row['id'] . "'");
  113.         break;
  114.     case 5:
  115.         //3 houses
  116.         echo "Rent#" . $prop['Rent3'];
  117.         UpMoney($Money - $prop['Rent3']);
  118.         mysqli_query($con,"UPDATE x" . $_GET['gid'] . " SET Money=" . ($row['Money'] + $prop['Rent3'])  . " WHERE id='" . $row['id'] . "'");
  119.         break;
  120.     case 6:
  121.         //4 houses
  122.         echo "Rent#" . $prop['Rent4'];
  123.         UpMoney($Money - $prop['Rent4']);
  124.         mysqli_query($con,"UPDATE x" . $_GET['gid'] . " SET Money=" . ($row['Money'] + $prop['Rent4'])  . " WHERE id='" . $row['id'] . "'");
  125.         break;
  126.     case 7:
  127.         //A hotel
  128.         echo "Rent#" . $prop['RentH'];
  129.         UpMoney($Money - $prop['RentH']);
  130.         mysqli_query($con,"UPDATE x" . $_GET['gid'] . " SET Money=" . ($row['Money'] + $prop['RentH'])  . " WHERE id='" . $row['id'] . "'");
  131.         break;
  132.     default:
  133.         //error
  134.     }
  135.   }else{
  136.     //not owned by this person
  137.   }
  138. }
  139. }
  140. if($owned=false){
  141. //the property is fair game to be purchased
  142. echo "fair";
  143. }
  144. }
  145. }else{
  146. //in jail
  147. echo "In Jail";
  148. }
  149. ?>
  150. <?php
  151. function UpMoney($newamount){
  152. include 'sql.php';
  153. mysqli_query($con,"UPDATE x" . $_GET['gid'] . " SET Money=" . $newamount . " WHERE id='" . $_GET['uid'] . "'");
  154. }
  155. ?>
Advertisement
Add Comment
Please, Sign In to add comment