#include <game_state.hpp>
Public Member Functions | |
game_events::wmi_manager & | get_wml_menu_items () |
const game_events::wmi_manager & | get_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_context & | get_disp_context () const override |
Inherited from filter_context. More... | |
virtual const tod_manager & | get_tod_man () const override |
Inherited from filter_context. More... | |
virtual const game_data * | get_game_data () const override |
Inherited from filter_context. More... | |
virtual game_lua_kernel * | get_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... | |
void | add_side_wml (config cfg) |
creates a new side during a game. More... | |
![]() | |
virtual | ~filter_context () |
Public Attributes | |
game_data | gamedata_ |
game_board | board_ |
tod_manager | tod_manager_ |
std::unique_ptr< pathfind::manager > | pathfind_manager_ |
const std::unique_ptr< reports > | reports_ |
std::unique_ptr< game_lua_kernel > | lua_kernel_ |
ai::manager | ai_manager_ |
const std::unique_ptr< game_events::manager > | events_manager_ |
const std::unique_ptr< actions::undo_list > | undo_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... | |
std::optional< end_level_data > | end_level_data_ |
int | server_request_number_ |
Friends | |
class | replay_controller |
Definition at line 41 of file game_state.hpp.
game_state::game_state | ( | const config & | level, |
play_controller & | pc | ||
) |
Definition at line 49 of file game_state.cpp.
References transient_end_level::carryover_report, end_level_data_, game_config::images::level, lua_kernel_, end_level_data::read(), and end_level_data::transient.
game_state::~game_state | ( | ) |
Definition at line 73 of file game_state.cpp.
void game_state::add_side_wml | ( | config | cfg | ) |
creates a new side during a game.
Definition at line 426 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().
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 288 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().
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 308 of file game_state.cpp.
References can_recruit_from(), unit::get_location(), and unit::side().
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 320 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().
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 361 of file game_state.cpp.
References can_recruit_on(), unit::get_location(), and unit::side().
|
inlineoverridevirtual |
Inherited from filter_context.
Implements filter_context.
Definition at line 86 of file game_state.hpp.
References board_.
|
inlineoverridevirtual |
Inherited from filter_context.
Implements filter_context.
Definition at line 98 of file game_state.hpp.
References gamedata_.
Referenced by carryover_show_gold().
|
inlineoverridevirtual |
Inherited from filter_context.
Implements filter_context.
Definition at line 104 of file game_state.hpp.
References lua_kernel_.
|
inlineoverridevirtual |
Inherited from filter_context.
Implements filter_context.
Definition at line 92 of file game_state.hpp.
References tod_manager_.
Referenced by carryover_show_gold().
game_events::wmi_manager & game_state::get_wml_menu_items | ( | ) |
Definition at line 383 of file game_state.cpp.
References events_manager_.
Referenced by playsingle_controller::hotkey_handler::can_execute_command(), play_controller::hotkey_handler::do_execute_command(), play_controller::hotkey_handler::expand_wml_commands(), game_lua_kernel::intf_clear_menu_item(), game_lua_kernel::intf_fire_wml_menu_item(), and game_lua_kernel::intf_set_menu_item().
const game_events::wmi_manager & game_state::get_wml_menu_items | ( | ) | const |
Definition at line 388 of file game_state.cpp.
References events_manager_.
|
inline |
Definition at line 110 of file game_state.hpp.
References gamedata_, and game_data::phase().
Referenced by in_phase(), play_controller::is_during_turn(), play_controller::is_linger_mode(), and write().
|
inline |
Definition at line 116 of file game_state.hpp.
References in_phase().
void game_state::init | ( | const config & | level, |
play_controller & | pc | ||
) |
Definition at line 146 of file game_state.cpp.
References tod_manager::add_time_area(), board_, ERR_NG, events_manager_, gamedata_, randomness::generator, game_board::get_team(), game_board::hidden_label_categories(), i, init_teams, preferences::is_ignored(), game_config::images::level, LOG_NG, lua_kernel_, game_board::map(), place_sides_in_preferred_locations(), player_number_, gui2::dialogs::loading_screen::progress(), tod_manager::resolve_random(), game_data::rng(), utf8::size(), t, game_board::teams(), play_controller::ticks(), tod_manager_, and undo_stack_.
void game_state::place_sides_in_preferred_locations | ( | const config & | level | ) |
Definition at line 111 of file game_state.cpp.
References board_, i, game_config::images::level, LOG_NG, game_board::map(), gamemap_base::num_valid_starting_positions(), p, placing_score(), placing_info::pos, placing_info::score, gamemap_base::set_starting_position(), placing_info::side, and gamemap_base::starting_position().
Referenced by init().
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().
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 366 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().
void game_state::write | ( | config & | cfg | ) | const |
Definition at line 218 of file game_state.cpp.
References config::add_child(), board_, do_healing_, end_level_data_, events_manager_, gamedata_, in_phase(), game_data::INITIAL, lua_kernel_, config::merge_with(), next_player_number_, pathfind_manager_, player_number_, game_data::PRELOAD, server_request_number_, tod_manager::to_config(), tod_manager_, undo_stack_, game_board::write_config(), and game_data::write_snapshot().
Referenced by play_controller::to_config().
|
friend |
Definition at line 44 of file game_state.hpp.
ai::manager game_state::ai_manager_ |
Definition at line 52 of file game_state.hpp.
game_board game_state::board_ |
Definition at line 47 of file game_state.hpp.
Referenced by add_side_wml(), game_lua_kernel::board(), events::menu_handler::board(), can_recruit_from(), can_recruit_on(), carryover_show_gold(), play_controller::check_victory(), play_controller::current_team(), playsingle_controller::do_end_level(), play_controller::do_init_side(), events::mouse_handler::find_unit(), events::mouse_handler::find_unit_nonowning(), play_controller::finish_side_turn_events(), get_disp_context(), play_controller::get_map(), events::mouse_handler::get_route(), play_controller::get_teams(), play_controller::get_units(), play_controller::init(), init(), play_controller::is_observer(), play_controller::is_team_visible(), playmp_controller::linger(), playsingle_controller::linger(), game_lua_kernel::map(), place_sides_in_preferred_locations(), play_controller::reset_gamestate(), events::mouse_handler::show_attack_dialog(), lua_gui2::show_gamestate_inspector(), playsingle_controller::show_turn_dialog(), side_can_recruit_on(), game_lua_kernel::teams(), events::mouse_handler::touch_motion(), events::mouse_handler::unit_in_cycle(), game_lua_kernel::units(), and write().
bool game_state::do_healing_ |
True if healing should be done at the beginning of the next side turn.
Definition at line 63 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().
std::optional<end_level_data> game_state::end_level_data_ |
Definition at line 65 of file game_state.hpp.
Referenced by carryover_show_gold(), game_state(), play_controller::get_end_level_data(), play_controller::is_regular_game_end(), play_controller::reset_end_level_data(), play_controller::set_end_level_data(), and write().
const std::unique_ptr<game_events::manager> game_state::events_manager_ |
Definition at line 53 of file game_state.hpp.
Referenced by play_controller::check_next_scenario_is_known(), get_wml_menu_items(), play_controller::init(), init(), game_lua_kernel::intf_add_event(), game_lua_kernel::intf_add_event_simple(), game_lua_kernel::intf_add_event_wml(), game_lua_kernel::intf_is_skipping_messages(), game_lua_kernel::intf_log(), game_lua_kernel::intf_remove_event(), game_lua_kernel::intf_skip_messages(), play_controller::pump(), play_controller::reset_gamestate(), lua_gui2::show_gamestate_inspector(), and write().
game_data game_state::gamedata_ |
Definition at line 46 of file game_state.hpp.
Referenced by playmp_controller::hotkey_handler::can_execute_command(), play_controller::do_init_side(), do_replay_handle(), playsingle_controller::finish_side_turn(), play_controller::fire_preload(), play_controller::fire_prestart(), play_controller::fire_start(), playsingle_controller::force_end_turn(), events::menu_handler::gamedata(), game_lua_kernel::gamedata(), get_game_data(), in_phase(), play_controller::init(), init(), play_controller::init_side_begin(), playmp_controller::maybe_linger(), playsingle_controller::play_scenario_init(), playsingle_controller::play_some(), play_controller::reset_gamestate(), playsingle_controller::sync_end_turn(), and write().
std::unique_ptr<game_lua_kernel> game_state::lua_kernel_ |
Definition at line 51 of file game_state.hpp.
Referenced by play_controller::fire_preload(), game_state(), get_lua_kernel(), play_controller::init(), init(), events::mouse_handler::mouse_motion(), play_controller::refresh_objectives(), play_controller::reset_gamestate(), events::mouse_handler::select_or_action(), set_game_display(), and write().
int game_state::next_player_number_ |
Definition at line 61 of file game_state.hpp.
Referenced by do_replay_handle(), game_lua_kernel::intf_end_turn(), and write().
std::unique_ptr<pathfind::manager> game_state::pathfind_manager_ |
Definition at line 49 of file game_state.hpp.
Referenced by play_controller::init(), play_controller::reset_gamestate(), and write().
int game_state::player_number_ |
Definition at line 60 of file game_state.hpp.
const std::unique_ptr<reports> game_state::reports_ |
Definition at line 50 of file game_state.hpp.
int game_state::server_request_number_ |
Definition at line 67 of file game_state.hpp.
Referenced by play_controller::get_server_request_number(), play_controller::increase_server_request_number(), and write().
tod_manager game_state::tod_manager_ |
Definition at line 48 of file game_state.hpp.
Referenced by play_controller::check_time_over(), play_controller::do_init_side(), get_tod_man(), play_controller::get_tod_manager(), play_controller::init(), init(), play_controller::init_side_end(), replay_controller::play_side_impl(), replay_controller::replay_next_turn(), play_controller::reset_gamestate(), game_lua_kernel::tod_man(), play_controller::turn(), and write().
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 59 of file game_state.hpp.
Referenced by init(), play_controller::undo_stack(), and write().