A unit group in the game. This may consist of a ship and any number of crew.
More...
#include <unit.hpp>
|
bool | attack (const Tile &tile, const std::string &target) |
| attacks either the 'crew' or 'ship' on a _tile in range. More...
|
|
bool | bury (int amount) |
| buries gold on this _unit's _tile. _gold must be a certain distance away for it to get interest (_game.min_interest_distance). More...
|
|
bool | deposit (int amount=0) |
| puts gold into an adjacent _port. _if that _port is the _player's port, the gold is added to that _player. _if that _port is owned by merchants, it adds to that _port's investment. More...
|
|
bool | dig (int amount=0) |
| digs up gold on this _unit's _tile. More...
|
|
bool | move (const Tile &tile) |
| moves this _unit from its current _tile to an adjacent _tile. _if this _unit merges with another one, the other _unit will be destroyed and its tile will be set to null. _make sure to check that your _unit's tile is not null before doing things with it. More...
|
|
bool | rest () |
| regenerates this _unit's health. _must be used in range of a port. More...
|
|
bool | split (const Tile &tile, int amount=1, int gold=0) |
| moves a number of crew from this _unit to the given _tile. _this will consume a move from those crew. More...
|
|
bool | withdraw (int amount=0) |
| takes gold from the _player. _you can only withdraw from your own _port. More...
|
|
void | log (const std::string &message) |
| adds a message to this _game_object's logs. _intended for your own debugging purposes, as strings stored here are saved in the gamelog. More...
|
|
template<typename T > |
std::shared_ptr< typename
T::element_type > | as () |
| Dynamically casts this object to another type. Returns nullptr if it cannot be converted to the type. More...
|
|
template<typename T > |
bool | is () |
| Determines if this object is of the specified object type More...
|
|
|
const bool & | acted |
| Whether this Unit has performed its action this turn. More...
|
|
const int & | crew |
| How many crew are on this Tile. This number will always be <= crewHealth. More...
|
|
const int & | crew_health |
| How much total health the crew on this Tile have. More...
|
|
const int & | gold |
| How much gold this Unit is carrying. More...
|
|
const int & | moves |
| How many more times this Unit may move this turn. More...
|
|
const Player & | owner |
| The Player that owns and can control this Unit, or null if the Unit is neutral. More...
|
|
const std::vector< Tile > & | path |
| (Merchants only) The path this Unit will follow. The first element is the Tile this Unit will move to next. More...
|
|
const int & | ship_health |
| If a ship is on this Tile, how much health it has remaining. 0 for no ship. More...
|
|
const int & | stun_turns |
| (Merchants only) The number of turns this merchant ship won't be able to move. They will still attack. Merchant ships are stunned when they're attacked. More...
|
|
const Port & | target_port |
| (Merchants only) The Port this Unit is moving to. More...
|
|
const Tile & | tile |
| The Tile this Unit is on. More...
|
|
const std::string & | game_object_name |
| String representing the top level Class that this game object is an instance of. Used for reflection to create new instances on clients, but exposed for convenience should AIs want this data. More...
|
|
const std::string & | id |
| A unique id for each instance of a GameObject or a sub class. Used for client and server communication. Should never change value after being set. More...
|
|
const std::vector< std::string > & | logs |
| Any strings logged will be stored here. Intended for debugging. More...
|
|
A unit group in the game. This may consist of a ship and any number of crew.
template<typename T >
std::shared_ptr<typename T::element_type> cpp_client::Base_object::as |
( |
| ) |
|
|
inlineinherited |
Dynamically casts this object to another type. Returns nullptr if it cannot be converted to the type.
- Returns
- A pointer to the desired type, or nullptr if it could not be converted
bool cpp_client::pirates::Unit::attack |
( |
const Tile & |
tile, |
|
|
const std::string & |
target |
|
) |
| |
attacks either the 'crew' or 'ship' on a _tile in range.
- Parameters
-
tile | The Tile to attack. |
target | Whether to attack 'crew' or 'ship'. Crew deal damage to crew and ships deal damage to ships. Consumes any remaining moves. |
bool cpp_client::pirates::Unit::bury |
( |
int |
amount | ) |
|
buries gold on this _unit's _tile. _gold must be a certain distance away for it to get interest (_game.min_interest_distance).
- Parameters
-
amount | How much gold this Unit should bury. Amounts <= 0 will bury as much as possible. |
bool cpp_client::pirates::Unit::deposit |
( |
int |
amount = 0 | ) |
|
puts gold into an adjacent _port. _if that _port is the _player's port, the gold is added to that _player. _if that _port is owned by merchants, it adds to that _port's investment.
- Parameters
-
amount | The amount of gold to deposit. Amounts <= 0 will deposit all the gold on this Unit. |
bool cpp_client::pirates::Unit::dig |
( |
int |
amount = 0 | ) |
|
digs up gold on this _unit's _tile.
- Parameters
-
amount | How much gold this Unit should take. Amounts <= 0 will dig up as much as possible. |
template<typename T >
bool cpp_client::Base_object::is |
( |
| ) |
|
|
inlineinherited |
Determines if this object is of the specified object type
- Returns
- true if the object is the object type, false otherwise
void cpp_client::pirates::Game_object::log |
( |
const std::string & |
message | ) |
|
|
inherited |
adds a message to this _game_object's logs. _intended for your own debugging purposes, as strings stored here are saved in the gamelog.
- Parameters
-
message | A string to add to this GameObject's log. Intended for debugging. |
bool cpp_client::pirates::Unit::move |
( |
const Tile & |
tile | ) |
|
moves this _unit from its current _tile to an adjacent _tile. _if this _unit merges with another one, the other _unit will be destroyed and its tile will be set to null. _make sure to check that your _unit's tile is not null before doing things with it.
- Parameters
-
bool cpp_client::pirates::Unit::rest |
( |
| ) |
|
regenerates this _unit's health. _must be used in range of a port.
bool cpp_client::pirates::Unit::split |
( |
const Tile & |
tile, |
|
|
int |
amount = 1 , |
|
|
int |
gold = 0 |
|
) |
| |
moves a number of crew from this _unit to the given _tile. _this will consume a move from those crew.
- Parameters
-
tile | The Tile to move the crew to. |
amount | The number of crew to move onto that Tile. Amount <= 0 will move all the crew to that Tile. |
gold | The amount of gold the crew should take with them. Gold < 0 will move all the gold to that Tile. |
bool cpp_client::pirates::Unit::withdraw |
( |
int |
amount = 0 | ) |
|
takes gold from the _player. _you can only withdraw from your own _port.
- Parameters
-
amount | The amount of gold to withdraw. Amounts <= 0 will withdraw everything. |
const bool& cpp_client::pirates::Unit::acted |
Whether this Unit has performed its action this turn.
const int& cpp_client::pirates::Unit::crew |
How many crew are on this Tile. This number will always be <= crewHealth.
const int& cpp_client::pirates::Unit::crew_health |
How much total health the crew on this Tile have.
const std::string& cpp_client::pirates::Game_object::game_object_name |
|
inherited |
String representing the top level Class that this game object is an instance of. Used for reflection to create new instances on clients, but exposed for convenience should AIs want this data.
const int& cpp_client::pirates::Unit::gold |
How much gold this Unit is carrying.
const std::string& cpp_client::pirates::Game_object::id |
|
inherited |
A unique id for each instance of a GameObject or a sub class. Used for client and server communication. Should never change value after being set.
const std::vector<std::string>& cpp_client::pirates::Game_object::logs |
|
inherited |
Any strings logged will be stored here. Intended for debugging.
const int& cpp_client::pirates::Unit::moves |
How many more times this Unit may move this turn.
const Player& cpp_client::pirates::Unit::owner |
The Player that owns and can control this Unit, or null if the Unit is neutral.
const std::vector<Tile>& cpp_client::pirates::Unit::path |
(Merchants only) The path this Unit will follow. The first element is the Tile this Unit will move to next.
const int& cpp_client::pirates::Unit::ship_health |
If a ship is on this Tile, how much health it has remaining. 0 for no ship.
const int& cpp_client::pirates::Unit::stun_turns |
(Merchants only) The number of turns this merchant ship won't be able to move. They will still attack. Merchant ships are stunned when they're attacked.
const Port& cpp_client::pirates::Unit::target_port |
(Merchants only) The Port this Unit is moving to.
const Tile& cpp_client::pirates::Unit::tile |
The documentation for this class was generated from the following file: