Define the WormMoney class containing money related functions.  
 More...
| 
Static Public Attributes | 
| static | WM_SILENT = true | 
| static | WM_SHOWINFO = false | 
| 
Money related functions | 
| static function | HasMoney (money) | 
|  | Check if we have enough money (via loan and on bank). 
 | 
| static function | GetMoney (money, silent=false) | 
|  | Get the amount of money requested, loan if needed. 
 | 
| static function | InflationCorrection (money) | 
|  | Compute the amount of money corrected for inflation. 
 | 
| function | GetMinimumCashNeeded () | 
|  | Calculates the minimum amount of cash needed to be at hand. 
 | 
| function | GetMaxBankBalance () | 
|  | Calculates how much cash will be on hand if the maximum loan is taken. 
 | 
| function | WaitForMoney (amount_required, sleep_period, iterations, update_log_period=500, silent=false) | 
|  | Wait a certain maximum amount of time until we have a required amount of money. 
 | 
Detailed Description
Define the WormMoney class containing money related functions. 
Member Function Documentation
      
        
          | function WormMoney::GetMaxBankBalance | ( |  | ) |  | 
      
 
Calculates how much cash will be on hand if the maximum loan is taken. 
- Returns
- The maximum amount of money. 
- Note
- Taken from SimpleAI. 
 
 
      
        
          | function WormMoney::GetMinimumCashNeeded | ( |  | ) |  | 
      
 
Calculates the minimum amount of cash needed to be at hand. 
This is used to avoid going bankrupt because of station maintenance costs. 
- Note
- Taken from SimpleAI. 
- Todo:
- Think of a better computation than stationcount * 50 since I think maintenance costs don't increase linearly. 
- Returns
- 10000 pounds plus the expected station maintenance costs. 
- Todo:
- Maybe also use InflationCorrection on GetLoanInterval or is that already corrected for inflation? 
 
 
  
  | 
        
          | function WormMoney::GetMoney | ( | money | , |  
          |  |  | silent | = false |  
          |  | ) |  |  |  | static | 
 
Get the amount of money requested, loan if needed. 
- Parameters
- 
  
    | money | The amount of money we need. |  | silent | (false by default) Whether or not we should show info about failure to get money or getting a loan. |  
 
- Returns
- Boolean saying if we got the needed money or not. 
 
 
  
  | 
        
          | function WormMoney::HasMoney | ( | money |  | ) |  |  | static | 
 
Check if we have enough money (via loan and on bank). 
- Parameters
- 
  
    | money | The amount of money we need. |  
 
- Returns
- Boolean saying if we do or don't have enough money. 
 
 
  
  | 
        
          | function WormMoney::InflationCorrection | ( | money |  | ) |  |  | static | 
 
Compute the amount of money corrected for inflation. 
- Parameters
- 
  
    | money | The uncorrected amount of money. |  
 
- Returns
- The inflation corrected amount of money. 
- Note
- Adapted from SuperLib.Money.Inflate: Computes GetInflationRate only once. 
 
 
      
        
          | function WormMoney::WaitForMoney | ( | amount_required | , | 
        
          |  |  | sleep_period | , | 
        
          |  |  | iterations | , | 
        
          |  |  | update_log_period | = 500, | 
        
          |  |  | silent | = false | 
        
          |  | ) |  |  | 
      
 
Wait a certain maximum amount of time until we have a required amount of money. 
- Parameters
- 
  
    | amount_required | The amount of money we need. |  | sleep_period | The amount of time in ms to sleep after which we check the money again. |  | iterations | The maximum amount of times we will go to sleep. |  | update_log_period | How often we will show a log message "Waiting...", default every 500 ms. Should be a multiple of sleep_period. |  | silent | Boolean: true means don't show any log messages, false (default) show log messages that we are waiting. |  
 
- Returns
- Boolean: true means we got the required money, false we still don't have enough money. 
- Precondition
- sleep_period > 0; update_log_period > sleep_period; iterations > 0. 
 
 
The documentation for this class was generated from the following file: