26 return teams().at(side - 1);
31 return side > 0 && side <= static_cast<int>(
teams().
size());
41 const unit & u = *u_it;
47 }
else if (!
get_team(side_num).fogged(u_loc)
58 if (!
map().on_board(
loc))
return nullptr;
60 if (!u.
valid() || !u->is_visible_to_team(current_team, see_all)) {
68 if (!
map().on_board(
loc))
return nullptr;
70 if (!u.
valid() || !u->is_visible_to_team(current_team, see_all)) {
79 return {
false,
false};
84 return {
false,
false};
91 const auto& attacks = u.
attacks();
93 std::set<int> attackable_distances;
94 for (
const auto& attack : attacks) {
95 for (
int i = attack.min_range();
i <= attack.max_range(); ++
i) {
96 attackable_distances.insert(
i);
100 if(!attackable_distances.empty()) {
101 int max_distance = *
std::prev(attackable_distances.end());
103 for (
int dx = -max_distance; dx <= max_distance; ++dx) {
104 for (
int dy = -max_distance; dy <= max_distance && !result.
attack_here; ++dy) {
106 int adjusted_dy = dy + floor(dx / 2.0);
111 if (attackable_distances.find(distance) == attackable_distances.end()) {
114 if (
map().on_board(locs)) {
116 if (
i.valid() && !
i->incapacitated() && current_team.
is_enemy(
i->side()) &&
i->is_visible_to_team(
get_team(u.
side()),
false)) {
125 if (
map().on_board(adj)) {
153 if(
t.owns_village(
loc)) {
179 if (u.
side() == side) ++res;
188 if (u.
side() == side) res += u.
cost();
204 , units(dc.side_units(side))
205 , upkeep(dc.side_upkeep(side))
206 , expenses(std::max<int>(0, upkeep - tm.support()))
207 , net_income(tm.total_income() - expenses)
Abstract class for exposing game data that doesn't depend on the GUI, however which for historical re...
const team & get_team(int side) const
This getter takes a 1-based side number, not a 0-based team number.
orb_status unit_orb_status(const unit &u) const
Returns an enumurated summary of whether this unit can move and/or attack.
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,...
const unit * get_visible_unit(const map_location &loc, const team ¤t_team, bool see_all=false) const
bool is_observer() const
Check if we are an observer in this game.
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,...
virtual const gamemap & map() const =0
bool has_team(int side) const
int side_units(int side_num) const
Returns the number of units of the side side_num.
virtual const std::vector< team > & teams() const =0
unit_const_ptr get_visible_unit_shared_ptr(const map_location &loc, const team ¤t_team, bool see_all=false) const
int side_units_cost(int side_num) const
Returns the total cost of units of side side_num.
virtual const unit_map & units() const =0
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 side_upkeep(int side_num) const
This class stores all the data for a single 'side' (in game nomenclature).
bool is_enemy(int n) const
unit_iterator find(std::size_t id)
This class represents a single unit of a specific type.
bool invisible(const map_location &loc, bool see_all=true) const
bool user_end_turn() const
Check whether the user ended their turn.
bool incapacitated() const
Check if the unit has been petrified.
int cost() const
How much gold is required to recruit this unit.
int side() const
The side this unit belongs to.
attack_itors attacks()
Gets an iterator over this unit's attacks.
int max_attacks() const
The maximum number of attacks this unit may perform per turn, usually 1.
int attacks_left() const
Gets the remaining number of attacks this unit can perform this turn.
bool has_goto() const
Gets whether this unit has a multi-turn destination set.
const map_location & get_location() const
The current map location this unit is at.
bool has_moved() const
Checks if this unit has moved.
int movement_cost(const t_translation::terrain_code &terrain) const
Get the unit's movement cost on a particular terrain.
int movement_left() const
Gets how far a unit can move, considering the incapacitated flag.
int total_movement() const
The maximum moves this unit has.
int upkeep() const
Gets the amount of gold this unit costs a side per turn.
void get_adjacent_tiles(const map_location &a, map_location *res)
Function which, given a location, will place all adjacent locations in res.
std::size_t distance_between(const map_location &a, const map_location &b)
Function which gives the number of hexes between two tiles (i.e.
std::size_t size(std::string_view str)
Length in characters of a UTF-8 string.
orb_status
Corresponds to the colored orbs displayed above units' hp-bar and xp-bar.
@ partial
There are still moves and/or attacks possible, but the unit doesn't fit in the "unmoved" status.
@ moved
All moves and possible attacks have been done.
@ unmoved
The unit still has full movement and all attacks available.
@ disengaged
The unit can move but can't attack, and wouldn't be able to attack even if it was moved to a hex adja...
std::shared_ptr< const unit > unit_const_ptr
bool attack_here
The unit can make an attack from the hex that it's currently on, this requires attack points and a no...
bool move
The unit can move to another hex, taking account of enemies' locations, ZoC and terrain costs vs curr...
Encapsulates the map of the game.
team_data(const display_context &dc, const team &tm)
pointer get_shared_ptr() const
This is exactly the same as operator-> but it's slightly more readable, and can replace &*iter syntax...