The Battle for Wesnoth  1.15.2+dev
Public Member Functions | Public Attributes | Friends | List of all members
game_state Class Reference

#include <game_state.hpp>

Inheritance diagram for game_state:
Inheritance graph

Public Member Functions

bool & init_side_done ()
 
game_events::wmi_managerget_wml_menu_items ()
 
const game_events::wmi_managerget_wml_menu_items () const
 
bool has_human_sides () const
 
 game_state (const config &level, play_controller &, const ter_data_cache &tdata)
 
 game_state (const config &level, play_controller &, game_board &board)
 The third parameter is an optimisation. More...
 
 ~game_state ()
 
void place_sides_in_preferred_locations (const config &level)
 
void init (const config &level, play_controller &)
 
void set_game_display (game_display *)
 
void write (config &cfg) const
 
virtual const display_contextget_disp_context () const override
 Inherited from filter_context. More...
 
virtual const tod_managerget_tod_man () const override
 Inherited from filter_context. More...
 
virtual const game_dataget_game_data () const override
 Inherited from filter_context. More...
 
virtual game_lua_kernelget_lua_kernel () const override
 Inherited from filter_context. More...
 
bool can_recruit_from (const map_location &leader_loc, int side) const
 Checks to see if a leader at leader_loc could recruit somewhere. More...
 
bool can_recruit_from (const unit &leader) const
 Checks to see if leader (assumed a leader) can recruit somewhere. More...
 
bool can_recruit_on (const map_location &leader_loc, const map_location &recruit_loc, int side) const
 Checks to see if a leader at leader_loc could recruit on recruit_loc. More...
 
bool can_recruit_on (const unit &leader, const map_location &recruit_loc) const
 Checks to see if leader (assumed a leader) can recruit on recruit_loc. More...
 
bool side_can_recruit_on (int side, map_location loc) const
 Checks if any of the sides leaders can recruit at a location. More...
 
- Public Member Functions inherited from filter_context
virtual ~filter_context ()
 

Public Attributes

game_data gamedata_
 
game_board board_
 
tod_manager tod_manager_
 
std::unique_ptr< pathfind::managerpathfind_manager_
 
const std::unique_ptr< reportsreports_
 
std::unique_ptr< game_lua_kernellua_kernel_
 
ai::manager ai_manager_
 
const std::unique_ptr< game_events::managerevents_manager_
 
const std::unique_ptr< actions::undo_listundo_stack_
 undo_stack_ is never nullptr. More...
 
int player_number_
 
int next_player_number_
 
bool do_healing_
 True if healing should be done at the beginning of the next side turn. More...
 
boost::optional< end_level_dataend_level_data_
 
bool init_side_done_
 
bool start_event_fired_
 
int server_request_number_
 
int first_human_team_
 

Friends

class replay_controller
 

Detailed Description

Definition at line 40 of file game_state.hpp.

Constructor & Destructor Documentation

◆ game_state() [1/2]

game_state::game_state ( const config level,
play_controller pc,
const ter_data_cache tdata 
)

◆ game_state() [2/2]

game_state::game_state ( const config level,
play_controller pc,
game_board board 
)

◆ ~game_state()

game_state::~game_state ( )

Definition at line 103 of file game_state.cpp.

Member Function Documentation

◆ can_recruit_from() [1/2]

bool game_state::can_recruit_from ( const map_location leader_loc,
int  side 
) const

Checks to see if a leader at leader_loc could recruit somewhere.

This takes into account terrain, shroud (for side side), and the presence of visible units. The behavior for an invalid side is subject to change for future needs.

Definition at line 308 of file game_state.cpp.

References board_, pathfind::find_vacant_tile(), game_board::get_team(), gamemap::is_keep(), game_board::map(), map_location::null_location(), and pathfind::VACANT_CASTLE.

Referenced by can_recruit_from(), and side_can_recruit_on().

◆ can_recruit_from() [2/2]

bool game_state::can_recruit_from ( const unit leader) const

Checks to see if leader (assumed a leader) can recruit somewhere.

This takes into account terrain, shroud, and the presence of visible units.

Definition at line 328 of file game_state.cpp.

References can_recruit_from(), unit::get_location(), and unit::side().

◆ can_recruit_on() [1/2]

bool game_state::can_recruit_on ( const map_location leader_loc,
const map_location recruit_loc,
int  side 
) const

Checks to see if a leader at leader_loc could recruit on recruit_loc.

This takes into account terrain, shroud (for side side), and whether or not there is already a visible unit at recruit_loc. The behavior for an invalid side is subject to change for future needs.

Definition at line 340 of file game_state.cpp.

References pathfind::a_star_search(), board_, game_board::get_team(), gamemap::h(), game_board::has_visible_unit(), gamemap::is_castle(), gamemap::is_keep(), game_board::map(), team::shrouded(), pathfind::plain_route::steps, and gamemap::w().

Referenced by wb::any_recruiter(), can_recruit_on(), actions::find_recruit_location(), wb::side_actions::queue_action(), and side_can_recruit_on().

◆ can_recruit_on() [2/2]

bool game_state::can_recruit_on ( const unit leader,
const map_location recruit_loc 
) const

Checks to see if leader (assumed a leader) can recruit on recruit_loc.

This takes into account terrain, shroud, and whether or not there is already a visible unit at recruit_loc.

Definition at line 381 of file game_state.cpp.

References can_recruit_on(), unit::get_location(), and unit::side().

◆ get_disp_context()

virtual const display_context& game_state::get_disp_context ( ) const
inlineoverridevirtual

Inherited from filter_context.

Implements filter_context.

Definition at line 90 of file game_state.hpp.

◆ get_game_data()

virtual const game_data* game_state::get_game_data ( ) const
inlineoverridevirtual

Inherited from filter_context.

Implements filter_context.

Definition at line 102 of file game_state.hpp.

◆ get_lua_kernel()

virtual game_lua_kernel* game_state::get_lua_kernel ( ) const
inlineoverridevirtual

Inherited from filter_context.

Implements filter_context.

Definition at line 108 of file game_state.hpp.

◆ get_tod_man()

virtual const tod_manager& game_state::get_tod_man ( ) const
inlineoverridevirtual

Inherited from filter_context.

Implements filter_context.

Definition at line 96 of file game_state.hpp.

◆ get_wml_menu_items() [1/2]

game_events::wmi_manager & game_state::get_wml_menu_items ( )

◆ get_wml_menu_items() [2/2]

const game_events::wmi_manager & game_state::get_wml_menu_items ( ) const

Definition at line 408 of file game_state.cpp.

References events_manager_.

◆ has_human_sides()

bool game_state::has_human_sides ( ) const
inline

Definition at line 73 of file game_state.hpp.

References utils::detail::init, game_config::images::level, and write().

◆ init()

void game_state::init ( const config level,
play_controller pc 
)

◆ init_side_done()

bool& game_state::init_side_done ( )
inline

Definition at line 67 of file game_state.hpp.

◆ place_sides_in_preferred_locations()

void game_state::place_sides_in_preferred_locations ( const config level)

◆ set_game_display()

void game_state::set_game_display ( game_display gd)

Definition at line 234 of file game_state.cpp.

References lua_kernel_.

Referenced by play_controller::init(), and play_controller::reset_gamestate().

◆ side_can_recruit_on()

bool game_state::side_can_recruit_on ( int  side,
map_location  loc 
) const

Checks if any of the sides leaders can recruit at a location.

Definition at line 386 of file game_state.cpp.

References unit_map::begin(), board_, can_recruit_from(), can_recruit_on(), unit_map::end(), unit_map::find(), and game_board::units().

Referenced by play_controller::hotkey_handler::in_context_menu().

◆ write()

void game_state::write ( config cfg) const

Friends And Related Function Documentation

◆ replay_controller

friend class replay_controller
friend

Definition at line 43 of file game_state.hpp.

Member Data Documentation

◆ ai_manager_

ai::manager game_state::ai_manager_

Definition at line 51 of file game_state.hpp.

◆ board_

game_board game_state::board_

Definition at line 46 of file game_state.hpp.

Referenced by events::menu_handler::board(), can_recruit_from(), can_recruit_on(), playsingle_controller::check_objectives(), play_controller::check_victory(), events::mouse_handler::current_team(), play_controller::current_team(), events::mouse_handler::current_unit_attacks_from(), events::mouse_handler::cycle_units(), play_controller::do_init_side(), play_controller::hotkey_handler::expand_wml_commands(), events::mouse_handler::fill_weapon_choices(), play_controller::find_last_visible_team(), events::mouse_handler::find_unit(), events::mouse_handler::find_unit_nonowning(), play_controller::finish_side_turn(), events::mouse_handler::get_adj_enemies(), events::mouse_handler::get_route(), init(), play_controller::init(), play_controller::is_team_visible(), playmp_controller::linger(), playsingle_controller::linger(), events::menu_handler::map(), events::mouse_handler::mouse_motion(), events::mouse_handler::move_action(), events::mouse_handler::move_unit_along_route(), place_sides_in_preferred_locations(), playsingle_controller::play_scenario(), playsingle_controller::play_scenario_main_loop(), playsingle_controller::play_side_impl(), play_controller::reset_gamestate(), events::mouse_handler::select_hex(), events::mouse_handler::show_attack_dialog(), events::mouse_handler::show_attack_options(), lua_gui2::show_gamestate_inspector(), play_controller::show_objectives(), playsingle_controller::show_turn_dialog(), side_can_recruit_on(), play_controller::tab(), events::menu_handler::teams(), events::mouse_handler::touch_motion(), events::mouse_handler::unit_in_cycle(), events::menu_handler::units(), events::mouse_handler::viewing_team(), and write().

◆ do_healing_

bool game_state::do_healing_

True if healing should be done at the beginning of the next side turn.

Definition at line 60 of file game_state.hpp.

Referenced by write().

◆ end_level_data_

boost::optional<end_level_data> game_state::end_level_data_

Definition at line 62 of file game_state.hpp.

Referenced by game_state(), and write().

◆ events_manager_

const std::unique_ptr<game_events::manager> game_state::events_manager_

◆ first_human_team_

int game_state::first_human_team_

◆ gamedata_

game_data game_state::gamedata_

◆ init_side_done_

bool game_state::init_side_done_

Definition at line 63 of file game_state.hpp.

Referenced by write().

◆ lua_kernel_

std::unique_ptr<game_lua_kernel> game_state::lua_kernel_

◆ next_player_number_

int game_state::next_player_number_

Definition at line 58 of file game_state.hpp.

Referenced by do_replay_handle(), game_lua_kernel::intf_end_turn(), and write().

◆ pathfind_manager_

std::unique_ptr<pathfind::manager> game_state::pathfind_manager_

Definition at line 48 of file game_state.hpp.

Referenced by play_controller::init(), play_controller::reset_gamestate(), and write().

◆ player_number_

int game_state::player_number_

Definition at line 57 of file game_state.hpp.

Referenced by write().

◆ reports_

const std::unique_ptr<reports> game_state::reports_

Definition at line 49 of file game_state.hpp.

◆ server_request_number_

int game_state::server_request_number_

Definition at line 66 of file game_state.hpp.

Referenced by write().

◆ start_event_fired_

bool game_state::start_event_fired_

Definition at line 64 of file game_state.hpp.

Referenced by play_controller::start_game().

◆ tod_manager_

tod_manager game_state::tod_manager_

◆ undo_stack_

const std::unique_ptr<actions::undo_list> game_state::undo_stack_

undo_stack_ is never nullptr.

It is implemented as a pointer so that undo_list can be an incomplete type at this point (which reduces the number of files that depend on actions/undo.hpp).

Definition at line 56 of file game_state.hpp.

Referenced by write().


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