# AIAccounting Class Reference

Class that keeps track of the costs, so you can request how much a block of commands did cost in total. More...

`#include <ai_accounting.hpp>`

Inheritance diagram for AIAccounting:

## Public Member Functions
| AIAccounting ()
| Creating instance of this class starts counting the costs of commands from zero.
| ~AIAccounting ()
| Destroying this instance reset the costs to the value it was in when the instance was created.
Money | GetCosts ()
| Get the current value of the costs.
void | ResetCosts ()
| Reset the costs to zero.
## Static Public Member Functions
static const char * | GetClassName ()
## Private Attributes
Money | last_costs

## Detailed Description

Class that keeps track of the costs, so you can request how much a block of commands did cost in total.

Works in both Execute as in Test mode. Example: { local costs = AIAccounting(); BuildRoad(from_here, to_here); BuildRoad(from_there, to_there); print("Costs for route is: " + costs.GetCosts()); }

Definition at line 21 of file ai_accounting.hpp.

## Constructor & Destructor Documentation

AIAccounting::AIAccounting | ( |  | ) |

Creating instance of this class starts counting the costs of commands from zero.

Note:
  when the instance is destroyed, he restores the costs that was current when the instance was created!

Definition at line 17 of file ai_accounting.cpp.

References AIObject::GetDoCommandCosts(), and AIObject::SetDoCommandCosts().

## Member Function Documentation

Money AIAccounting::GetCosts | ( |  | ) |

Get the current value of the costs.

Returns:
  The current costs.

Definition at line 7 of file ai_accounting.cpp.

References AIObject::GetDoCommandCosts().

The documentation for this class was generated from the following files:

- src/ai/api/ai_accounting.hpp
- src/ai/api/ai_accounting.cpp