Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //cityfunctions
- $neededpower = 0;
- $poweredinfra = 0;
- $commerce = 0;
- $policedcrime = 0;
- $hospitaldisease = 0;
- $subwaycommerce = 0;
- $supermarketcommerce = 0;
- $bankcommerce = 0;
- $mallcommerce = 0;
- $stadiumcommerce = 0;
- if(!defined('NO_CITYFUNC_DUPES')) {
- $gamedatequery = $mysqli->query("SELECT value FROM gamestats WHERE valuetype='1'")->fetch_array(MYSQLI_ASSOC);
- $gamedate = date('Y-m-d', $gamedatequery['value']*100);
- $cnidq = $mysqli->query("SELECT account_id, ecopolicy, continent, nation_name, money, coal, oil, uranium, itc FROM nations WHERE id='$cidfetch[nation_id]'");
- $cnidf = $cnidq->fetch_array(MYSQLI_ASSOC);
- } else {
- $cnidf = $nquery->fetch_array(MYSQLI_ASSOC);
- }
- //calculate powered pollution
- $plantpollution = ($cidfetch['coalpower']*8)+($cidfetch['oilpower']*6);
- $civilpollution = ($cidfetch['policestation'])+($cidfetch['hospital']*4)+($cidfetch['subway']*-45)+($cidfetch['recyclingcenter']*-70);
- $manufpollution = ($cidfetch['steelmill']*20)+($cidfetch['gasrefinery']*16)+($cidfetch['aluminumrefinery']*20)+($cidfetch['munitionsfactory']*16);
- $commercepollution = ($cidfetch['mall']*2)+($cidfetch['stadium']*5);
- //check power
- if($cidfetch['windpower'] > 0) { $poweredinfra = $cidfetch['windpower']*250; }
- $neededpower = $cidfetch['infrastructure']-$poweredinfra;
- if($neededpower > 0) { //check nuclear
- if($cidfetch['nuclearpower'] > 0 AND $cnidf['uranium'] > 0) {
- 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']; }
- } } $neededpower = $cidfetch['infrastructure']-$poweredinfra;
- if($neededpower > 0) { //check oil
- if($cidfetch['oilpower'] > 0 AND $cnidf['oil'] > 0) {
- 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; } } }
- $neededpower = $cidfetch['infrastructure']-$poweredinfra;
- if($neededpower > 0) { //check coal
- if($cidfetch['coalpower'] > 0 AND $cnidf['coal'] > 0) {
- 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; } } }
- $neededpower = $cidfetch['infrastructure']-$poweredinfra;
- if($neededpower > 0) { $powered = "No"; $citypower = "No Power"; $plantpollution = 0; $commercepollution = 0; $civilpollution = 0; $manufpollution = 0; } else {
- $powered = "Yes";
- $policestations = $cidfetch['policestation'];
- $hospitals = $cidfetch['hospital'];
- $subway = $cidfetch['subway'];
- $supermarkets = $cidfetch['supermarket'];
- $banks = $cidfetch['bank'];
- $malls = $cidfetch['mall'];
- $stadiums = $cidfetch['stadium'];
- $citypower = "Powered";
- $policedcrime = $policestations*2.5;
- $hospitaldisease = $hospitals*2.5;
- $subwaycommerce = ($subway*7);
- $supermarketcommerce = $supermarkets*4;
- $bankcommerce = $banks*7;
- $mallcommerce = $malls*12;
- $stadiumcommerce = $stadiums*18;
- }
- //pollution
- $resourcepollution = ($cidfetch['farm'])+($cidfetch['uramine']*10)+($cidfetch['leadmine']*6)+($cidfetch['ironmine']*6)+($cidfetch['bauxitemine']*6)+($cidfetch['coalmine']*6)+($cidfetch['oilwell']*6);
- $citypollution = max($plantpollution+$commercepollution+$civilpollution+$manufpollution+$resourcepollution,0);
- //check for nuclear pollution
- $nukedatediff = strtotime($gamedate) - strtotime($cidfetch['nukedate']);
- $nukeage = floor($nukedatediff/(60*60*24));
- $nuclearpollution = max((400-($nukeage*3)),0);
- $citypollution = max($citypollution+$nuclearpollution,0);
- $citydatediff = strtotime(date("c")) - strtotime($cidfetch['date']);
- $cityage = floor($citydatediff/(60*60*24));
- $basepopulation = $cidfetch['infrastructure']*100;
- $popdensity = $basepopulation/($cidfetch['land']+.001);
- $disease = (((0.01*($popdensity*$popdensity))-25)/100)+($basepopulation/100000)-($hospitaldisease)+($citypollution*0.05);
- $disease = varPercentage($disease);
- $diseaselost = ($disease/10)*($basepopulation/10);
- $commerce = $subwaycommerce+$supermarketcommerce+$bankcommerce+$mallcommerce+$stadiumcommerce;
- if($cnidf['itc'] == 1) { $commerce = max(min($commerce,115),0); } else { $commerce = varPercentage($commerce); }
- $nationaltaxrate = (($cnidf['ecopolicy']*(-45/40)) + 27.5)/100;
- $minimumwage = (725/($nationaltaxrate*1000));
- $avgincome = (($commerce/50)*$minimumwage)+$minimumwage;
- $crime = ((((103-$commerce)*(103-$commerce))+$basepopulation)/111111)-$policedcrime;
- $crime = varPercentage($crime);
- $crimelost = max(((($crime/10)*$basepopulation)-25),0);
- $population = max(10,($basepopulation-$diseaselost-$crimelost)*(1+($cityage/3000)));
- //$population = max(10,$basepopulation-$diseaselost-$crimelost);
- $landarea += $cidfetch['land'];
- $totalinfra += $cidfetch['infrastructure'];
- $totalpopulation += $population;
- $totalpollution += $citypollution;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement