Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

lib/taxplaner.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************************
00003  This program is free software; you can redistribute it and/or
00004  modify it under the terms of the GNU General Public License
00005  as published by the Free Software Foundation; either version 2
00006  of the License, or (at your option) any later version.
00007 
00008  This program is distributed in the hope that it will be useful,
00009  but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  GNU General Public License for more details.
00012 
00013  You should have received a copy of the GNU General Public License
00014  along with this program; if not, write to the Free Software
00015  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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         // check params
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                 // no tax value set
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                 // no tax value set
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 }

Generated on Sun May 8 19:29:45 2005 for PhpMap by  doxygen 1.4.2