26 return teams().at(side - 1);
36 const unit & u = *u_it;
53 if (!
map().on_board(loc))
return nullptr;
55 if (!u.
valid() || !u->is_visible_to_team(current_team, see_all)) {
63 if (!
map().on_board(loc))
return nullptr;
65 if (!u.
valid() || !u->is_visible_to_team(current_team, see_all)) {
74 return {
false,
false};
79 return {
false,
false};
87 if(!result.attack_here) {
89 if (i.
valid() && !i->incapacitated() && current_team.
is_enemy(i->side())) {
90 result.attack_here =
true;
121 const std::vector<team> &
t =
teams();
122 for(std::size_t
i = 0;
i != t.size(); ++
i) {
123 if(t[
i].owns_village(loc))
148 if (u.side() == side) ++res;
157 if (u.side() == side) res += u.cost();
166 if (u.side() == side) res += u.upkeep();
175 , expenses(
std::max<int>(0, upkeep - tm.support()))
176 , net_income(tm.total_income() - expenses)
int village_owner(const map_location &loc) const
Given the location of a village, will return the 1-based number of the team that currently owns it...
int attacks_left() const
Gets the remaining number of attacks this unit can perform this turn.
const team & get_team(int side) const
void get_adjacent_tiles(const map_location &a, map_location *res)
Function which, given a location, will place all adjacent locations in res.
This class represents a single unit of a specific type.
int movement_cost(const t_translation::terrain_code &terrain) const
Get the unit's movement cost on a particular terrain.
const unit * get_visible_unit(const map_location &loc, const team ¤t_team, bool see_all=false) const
can_move_result unit_can_move(const unit &u) const
Work out what u can do - this does not check which player's turn is currently active, the result is calculated assuming that the unit's owner is currently active.
orb_status
Corresponds to the colored orbs displayed above units' hp-bar and xp-bar.
virtual const gamemap & map() const =0
The unit still has full movement and all attacks available.
team_data(const display_context &dc, const team &tm)
std::shared_ptr< const unit > unit_const_ptr
This class stores all the data for a single 'side' (in game nomenclature).
int side_upkeep(int side_num) const
bool is_enemy(int n) const
virtual const unit_map & units() const =0
Encapsulates the map of the game.
int side_units_cost(int side_num) const
Returns the total cost of units of side side_num.
bool user_end_turn() const
Check whether the user ended their turn.
unit_iterator find(std::size_t id)
bool invisible(const map_location &loc, bool see_all=true) const
bool has_moved() const
Checks if this unit has moved.
pointer get_shared_ptr() const
This is exactly the same as operator-> but it's slightly more readable, and can replace &*iter syntax...
virtual const std::vector< team > & teams() const =0
bool is_observer() const
Check if we are an observer in this game.
bool on_board(const map_location &loc) const
Tell if a location is on the map.
bool has_goto() const
Gets whether this unit has a multi-turn destination set.
All moves and possible attacks have been done.
unit_const_ptr get_visible_unit_shared_ptr(const map_location &loc, const team ¤t_team, bool see_all=false) const
orb_status unit_orb_status(const unit &u) const
Returns an enumurated summary of whether this unit can move and/or attack.
const map_location & get_location() const
The current map location this unit is at.
bool incapacitated() const
Check if the unit has been petrified.
The unit can move but can't attack, and wouldn't be able to attack even if it was moved to a hex adja...
int total_movement() const
The maximum moves this unit has.
bool fogged(const map_location &loc) const
int side() const
The side this unit belongs to.
int side_units(int side_num) const
Returns the number of units of the side side_num.
There are still moves and/or attacks possible, but the unit doesn't fit in the "unmoved" status...
bool would_be_discovered(const map_location &loc, int side_num, bool see_all=true)
Given a location and a side number, indicates whether an invisible unit of that side at that location...
int movement_left() const
Gets how far a unit can move, considering the incapacitated flag.
int max_attacks() const
The maximum number of attacks this unit may perform per turn, usually 1.