The Battle for Wesnoth  1.15.6+dev
Public Member Functions | List of all members
display_context Class Referenceabstract

#include <display_context.hpp>

Inheritance diagram for display_context:
Inheritance graph

Public Member Functions

virtual const std::vector< team > & teams () const =0
 
virtual const gamemapmap () const =0
 
virtual const unit_mapunits () const =0
 
virtual const std::vector< std::string > & hidden_label_categories () const =0
 
virtual std::vector< std::string > & hidden_label_categories ()=0
 
const teamget_team (int side) const
 
template<typename T = void>
bool has_team (int side) const
 
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 would be revealed (perhaps ambushed), based on what team side_num can see. More...
 
const unitget_visible_unit (const map_location &loc, const team &current_team, bool see_all=false) const
 
unit_const_ptr get_visible_unit_shared_ptr (const map_location &loc, const team &current_team, bool see_all=false) const
 
bool unit_can_move (const unit &u) const
 True if, and only if, at least one of the following is true: More...
 
orb_status unit_orb_status (const unit &u) const
 Returns an enumurated summary of whether this unit can move and/or attack. More...
 
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, and 0 if it is unowned. More...
 
int side_units (int side_num) const
 Returns the number of units of the side side_num. More...
 
int side_units_cost (int side_num) const
 Returns the total cost of units of side side_num. More...
 
int side_upkeep (int side_num) const
 
bool is_observer () const
 Check if we are an observer in this game. More...
 
virtual ~display_context ()
 

Detailed Description

Definition at line 36 of file display_context.hpp.

Constructor & Destructor Documentation

◆ ~display_context()

virtual display_context::~display_context ( )
inlinevirtual

Definition at line 113 of file display_context.hpp.

Member Function Documentation

◆ get_team()

const team & display_context::get_team ( int  side) const

◆ get_visible_unit()

const unit * display_context::get_visible_unit ( const map_location loc,
const team current_team,
bool  see_all = false 
) const

◆ get_visible_unit_shared_ptr()

unit_const_ptr display_context::get_visible_unit_shared_ptr ( const map_location loc,
const team current_team,
bool  see_all = false 
) const

◆ has_team()

template<typename T = void>
bool display_context::has_team ( int  side) const
inline

◆ hidden_label_categories() [1/2]

virtual const std::vector<std::string>& display_context::hidden_label_categories ( ) const
pure virtual

◆ hidden_label_categories() [2/2]

virtual std::vector<std::string>& display_context::hidden_label_categories ( )
pure virtual

◆ is_observer()

bool display_context::is_observer ( ) const

Check if we are an observer in this game.

Determine if we are an observer, by checking if every team is not locally controlled.

Definition at line 132 of file display_context.cpp.

References t, and teams().

Referenced by display_chat_manager::add_chat_message(), events::menu_handler::clear_labels(), has_team(), events::menu_handler::send_chat_message(), and terrain_label::viewable().

◆ map()

virtual const gamemap& display_context::map ( ) const
pure virtual

◆ side_units()

int display_context::side_units ( int  side_num) const

Returns the number of units of the side side_num.

Static info getters previously declared at global scope in unit.?pp.

Definition at line 144 of file display_context.cpp.

References units().

Referenced by has_team(), and ai_testing::log_turn().

◆ side_units_cost()

int display_context::side_units_cost ( int  side_num) const

Returns the total cost of units of side side_num.

Definition at line 153 of file display_context.cpp.

References units().

Referenced by has_team(), and ai_testing::log_turn().

◆ side_upkeep()

int display_context::side_upkeep ( int  side_num) const

◆ teams()

virtual const std::vector<team>& display_context::teams ( ) const
pure virtual

◆ unit_can_move()

bool display_context::unit_can_move ( const unit u) const

True if, and only if, at least one of the following is true:

(a) the unit can move to another hex, taking account of ZoC and terrain costs vs current movement points.

(b) the unit can make an attack from the hex that it's currently on, requires attack points and a non-petrified enemy in an adjacent hex.

This does not check which player's turn is currently active, the result is calculated assuming that the unit's owner is currently active.

Definition at line 74 of file display_context.cpp.

References unit::attacks_left(), unit_map::find(), get_adjacent_tiles(), unit::get_location(), get_team(), unit::has_goto(), unit::has_moved(), i, team::is_enemy(), map(), unit::movement_cost(), unit::movement_left(), n, gamemap::on_board(), unit::side(), units(), and unit_map::iterator_base< iter_types >::valid().

Referenced by has_team(), events::mouse_handler::unit_in_cycle(), unit_orb_status(), and events::menu_handler::update_shroud_now().

◆ unit_orb_status()

orb_status display_context::unit_orb_status ( const unit u) const

Returns an enumurated summary of whether this unit can move and/or attack.

This does not check which player's turn is currently active, the result is calculated assuming that the unit's owner is currently active. For this reason this never returns orb_status::enemy nor orb_status::allied.

Definition at line 108 of file display_context.cpp.

References unit::attacks_left(), unit::max_attacks(), moved, unit::movement_left(), partial, unit::total_movement(), unit_can_move(), unmoved, and unit::user_end_turn().

Referenced by display::draw_minimap_units(), has_team(), and unit_drawer::redraw_unit().

◆ units()

virtual const unit_map& display_context::units ( ) const
pure virtual

◆ village_owner()

int display_context::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, and 0 if it is unowned.

Definition at line 119 of file display_context.cpp.

References i, t, and teams().

Referenced by events::menu_handler::change_side(), game_board::change_terrain(), image::getMinimap(), has_team(), display::invalidate_animations_location(), ai::ai_default_rca::aspect_attacks_base::rate_terrain(), ai::default_ai_context_impl::rate_terrain(), and game_board::replace_map().

◆ would_be_discovered()

bool display_context::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 would be revealed (perhaps ambushed), based on what team side_num can see.

If see_all is true then the calculation ignores fog, and enemy ambushers.

Definition at line 28 of file display_context.cpp.

References unit_map::find(), team::fogged(), get_adjacent_tiles(), get_team(), unit::incapacitated(), unit::invisible(), team::is_enemy(), unit::side(), units(), and unit_map::iterator_base< iter_types >::valid().

Referenced by has_team(), and unit::invisible().


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