Game board class. More...
#include <game_board.hpp>
Public Member Functions | |
n_unit::id_manager & | unit_id_manager () |
game_board (const tdata_cache &tdata, const config &level) | |
virtual | ~game_board () |
virtual const std::vector< team > & | teams () const |
virtual const gamemap & | map () const |
virtual const unit_map & | units () const |
unit_map & | units () |
virtual const std::vector < std::string > & | hidden_label_categories () const |
game_board (const game_board &other) | |
game_board & | operator= (game_board other) |
void | write_config (config &cfg) const |
void | new_turn (int pnum) |
void | end_turn (int pnum) |
void | set_all_units_user_end_turn () |
void | heal_all_survivors () |
void | check_victory (bool &, bool &, bool &, bool &, std::set< unsigned > &, bool) |
void | side_drop_to (int side_num, team::CONTROLLER ctrl, team::PROXY_CONTROLLER proxy=team::PROXY_CONTROLLER::PROXY_HUMAN) |
void | side_change_controller (int side_num, bool is_local, const std::string &pname="") |
bool | try_add_unit_to_recall_list (const map_location &loc, const unit_ptr u) |
boost::optional< std::string > | replace_map (const gamemap &r) |
void | overlay_map (const gamemap &o, const config &cfg, map_location loc, bool border) |
bool | change_terrain (const map_location &loc, const std::string &t, const std::string &mode, bool replace_if_failed) |
unit_map::iterator | find_visible_unit (const map_location &loc, const team ¤t_team, bool see_all=false) |
unit_map::iterator | find_visible_unit (const map_location &loc, size_t team, bool see_all=false) |
bool | has_visible_unit (const map_location &loc, const team &team, bool see_all=false) const |
bool | has_visible_unit (const map_location &loc, size_t team, bool see_all=false) const |
unit * | get_visible_unit (const map_location &loc, const team ¤t_team, bool see_all=false) |
unit_map::iterator | find_unit (const map_location &loc) |
bool | team_is_defeated (const team &t) const |
Calculates whether a team is defeated. More... | |
Public Member Functions inherited from display_context | |
std::vector< std::string > & | hidden_label_categories_ref () |
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 unit * | get_visible_unit (const map_location &loc, const team ¤t_team, bool see_all=false) const |
bool | unit_can_move (const unit &u) const |
Will return true iff the unit u has any possible moves it can do (including attacking etc). More... | |
int | village_owner (const map_location &loc) const |
Given the location of a village, will return the 0-based index of the team that currently owns it, and -1 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 |
team_data | calculate_team_data (const class team &tm, int side) const |
bool | is_observer () const |
Check if we are an observer in this game. More... | |
virtual | ~display_context () |
Private Attributes | |
std::vector< team > | teams_ |
std::vector< std::string > | labels_ |
boost::scoped_ptr< gamemap > | map_ |
n_unit::id_manager | unit_id_manager_ |
unit_map | units_ |
Friends | |
class | play_controller |
class | events::mouse_handler |
class | events::menu_handler |
class | game_state |
class | game_lua_kernel |
struct | temporary_unit_placer |
Temporary unit move structs: More... | |
struct | temporary_unit_mover |
struct | temporary_unit_remover |
void | swap (game_board &one, game_board &other) |
Game board class.
The purpose of this class is to encapsulate some of the core game logic, including the unit map, the list of teams, and the game map.
This should eventually become part of the game state object IMO, which should be a child of play_controller.
I also intend to move the pathfinding module to be housed within this class – this way, we can implement a sound pathfinding data structure to speed up path computations for AI, without having to make "update event" code at all points in the engine which modify the relevant data.
Definition at line 55 of file game_board.hpp.
game_board::game_board | ( | const tdata_cache & | tdata, |
const config & | level | ||
) |
Definition at line 36 of file game_board.cpp.
|
virtual |
Definition at line 50 of file game_board.cpp.
game_board::game_board | ( | const game_board & | other | ) |
Definition at line 44 of file game_board.cpp.
bool game_board::change_terrain | ( | const map_location & | loc, |
const std::string & | t, | ||
const std::string & | mode, | ||
bool | replace_if_failed | ||
) |
Definition at line 298 of file game_board.cpp.
References terrain_type_data::BASE, terrain_type_data::BOTH, preferences::encountered_terrains(), map_, t_translation::NONE_TERRAIN, terrain_type_data::OVERLAY, t_translation::read_terrain_code(), teams_, gui2::terrain, and display_context::village_owner().
Referenced by game_lua_kernel::intf_set_terrain().
void game_board::check_victory | ( | bool & | continue_level, |
bool & | found_player, | ||
bool & | found_network_player, | ||
bool & | cleared_villages, | ||
std::set< unsigned > & | not_defeated, | ||
bool | remove_from_carryover_on_defeat | ||
) |
Definition at line 101 of file game_board.cpp.
References DBG_EE, team::defeat_condition(), i, teams(), teams_, and units().
Referenced by play_controller::check_victory().
Definition at line 77 of file game_board.cpp.
Referenced by play_controller::finish_side_turn().
|
inline |
Definition at line 149 of file game_board.hpp.
References unit_map::find().
Referenced by unit_display::unit_attack().
unit_map::iterator game_board::find_visible_unit | ( | const map_location & | loc, |
const team & | current_team, | ||
bool | see_all = false |
||
) |
Definition at line 173 of file game_board.cpp.
References unit_map::end(), unit_map::find(), map_, units_, and unit_map::iterator_base< iter_types >::valid().
Referenced by actions::shroud_clearer::clear_loc(), events::menu_handler::current_unit(), game_display::draw_movement_info(), events::mouse_handler::find_unit(), get_visible_unit(), game_lua_kernel::intf_get_displayed_unit(), and SYNCED_COMMAND_HANDLER_FUNCTION().
|
inline |
Definition at line 141 of file game_board.hpp.
References find_visible_unit().
Referenced by find_visible_unit().
unit * game_board::get_visible_unit | ( | const map_location & | loc, |
const team & | current_team, | ||
bool | see_all = false |
||
) |
Definition at line 192 of file game_board.cpp.
References unit_map::end(), find_visible_unit(), and units_.
Referenced by wb::move::check_validity(), pathfind::shortest_path_calculator::cost(), game_display::display_unit_hex(), game_display::draw_hex(), pathfind::enemy_zoc(), pathfind::find_routes(), wb::future_visible_unit(), and game_display::highlight_hex().
bool game_board::has_visible_unit | ( | const map_location & | loc, |
const team & | team, | ||
bool | see_all = false |
||
) | const |
Definition at line 183 of file game_board.cpp.
References unit_map::find(), map_, units_, and unit_map::iterator_base< iter_types >::valid().
Referenced by game_state::can_recruit_on().
|
inline |
Definition at line 143 of file game_board.hpp.
References has_visible_unit().
Referenced by has_visible_unit().
void game_board::heal_all_survivors | ( | ) |
Definition at line 91 of file game_board.cpp.
References unit_map::begin(), unit_map::end(), teams_, and units_.
Referenced by playsingle_controller::play_scenario().
|
inlinevirtual |
|
inlinevirtual |
Implements display_context.
Definition at line 98 of file game_board.hpp.
References map_.
Referenced by ai::ai_default_rca::move_to_targets_phase::access_points(), actions::actor_sighted(), calculate_healing(), game_state::can_recruit_from(), game_state::can_recruit_on(), ai::ai_default_rca::move_to_targets_phase::choose_move(), actions::shroud_clearer::clear_loc(), ai::default_recruitment::recruitment::compare_cost_maps_and_update_important_hexes(), events::mouse_handler::current_unit_attacks_from(), ai::ai_default_rca::aspect_attacks_base::do_attack_analysis(), preferences::encounter_all_content(), ai::ai_default_rca::goto_phase::evaluate(), ai::ai_default_rca::move_leader_to_goals_phase::evaluate(), ai::ai_default_rca::move_leader_to_keep_phase::evaluate(), ai::ai_default_rca::retreat_phase::evaluate(), ai::ai_default_rca::move_to_targets_phase::execute(), ai::default_recruitment::recruitment::execute(), unit_creator::find_location(), pathfind::find_routes(), ai::default_ai_context_impl::find_targets(), pathfind::find_vacant_tile(), ai::ai_default_rca::get_villages_phase::find_villages(), pathfind::full_cost_map::full_cost_map(), ai::default_recruitment::recruitment::get_estimated_village_gain(), play_controller::get_map_const(), pathfind::full_cost_map::get_pair_at(), actions::get_recalls(), actions::get_recruits(), events::mouse_handler::get_route(), actions::get_sides_not_seeing(), game_state::init(), team_builder::init(), game_lua_kernel::intf_find_path(), game_lua_kernel::intf_get_map_size(), game_lua_kernel::intf_get_starting_location(), game_lua_kernel::intf_get_terrain(), game_lua_kernel::intf_get_terrain_info(), events::menu_handler::map(), game_lua_kernel::map(), pathfind::mark_route(), events::mouse_handler::mouse_motion(), ai::ai_default_rca::move_to_targets_phase::move_group(), team_builder::new_team(), wb::path_cost(), game_state::place_sides_in_preferred_locations(), team_builder::place_units(), unit_creator::post_create(), ai::readonly_context_impl::power_projection(), ai::ai_default_rca::move_to_targets_phase::rate_group(), ai::ai_default_rca::aspect_attacks_base::rate_terrain(), ai::default_ai_context_impl::rate_terrain(), events::mouse_handler::show_attack_options(), ai::move_result::test_route(), ai::default_recruitment::recruitment::update_average_local_cost(), ai::default_recruitment::recruitment::update_important_hexes(), and game_events::WML_HANDLER_FUNCTION().
Definition at line 69 of file game_board.cpp.
Referenced by play_controller::do_init_side().
game_board & game_board::operator= | ( | game_board | other | ) |
Definition at line 63 of file game_board.cpp.
References swap.
void game_board::overlay_map | ( | const gamemap & | o, |
const config & | cfg, | ||
map_location | loc, | ||
bool | border | ||
) |
Definition at line 294 of file game_board.cpp.
References map_, map_location::x, and map_location::y.
Referenced by game_events::WML_HANDLER_FUNCTION().
boost::optional< std::string > game_board::replace_map | ( | const gamemap & | r | ) |
Definition at line 258 of file game_board.cpp.
References unit_map::begin(), unit_map::end(), unit_map::erase(), gamemap::is_village(), itor, map_, gamemap::on_board(), teams_, try_add_unit_to_recall_list(), units_, and display_context::village_owner().
Referenced by game_events::WML_HANDLER_FUNCTION().
void game_board::set_all_units_user_end_turn | ( | ) |
Definition at line 85 of file game_board.cpp.
Referenced by playmp_controller::linger(), and playsingle_controller::linger().
void game_board::side_change_controller | ( | int | side_num, |
bool | is_local, | ||
const std::string & | pname = "" |
||
) |
Definition at line 213 of file game_board.cpp.
References unit_map::find_leader(), team::is_human(), team::set_current_player(), team::set_local(), teams_, units_, and unit_map::iterator_base< iter_types >::valid().
Referenced by turn_info::process_network_data().
void game_board::side_drop_to | ( | int | side_num, |
team::CONTROLLER | ctrl, | ||
team::PROXY_CONTROLLER | proxy = team::PROXY_CONTROLLER::PROXY_HUMAN |
||
) |
Definition at line 200 of file game_board.cpp.
References team::change_controller(), team::change_proxy(), unit_map::find_leader(), team::set_current_player(), team::set_local(), teams_, units_, and unit_map::iterator_base< iter_types >::valid().
Referenced by turn_info::process_network_data().
bool game_board::team_is_defeated | ( | const team & | t | ) | const |
Calculates whether a team is defeated.
Definition at line 230 of file game_board.cpp.
References team::defeat_condition(), unit_map::find_leader(), team::side(), units_, and schema_validation::valid.
Referenced by actions::get_village().
|
inlinevirtual |
Implements display_context.
Definition at line 97 of file game_board.hpp.
References teams_.
Referenced by game_state::can_recruit_from(), game_state::can_recruit_on(), playsingle_controller::check_objectives(), check_victory(), play_controller::current_team(), preferences::encounter_all_content(), play_controller::find_last_visible_team(), events::mouse_handler::get_route(), play_controller::init(), game_lua_kernel::intf_find_cost_map(), game_lua_kernel::intf_find_path(), game_lua_kernel::intf_find_reach(), play_controller::is_team_visible(), playsingle_controller::play_scenario_main_loop(), play_controller::play_turn(), turn_info::process_network_data(), playsingle_controller::show_turn_dialog(), play_controller::tab(), and events::mouse_handler::viewing_team().
bool game_board::try_add_unit_to_recall_list | ( | const map_location & | loc, |
const unit_ptr | u | ||
) |
|
inline |
Definition at line 91 of file game_board.hpp.
References unit_id_manager_.
Referenced by unit_creator::add_unit(), unit::clone(), play_controller::finish_side_turn(), synced_context::get_unit_id_diff(), actions::undo_list::redo(), and actions::undo_list::undo().
|
inlinevirtual |
Implements display_context.
Definition at line 99 of file game_board.hpp.
References units_.
Referenced by unit_creator::add_unit(), check_victory(), events::mouse_handler::cycle_units(), preferences::encounter_all_content(), unit_creator::find_location(), pathfind::find_vacant_tile(), play_controller::get_units_const(), events::mouse_handler::move_unit_along_route(), playsingle_controller::play_side_impl(), events::mouse_handler::show_attack_options(), game_state::side_can_recruit_on(), and unit_display::unit_attack().
|
inline |
Definition at line 100 of file game_board.hpp.
References units_.
Definition at line 340 of file game_board.cpp.
References config::add_child(), n_unit::id_manager::get_save_id(), i, map_, teams_, unit_id_manager_, and units_.
Referenced by game_state::write().
|
friend |
Definition at line 68 of file game_board.hpp.
|
friend |
Definition at line 67 of file game_board.hpp.
|
friend |
Definition at line 70 of file game_board.hpp.
|
friend |
Definition at line 69 of file game_board.hpp.
|
friend |
Definition at line 66 of file game_board.hpp.
|
friend |
Definition at line 56 of file game_board.cpp.
Referenced by operator=().
|
friend |
Definition at line 87 of file game_board.hpp.
|
friend |
Temporary unit move structs:
Probably don't remove these friends, this is actually fairly useful. These structs are used by:
Definition at line 86 of file game_board.hpp.
|
friend |
Definition at line 88 of file game_board.hpp.
|
private |
Definition at line 59 of file game_board.hpp.
Referenced by hidden_label_categories().
|
private |
Definition at line 61 of file game_board.hpp.
Referenced by change_terrain(), find_visible_unit(), has_visible_unit(), map(), overlay_map(), game_state::place_sides_in_preferred_locations(), replace_map(), swap(), and write_config().
|
private |
Definition at line 58 of file game_board.hpp.
Referenced by change_terrain(), check_victory(), events::mouse_handler::current_team(), play_controller::current_team(), events::mouse_handler::get_adj_enemies(), play_controller::get_teams_const(), heal_all_survivors(), game_state::init(), play_controller::init(), replace_map(), play_controller::reset_gamestate(), events::mouse_handler::show_attack_options(), side_change_controller(), side_drop_to(), swap(), teams(), events::menu_handler::teams(), game_lua_kernel::teams(), try_add_unit_to_recall_list(), events::mouse_handler::viewing_team(), and write_config().
|
private |
Definition at line 62 of file game_board.hpp.
Referenced by swap(), unit_id_manager(), and write_config().
|
private |
Definition at line 63 of file game_board.hpp.
Referenced by end_turn(), play_controller::hotkey_handler::expand_wml_commands(), events::mouse_handler::fill_weapon_choices(), events::mouse_handler::find_unit(), find_visible_unit(), get_visible_unit(), has_visible_unit(), heal_all_survivors(), play_controller::init(), events::mouse_handler::move_action(), new_turn(), replace_map(), play_controller::reset_gamestate(), events::mouse_handler::select_hex(), set_all_units_user_end_turn(), events::mouse_handler::show_attack_dialog(), side_change_controller(), side_drop_to(), swap(), team_is_defeated(), game_lua_kernel::units(), units(), events::menu_handler::units(), and write_config().