actions.hpp File Reference

Various functions which implement in-game events and commands. More...

#include "global.hpp"
#include "map.hpp"
#include "unit.hpp"
#include "unit_map.hpp"
#include "unit_types.hpp"
#include <deque>
#include <sstream>

Include dependency graph for actions.hpp:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  victory_conditions

Classes

class  battle_context
 Computes the statistics of a battle between an attacker and a defender unit. More...
struct  battle_context::unit_stats
 Structure describing the statistics of a unit involved in the battle. More...
class  attack
 Executes an attack. More...
class  attack::attack_end_exception
struct  undo_action
 Records information to be able to undo a movement. More...

Defines

#define RECRUIT_POS   -2

Typedefs

typedef std::deque< undo_actionundo_list

Functions

bool can_recruit_on (const gamemap &map, const gamemap::location &leader, const gamemap::location loc)
std::string recruit_unit (const gamemap &map, const int side, unit_map &units, unit u, gamemap::location &recruit_location, const bool is_recall, const bool show=false, const bool need_castle=true, const bool full_movement=false, const bool wml_triggered=false)
 Function which recruits a unit into the game.
int village_owner (const gamemap::location &loc, const std::vector< team > &teams)
 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.
bool get_village (const gamemap::location &loc, game_display &disp, std::vector< team > &teams, size_t team_num, const unit_map &units, int *time_bonus=NULL)
 Makes it so the village at the given location is owned by the given 0-based team number.
unit_map::iterator find_leader (unit_map &units, int side)
 Given the 1-based side, will find the leader of that side, and return an iterator to the leader.
unit_map::const_iterator find_leader (const unit_map &units, int side)
void reset_resting (unit_map &units, unsigned int side)
 Resets resting for all units on this side: should be called after calculate_healing().
void calculate_healing (game_display &disp, const gamemap &map, unit_map &units, unsigned int side, const std::vector< team > &teams, bool update_display)
 Calculates healing for all units for the given side.
unit get_advanced_unit (unit_map &units, const gamemap::location &loc, const std::string &advance_to)
 Function which, given the location of a unit that is advancing, and the name of the unit it is advancing to, Will return the advanced version of this unit.
void advance_unit (unit_map &units, gamemap::location loc, const std::string &advance_to)
 Function which will advance the unit at loc to 'advance_to'.
gamemap::location under_leadership (const unit_map &units, const gamemap::location &loc, int *bonus=NULL)
 function which tests if the unit at loc is currently affected by leadership.
void check_victory (unit_map &units, std::vector< team > &teams, display &disp)
 Checks to see if a side has won, and will throw an end_level_exception if one has.
time_of_day timeofday_at (const gamestatus &status, const unit_map &units, const gamemap::location &loc, const gamemap &map)
 Gets the time of day at a certain tile.
int combat_modifier (const gamestatus &status, const unit_map &units, const gamemap::location &loc, unit_type::ALIGNMENT alignment, bool is_fearless, const gamemap &map)
 Returns the amount that a unit's damage should be multiplied by due to the current time of day.
size_t move_unit (game_display *disp, const gamemap &map, unit_map &units, std::vector< team > &teams, std::vector< gamemap::location > steps, replay *move_recorder, undo_list *undos, gamemap::location *next_unit=NULL, bool continue_move=false, bool should_clear_shroud=true)
 function which moves a unit along the sequence of locations given by steps.
void recalculate_fog (const gamemap &map, unit_map &units, std::vector< team > &teams, int team)
 Function which recalculates the fog.
bool clear_shroud (game_display &disp, const gamemap &map, unit_map &units, std::vector< team > &teams, int team)
 Function which will clear shroud away for the given 0-based team based on current unit positions.
void apply_shroud_changes (undo_list &undos, game_display *disp, const gamemap &map, unit_map &units, std::vector< team > &teams, int team)
 Function to apply pending shroud changes in the undo stack.
bool unit_can_move (const gamemap::location &loc, const unit_map &units, const gamemap &map, const std::vector< team > &teams)
 Will return true iff the unit at 'loc' has any possible moves it can do (including attacking etc).
void victory_conditions::set_victory_when_enemies_defeated (const bool on)
void victory_conditions::set_carryover_percentage (const int percentage)
void victory_conditions::set_carryover_add (const bool add)
bool backstab_check (const gamemap::location &attacker_loc, const gamemap::location &defender_loc, const unit_map &units, const std::vector< team > &teams)
 Function to check if an attack will satisfy the requirements for backstab.


Detailed Description

Various functions which implement in-game events and commands.

Definition in file actions.hpp.


Define Documentation

#define RECRUIT_POS   -2

Definition at line 41 of file actions.hpp.

Referenced by undo_action::is_recruit().


Typedef Documentation

typedef std::deque<undo_action> undo_list

Definition at line 315 of file actions.hpp.


Function Documentation

void advance_unit ( unit_map units,
gamemap::location  loc,
const std::string &  advance_to 
)

void apply_shroud_changes ( undo_list undos,
game_display disp,
const gamemap map,
unit_map units,
std::vector< team > &  teams,
int  team 
)

bool backstab_check ( const gamemap::location attacker_loc,
const gamemap::location defender_loc,
const unit_map units,
const std::vector< team > &  teams 
)

Function to check if an attack will satisfy the requirements for backstab.

Input:

  • the location from which the attack will occur,
  • the defending unit location,
  • the list of units on the map and
  • the list of teams. The defender and opposite units should be in place already. The attacking unit doesn't need to be, but if it isn't, an external check should be made to make sure the opposite unit isn't also the attacker.

Definition at line 2518 of file actions.cpp.

References unit_map::end(), unit_map::find(), and get_adjacent_tiles().

Referenced by ai::do_attack_analysis(), and battle_context::unit_stats::unit_stats().

void calculate_healing ( game_display disp,
const gamemap map,
unit_map units,
unsigned int  side,
const std::vector< team > &  teams,
bool  update_display 
)

bool can_recruit_on ( const gamemap map,
const gamemap::location leader,
const gamemap::location  loc 
)

void check_victory ( unit_map units,
std::vector< team > &  teams,
display disp 
)

bool clear_shroud ( game_display disp,
const gamemap map,
unit_map units,
std::vector< team > &  teams,
int  team 
)

Function which will clear shroud away for the given 0-based team based on current unit positions.

Returns true if some shroud is actually cleared away.

Definition at line 1990 of file actions.cpp.

References unit_map::begin(), clear_shroud_unit(), unit_map::end(), display::labels(), game_events::pump(), recalculate_fog(), and map_labels::recalculate_shroud().

Referenced by apply_shroud_changes(), do_replay_handle(), and events::mouse_handler::left_click().

int combat_modifier ( const gamestatus status,
const unit_map units,
const gamemap::location loc,
unit_type::ALIGNMENT  alignment,
bool  is_fearless,
const gamemap map 
)

Returns the amount that a unit's damage should be multiplied by due to the current time of day.

Definition at line 1843 of file actions.cpp.

References unit_type::CHAOTIC, time_of_day::lawful_bonus, unit_type::NEUTRAL, and timeofday_at().

Referenced by battle_context::unit_stats::unit_stats().

unit_map::const_iterator find_leader ( const unit_map units,
int  side 
)

Definition at line 1532 of file actions.cpp.

References unit_map::begin(), and unit_map::end().

unit_map::iterator find_leader ( unit_map units,
int  side 
)

unit get_advanced_unit ( unit_map units,
const gamemap::location loc,
const std::string &  advance_to 
)

Function which, given the location of a unit that is advancing, and the name of the unit it is advancing to, Will return the advanced version of this unit.

(with traits and items retained).

Definition at line 1707 of file actions.cpp.

References unit::advance_to(), unit_map::end(), boost::foreach_detail_::end(), unit_map::find(), unit::get_experience(), unit::max_experience(), and unit_type_data::types().

Referenced by dialogs::advance_unit(), and advance_unit().

bool get_village ( const gamemap::location loc,
game_display disp,
std::vector< team > &  teams,
size_t  team_num,
const unit_map units,
int *  time_bonus = NULL 
)

Makes it so the village at the given location is owned by the given 0-based team number.

Returns true if getting the village triggered a mutating event.

Definition at line 1482 of file actions.cpp.

References unit_map::end(), find_leader(), and game_display::invalidate().

Referenced by do_replay_handle(), ai::find_targets(), move_unit(), ai_interface::move_unit_partial(), events::menu_handler::redo(), and events::menu_handler::undo().

size_t move_unit ( game_display disp,
const gamemap map,
unit_map units,
std::vector< team > &  teams,
std::vector< gamemap::location steps,
replay move_recorder,
undo_list undos,
gamemap::location next_unit = NULL,
bool  continue_move = false,
bool  should_clear_shroud = true 
)

void recalculate_fog ( const gamemap map,
unit_map units,
std::vector< team > &  teams,
int  team 
)

std::string recruit_unit ( const gamemap map,
const int  side,
unit_map units,
unit  u,
gamemap::location recruit_location,
const bool  is_recall,
const bool  show = false,
const bool  need_castle = true,
const bool  full_movement = false,
const bool  wml_triggered = false 
)

void reset_resting ( unit_map units,
unsigned int  side 
)

Resets resting for all units on this side: should be called after calculate_healing().

Todo:
FIXME: Try moving this to unit::new_turn, then move it above calculate_healing().

Definition at line 1543 of file actions.cpp.

References unit_map::begin(), and unit_map::end().

Referenced by play_controller::init_side().

time_of_day timeofday_at ( const gamestatus status,
const unit_map units,
const gamemap::location loc,
const gamemap map 
)

Gets the time of day at a certain tile.

Certain tiles may have a time of day that differs from 'the' time of day, if a unit that illuminates is in that tile or adjacent.

Definition at line 1811 of file actions.cpp.

References unit_map::end(), unit_map::find(), get_adjacent_tiles(), unit_abilities::effect::get_composite_value(), gamemap::get_terrain(), gamemap::get_terrain_info(), gamestatus::get_time_of_day(), unit_ability_list::highest(), and gamemap::location::valid().

Referenced by combat_modifier(), game_display::draw(), game_display::draw_report(), reports::generate_report(), and terrain_filter::match_internal().

gamemap::location under_leadership ( const unit_map units,
const gamemap::location loc,
int *  bonus = NULL 
)

function which tests if the unit at loc is currently affected by leadership.

(i.e. has a higher-level 'leadership' unit next to it). If it does, then the location of the leader unit will be returned, Otherwise gamemap::location::null_location will be returned. If 'bonus' is not NULL, the % bonus will be stored in it.

Definition at line 236 of file actions.cpp.

References unit_map::end(), unit_map::find(), unit_ability_list::highest(), and gamemap::location::null_location.

Referenced by unit_display::unit_attack(), and battle_context::unit_stats::unit_stats().

bool unit_can_move ( const gamemap::location loc,
const unit_map units,
const gamemap map,
const std::vector< team > &  teams 
)

Will return true iff the unit at 'loc' has any possible moves it can do (including attacking etc).

Definition at line 2363 of file actions.cpp.

References unit_map::end(), unit_map::find(), get_adjacent_tiles(), team::is_enemy(), and gamemap::on_board().

Referenced by events::menu_handler::end_turn(), unit::redraw_unit(), and events::mouse_handler::unit_in_cycle().

int village_owner ( const gamemap::location loc,
const std::vector< team > &  teams 
)

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.

Definition at line 1472 of file actions.cpp.

Referenced by ai::do_recruitment(), do_replay_handle(), reports::generate_report(), terrain_filter::match_internal(), move_unit(), and ai::rate_terrain().


Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs