The Battle for Wesnoth  1.19.0-dev
Classes | Public Member Functions | List of all members
display_context Class Referenceabstract

Abstract class for exposing game data that doesn't depend on the GUI, however which for historical reasons is generally accessed via the GUI method display::get_singleton(). More...

#include <display_context.hpp>

Inheritance diagram for display_context:

Classes

struct  can_move_result
 

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
 This getter takes a 1-based side number, not a 0-based team number. More...
 
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
 
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. 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

Abstract class for exposing game data that doesn't depend on the GUI, however which for historical reasons is generally accessed via the GUI method display::get_singleton().

Definition at line 34 of file display_context.hpp.

Constructor & Destructor Documentation

◆ ~display_context()

virtual display_context::~display_context ( )
inlinevirtual

Definition at line 124 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

Definition at line 48 of file display_context.hpp.

References utf8::size(), and teams().

◆ 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(), play_controller::is_observer(), 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.

Definition at line 144 of file display_context.cpp.

References units().

Referenced by 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 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()

display_context::can_move_result display_context::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.

Definition at line 71 of file display_context.cpp.

References display_context::can_move_result::attack_here, 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(), display_context::can_move_result::move, unit::movement_cost(), unit::movement_left(), unit::side(), and units().

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

◆ 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 105 of file display_context.cpp.

References unit::attacks_left(), disengaged, 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(), and image::prep_minimap_for_rendering().

◆ units()

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

◆ village_owner()

int display_context::village_owner ( const map_location loc) const

◆ 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 29 of file display_context.cpp.

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

Referenced by unit::invisible().


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