Advertisement
Guest User

Untitled

a guest
Jul 12th, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.06 KB | None | 0 0
  1. <?php
  2. //cityfunctions
  3. $neededpower = 0;
  4. $poweredinfra = 0;
  5. $commerce = 0;
  6. $policedcrime = 0;
  7. $hospitaldisease = 0;
  8. $subwaycommerce = 0;
  9. $supermarketcommerce = 0;
  10. $bankcommerce = 0;
  11. $mallcommerce = 0;
  12. $stadiumcommerce = 0;
  13.  
  14.  if(!defined('NO_CITYFUNC_DUPES')) {
  15. $gamedatequery = $mysqli->query("SELECT value FROM gamestats WHERE valuetype='1'")->fetch_array(MYSQLI_ASSOC);
  16. $gamedate = date('Y-m-d', $gamedatequery['value']*100);
  17.  
  18. $cnidq = $mysqli->query("SELECT account_id, ecopolicy, continent, nation_name, money, coal, oil, uranium, itc FROM nations WHERE id='$cidfetch[nation_id]'");
  19. $cnidf = $cnidq->fetch_array(MYSQLI_ASSOC);
  20. } else {
  21. $cnidf = $nquery->fetch_array(MYSQLI_ASSOC);
  22. }
  23.  
  24. //calculate powered pollution
  25. $plantpollution = ($cidfetch['coalpower']*8)+($cidfetch['oilpower']*6);
  26. $civilpollution = ($cidfetch['policestation'])+($cidfetch['hospital']*4)+($cidfetch['subway']*-45)+($cidfetch['recyclingcenter']*-70);
  27. $manufpollution = ($cidfetch['steelmill']*20)+($cidfetch['gasrefinery']*16)+($cidfetch['aluminumrefinery']*20)+($cidfetch['munitionsfactory']*16);
  28. $commercepollution = ($cidfetch['mall']*2)+($cidfetch['stadium']*5);
  29.  
  30. //check power
  31. if($cidfetch['windpower'] > 0) { $poweredinfra = $cidfetch['windpower']*250; }
  32. $neededpower = $cidfetch['infrastructure']-$poweredinfra;
  33. if($neededpower > 0) { //check nuclear
  34. if($cidfetch['nuclearpower'] > 0 AND $cnidf['uranium'] > 0) {
  35. if($cidfetch['nuclearpower']*.2 < $cnidf['uranium']) { $poweredinfra += $cidfetch['nuclearpower']*2000; $uraniumused += min(ceil($neededpower/1000)*.1,$cidfetch['nuclearpower']*.2); } else { $poweredinfra += ($cnidf['uranium'])*10000; $uraniumused += $cnidf['uranium']; }
  36. } } $neededpower = $cidfetch['infrastructure']-$poweredinfra;
  37. if($neededpower > 0) { //check oil
  38. if($cidfetch['oilpower'] > 0 AND $cnidf['oil'] > 0) {
  39. if($cidfetch['oilpower']*.5 < ($cnidf['oil'])) { $poweredinfra += $cidfetch['oilpower']*500; $oilused += min((ceil($neededpower/100)*.1),($cidfetch['oilpower']*.5)); } else { $poweredinfra += $cnidf['oil']*1000; $oilused += ceil($neededpower/100)*.1; } } }
  40. $neededpower = $cidfetch['infrastructure']-$poweredinfra;
  41. if($neededpower > 0) { //check coal
  42. if($cidfetch['coalpower'] > 0 AND $cnidf['coal'] > 0) {
  43. if($cidfetch['coalpower']*.5 < ($cnidf['coal'])) { $poweredinfra += $cidfetch['coalpower']*500; $coalused += min(ceil($neededpower/100)*.1,($cidfetch['coalpower']*.5)); } else { $poweredinfra += $cnidf['coal']*1000; $coalused += ceil($neededpower/100)*.1; } } }
  44. $neededpower = $cidfetch['infrastructure']-$poweredinfra;
  45.  
  46. if($neededpower > 0) { $powered = "No"; $citypower = "No Power"; $plantpollution = 0; $commercepollution = 0; $civilpollution = 0; $manufpollution = 0; } else {
  47. $powered = "Yes";
  48. $policestations = $cidfetch['policestation'];
  49. $hospitals = $cidfetch['hospital'];
  50. $subway = $cidfetch['subway'];
  51. $supermarkets = $cidfetch['supermarket'];
  52. $banks = $cidfetch['bank'];
  53. $malls = $cidfetch['mall'];
  54. $stadiums = $cidfetch['stadium'];
  55. $citypower = "Powered";
  56.  
  57. $policedcrime = $policestations*2.5;
  58. $hospitaldisease = $hospitals*2.5;
  59. $subwaycommerce = ($subway*7);
  60. $supermarketcommerce = $supermarkets*4;
  61. $bankcommerce = $banks*7;
  62. $mallcommerce = $malls*12;
  63. $stadiumcommerce = $stadiums*18;
  64. }
  65.  
  66. //pollution
  67. $resourcepollution = ($cidfetch['farm'])+($cidfetch['uramine']*10)+($cidfetch['leadmine']*6)+($cidfetch['ironmine']*6)+($cidfetch['bauxitemine']*6)+($cidfetch['coalmine']*6)+($cidfetch['oilwell']*6);
  68. $citypollution = max($plantpollution+$commercepollution+$civilpollution+$manufpollution+$resourcepollution,0);
  69.  
  70. //check for nuclear pollution
  71. $nukedatediff =  strtotime($gamedate) - strtotime($cidfetch['nukedate']);
  72. $nukeage = floor($nukedatediff/(60*60*24));
  73. $nuclearpollution = max((400-($nukeage*3)),0);
  74. $citypollution = max($citypollution+$nuclearpollution,0);
  75.  
  76. $citydatediff = strtotime(date("c")) - strtotime($cidfetch['date']);
  77. $cityage = floor($citydatediff/(60*60*24));
  78.    
  79. $basepopulation = $cidfetch['infrastructure']*100;
  80. $popdensity = $basepopulation/($cidfetch['land']+.001);
  81. $disease = (((0.01*($popdensity*$popdensity))-25)/100)+($basepopulation/100000)-($hospitaldisease)+($citypollution*0.05);
  82. $disease = varPercentage($disease);
  83. $diseaselost = ($disease/10)*($basepopulation/10);
  84. $commerce = $subwaycommerce+$supermarketcommerce+$bankcommerce+$mallcommerce+$stadiumcommerce;
  85. if($cnidf['itc'] == 1) { $commerce = max(min($commerce,115),0); } else { $commerce = varPercentage($commerce); }
  86. $nationaltaxrate = (($cnidf['ecopolicy']*(-45/40)) + 27.5)/100;
  87. $minimumwage = (725/($nationaltaxrate*1000));
  88. $avgincome = (($commerce/50)*$minimumwage)+$minimumwage;
  89. $crime = ((((103-$commerce)*(103-$commerce))+$basepopulation)/111111)-$policedcrime;
  90. $crime = varPercentage($crime);
  91. $crimelost = max(((($crime/10)*$basepopulation)-25),0);
  92. $population = max(10,($basepopulation-$diseaselost-$crimelost)*(1+($cityage/3000)));
  93. //$population = max(10,$basepopulation-$diseaselost-$crimelost);
  94.  
  95. $landarea += $cidfetch['land'];
  96. $totalinfra += $cidfetch['infrastructure'];
  97. $totalpopulation += $population;
  98. $totalpollution += $citypollution;
  99. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement