#include <game_state.hpp>
Public Member Functions | |
bool & | init_side_done () |
game_events::wmi_manager & | get_wml_menu_items () |
const game_events::wmi_manager & | get_wml_menu_items () const |
bool | has_human_sides () const |
game_state (const config &level, play_controller &) | |
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_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 | 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_ |
bool | init_side_done_ |
bool | start_event_fired_ |
int | server_request_number_ |
int | first_human_team_ |
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, config::child(), end_level_data_, lua_kernel_, end_level_data::read(), and end_level_data::transient.
game_state::game_state | ( | const config & | level, |
play_controller & | pc, | ||
game_board & | board | ||
) |
The third parameter is an optimisation.
Definition at line 78 of file game_state.cpp.
References transient_end_level::carryover_report, config::child(), end_level_data_, events_manager_, lua_kernel_, end_level_data::read(), and end_level_data::transient.
game_state::~game_state | ( | ) |
Definition at line 106 of file game_state.cpp.
void game_state::add_side_wml | ( | config | cfg | ) |
creates a new side during a game.
Definition at line 459 of file game_state.cpp.
References synced_context::ask_server_choice(), board_, game_board::map(), and game_board::teams().
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 321 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 341 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 353 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(), actions::find_recruit_location(), wb::side_actions::queue_action(), 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 394 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 93 of file game_state.hpp.
|
inlineoverridevirtual |
Inherited from filter_context.
Implements filter_context.
Definition at line 105 of file game_state.hpp.
Referenced by campaign_controller::show_carryover_message().
|
inlineoverridevirtual |
Inherited from filter_context.
Implements filter_context.
Definition at line 111 of file game_state.hpp.
|
inlineoverridevirtual |
Inherited from filter_context.
Implements filter_context.
Definition at line 99 of file game_state.hpp.
game_events::wmi_manager & game_state::get_wml_menu_items | ( | ) |
Definition at line 416 of file game_state.cpp.
References events_manager_.
Referenced by playsingle_controller::hotkey_handler::can_execute_command(), play_controller::hotkey_handler::do_execute_command(), and play_controller::hotkey_handler::expand_wml_commands().
const game_events::wmi_manager & game_state::get_wml_menu_items | ( | ) | const |
Definition at line 421 of file game_state.cpp.
References events_manager_.
|
inline |
Definition at line 76 of file game_state.hpp.
References utils::detail::init, game_config::images::level, and write().
Referenced by playsingle_controller::enable_replay().
void game_state::init | ( | const config & | level, |
play_controller & | pc | ||
) |
Definition at line 179 of file game_state.cpp.
References tod_manager::add_time_area(), board_, config::child_count(), config::child_range(), ERR_NG, events_manager_, first_human_team_, 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(), t, game_board::teams(), play_controller::ticks(), and tod_manager_.
|
inline |
Definition at line 70 of file game_state.hpp.
void game_state::place_sides_in_preferred_locations | ( | const config & | level | ) |
Definition at line 144 of file game_state.cpp.
References board_, config::child_range(), i, LOG_NG, game_board::map(), gamemap_base::num_valid_starting_positions(), p, placing_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 247 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 399 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 252 of file game_state.cpp.
References config::add_child(), board_, do_healing_, end_level_data_, events_manager_, gamedata_, init_side_done_, lua_kernel_, config::merge_with(), next_player_number_, pathfind_manager_, game_data::phase(), game_data::PLAY, player_number_, server_request_number_, tod_manager::to_config(), tod_manager_, undo_stack_, team::uses_shroud(), 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(), events::menu_handler::board(), can_recruit_from(), can_recruit_on(), play_controller::check_victory(), play_controller::current_team(), play_controller::do_init_side(), events::mouse_handler::find_unit(), events::mouse_handler::find_unit_nonowning(), play_controller::finish_side_turn(), events::mouse_handler::get_route(), init(), play_controller::init(), play_controller::is_team_visible(), playmp_controller::linger(), playsingle_controller::linger(), place_sides_in_preferred_locations(), playsingle_controller::play_scenario(), play_controller::reset_gamestate(), events::mouse_handler::show_attack_dialog(), lua_gui2::show_gamestate_inspector(), playsingle_controller::show_turn_dialog(), side_can_recruit_on(), events::mouse_handler::touch_motion(), events::mouse_handler::unit_in_cycle(), 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 write().
std::optional<end_level_data> game_state::end_level_data_ |
Definition at line 65 of file game_state.hpp.
Referenced by game_state(), 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(), game_state(), get_wml_menu_items(), init(), play_controller::init(), play_controller::pump(), play_controller::reset_gamestate(), lua_gui2::show_gamestate_inspector(), and write().
int game_state::first_human_team_ |
Definition at line 75 of file game_state.hpp.
Referenced by init(), playsingle_controller::init_gui(), playmp_controller::playmp_controller(), and replay_controller::update_viewing_player().
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::hotkey_handler::do_execute_command(), play_controller::do_init_side(), play_controller::hotkey_handler::expand_wml_commands(), play_controller::fire_preload(), play_controller::fire_prestart(), play_controller::fire_start(), events::menu_handler::gamedata(), init(), play_controller::init(), play_controller::init_side_begin(), play_controller::is_browsing(), playmp_controller::maybe_linger(), play_controller::reset_gamestate(), play_controller::start_game(), and write().
bool game_state::init_side_done_ |
Definition at line 66 of file game_state.hpp.
Referenced by 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(), init(), play_controller::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 69 of file game_state.hpp.
Referenced by write().
bool game_state::start_event_fired_ |
Definition at line 67 of file game_state.hpp.
Referenced by play_controller::start_game().
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(), init(), play_controller::init(), play_controller::init_side_end(), replay_controller::play_side_impl(), replay_controller::replay_next_turn(), play_controller::reset_gamestate(), 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 write().