00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00029 class Taxplaner
00030 {
00031 var $intGrowth;
00032 var $intInflTax;
00033 var $intTax;
00034 var $intWorker;
00035 var $intFood;
00036 var $intFoodBase;
00037 var $intUnit;
00038 var $intBuild;
00039 var $intGold;
00040 var $intTotalFood;
00041
00045 function Taxplaner ( )
00046 {
00047 }
00048
00061 function set ( $intGrowth, $intInflTax, $intTax, $intWorker, $intFood, $intFoodBase, $intUnit, $intBuild, $intGold )
00062 {
00063 $this->intGrowth = $intGrowth;
00064 $this->intInflTax = $intInflTax;
00065 $this->intTax = $intTax;
00066 $this->intWorker = $intWorker;
00067 $this->intFood = $intFood;
00068 $this->intFoodBase = $intFoodBase;
00069 $this->intUnit = $intUnit;
00070 $this->intBuild = $intBuild;
00071 $this->intGold = $intGold;
00072 $this->intTotalFood = $this->intFood + $this->intFoodBase;
00073 }
00074
00081 function taxCalc ( $intStartTax, $intEndTax )
00082 {
00083
00084 $intStart = min ( $intStartTax, $intEndTax );
00085 $intEnd = max ( $intStartTax, $intEndTax );
00086
00087 $aReturn = array();
00088 for ( $i = $intStart; $i<$intEnd; $i++)
00089 {
00090 $aReturn[$i] = $this->getTax ( $i );
00091 }
00092 return $aReturn;
00093 }
00094
00100 function getTax ( $intTax = 0 )
00101 {
00102 if ( $intTax == 0 )
00103 {
00104 if ( !$this->intTax )
00105 {
00106
00107 return false;
00108 }
00109 $intTax = $this->intTax;
00110 }
00111
00112 $intTotalWorker = 650 - $intTax * 25 + $this->intGrowth * 10;
00113 $intFreeWorker = $intTotalWorker - $this->intWorker;
00114 $intTaxIncome = round ( $intFreeWorker * 1.5 * $intTax / 100 * ( 1 + $this->intInflTax / 100 ) );
00115 $intFoodNeeded = round ( $intFreeWorker / 2.5);
00116 $intFood = $this->intTotalFood - ( 5 * ( $this->intBuild + $this->intUnit ) + $intFoodNeeded );
00117 $intGold = $intTaxIncome + $this->intGold - ( 5 * ( $this->intBuild + $this->intUnit ) );
00118 return array ( 'tax' => $intTax, 'gold' => $intGold, 'food' => $intFood );
00119 }
00120
00126 function getTaxDetails ( $intTax = 0 )
00127 {
00128 if ( $intTax == 0 )
00129 {
00130 if ( !$this->intTax )
00131 {
00132
00133 return false;
00134 }
00135 $intTax = $this->intTax;
00136 }
00137
00138 $intTotalWorker = 650 - $intTax * 25 + $this->intGrowth *10;
00139 $intFreeWorker = $intTotalWorker - $this->intWorker;
00140 $intTaxIncome = round ( $intFreeWorker * 1.5 * $intTax / 100 * ( 1 + $this->intInflTax / 100 ) );
00141 $intFoodNeeded = round ( $intFreeWorker / 2.5 );
00142 $intFood = $this->intTotalFood - ( 5 * ($this->intBuild + $this->intUnit ) + $intFoodNeeded );
00143 $intGold = $intTaxIncome + $this->intGold - ( 5 * ( $this->intUnit + $this->intBuild ) );
00144 return array ( 'workers_sum' => $intTotalWorker,
00145 'workers_free' => $intFreeWorker,
00146 'tax_income' => $intTaxIncome,
00147 'food_production' => $this->intTotalFood,
00148 'food_needed' => $intFoodNeeded,
00149 'food' => $intFood,
00150 'gold' => $intGold );
00151 }
00152 }