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

#include <game_state.hpp>

Inheritance diagram for game_state:

Public Member Functions

game_events::wmi_managerget_wml_menu_items ()
 
const game_events::wmi_managerget_wml_menu_items () const
 
 game_state (const config &level, play_controller &)
 
 ~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 in_phase (game_data::PHASE phase) const
 
template<typename... Arguments>
bool in_phase (game_data::PHASE phase, Arguments ... args) const
 
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...
 
bool has_next_scenario () const
 Checks whether this is not the last scenario (usually of a campaign) More...
 
void add_side_wml (config cfg)
 creates a new side during a game. 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...
 
bool victory_when_enemies_defeated_
 
bool remove_from_carryover_on_defeat_
 
std::optional< end_level_dataend_level_data_
 
int server_request_number_
 

Friends

class replay_controller
 

Detailed Description

Definition at line 38 of file game_state.hpp.

Constructor & Destructor Documentation

◆ game_state()

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

◆ ~game_state()

game_state::~game_state ( )

Definition at line 73 of file game_state.cpp.

Member Function Documentation

◆ add_side_wml()

void game_state::add_side_wml ( config  cfg)

creates a new side during a game.

Todo:
: maybe add parameters like id etc?

Definition at line 432 of file game_state.cpp.

References synced_context::ask_server_choice(), board_, game_board::map(), and game_board::teams().

Referenced by game_lua_kernel::intf_create_side().

◆ 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 290 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 310 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 322 of file game_state.cpp.

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

Referenced by wb::any_recruiter(), can_recruit_on(), wb::find_recruiter(), 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 363 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 85 of file game_state.hpp.

References board_.

◆ get_game_data()

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

Inherited from filter_context.

Implements filter_context.

Definition at line 97 of file game_state.hpp.

References gamedata_.

Referenced by carryover_show_gold().

◆ get_lua_kernel()

virtual game_lua_kernel* game_state::get_lua_kernel ( ) const
inlineoverridevirtual

Inherited from filter_context.

Implements filter_context.

Definition at line 103 of file game_state.hpp.

References lua_kernel_.

◆ get_tod_man()

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

Inherited from filter_context.

Implements filter_context.

Definition at line 91 of file game_state.hpp.

References tod_manager_.

Referenced by carryover_show_gold().

◆ 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 390 of file game_state.cpp.

References events_manager_.

◆ has_next_scenario()

bool game_state::has_next_scenario ( ) const

Checks whether this is not the last scenario (usually of a campaign)

Definition at line 395 of file game_state.cpp.

References gamedata_, and game_data::next_scenario().

Referenced by playmp_controller::hotkey_handler::can_execute_command(), and playmp_controller::process_network_side_drop_impl().

◆ in_phase() [1/2]

bool game_state::in_phase ( game_data::PHASE  phase) const
inline

◆ in_phase() [2/2]

template<typename... Arguments>
bool game_state::in_phase ( game_data::PHASE  phase,
Arguments ...  args 
) const
inline

Definition at line 115 of file game_state.hpp.

References in_phase().

◆ init()

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

◆ 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 213 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 368 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 41 of file game_state.hpp.

Member Data Documentation

◆ ai_manager_

ai::manager game_state::ai_manager_

Definition at line 49 of file game_state.hpp.

◆ board_

game_board game_state::board_

◆ 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 play_controller::do_healing(), game_lua_kernel::impl_game_config_get(), game_lua_kernel::impl_game_config_set(), play_controller::set_do_healing(), and write().

◆ end_level_data_

std::optional<end_level_data> game_state::end_level_data_

◆ events_manager_

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

◆ gamedata_

game_data game_state::gamedata_

◆ 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 46 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 init(), and write().

◆ remove_from_carryover_on_defeat_

bool game_state::remove_from_carryover_on_defeat_

Definition at line 62 of file game_state.hpp.

Referenced by write().

◆ reports_

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

Definition at line 47 of file game_state.hpp.

◆ server_request_number_

int game_state::server_request_number_

◆ 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 init(), play_controller::undo_stack(), and write().

◆ victory_when_enemies_defeated_

bool game_state::victory_when_enemies_defeated_

Definition at line 61 of file game_state.hpp.

Referenced by play_controller::check_victory(), and write().


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