battle_context Class Reference

Computes the statistics of a battle between an attacker and a defender unit. More...

#include <actions.hpp>

Collaboration diagram for battle_context:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 battle_context (const gamemap &map, const std::vector< team > &teams, const unit_map &units, const gamestatus &status, const gamemap::location &attacker_loc, const gamemap::location &defender_loc, int attacker_weapon=-1, int defender_weapon=-1, double aggression=0.0, const combatant *prev_def=NULL, const unit *attacker_ptr=NULL)
 battle_context (const unit_stats &att, const unit_stats &def)
 battle_context (const battle_context &other)
 ~battle_context ()
battle_contextoperator= (const battle_context &other)
const unit_statsget_attacker_stats () const
 This method returns the statistics of the attacker.
const unit_statsget_defender_stats () const
 This method returns the statistics of the defender.
const combatantget_attacker_combatant (const combatant *prev_def=NULL)
 Get the simulation results.
const combatantget_defender_combatant (const combatant *prev_def=NULL)
bool better_attack (class battle_context &that, double harm_weight)
 Given this harm_weight, is this attack better than that?

Private Member Functions

bool better_combat (const combatant &us_a, const combatant &them_a, const combatant &us_b, const combatant &them_b, double harm_weight)
int choose_attacker_weapon (const unit &attacker, const unit &defender, const gamemap &map, const std::vector< team > &teams, const unit_map &units, const gamestatus &status, const gamemap::location &attacker_loc, const gamemap::location &defender_loc, double harm_weight, int *defender_weapon, const combatant *prev_def)
int choose_defender_weapon (const unit &attacker, const unit &defender, unsigned attacker_weapon, const gamemap &map, const std::vector< team > &teams, const unit_map &units, const gamestatus &status, const gamemap::location &attacker_loc, const gamemap::location &defender_loc, const combatant *prev_def)

Private Attributes

unit_statsattacker_stats_
unit_statsdefender_stats_
combatantattacker_combatant_
combatantdefender_combatant_

Classes

struct  unit_stats
 Structure describing the statistics of a unit involved in the battle. More...


Detailed Description

Computes the statistics of a battle between an attacker and a defender unit.

Definition at line 65 of file actions.hpp.


Constructor & Destructor Documentation

battle_context::battle_context ( const gamemap map,
const std::vector< team > &  teams,
const unit_map units,
const gamestatus status,
const gamemap::location attacker_loc,
const gamemap::location defender_loc,
int  attacker_weapon = -1,
int  defender_weapon = -1,
double  aggression = 0.0,
const combatant prev_def = NULL,
const unit attacker_ptr = NULL 
)

battle_context::battle_context ( const unit_stats att,
const unit_stats def 
)

Definition at line 313 of file actions.cpp.

battle_context::battle_context ( const battle_context other  ) 

Definition at line 307 of file actions.cpp.

battle_context::~battle_context (  ) 


Member Function Documentation

battle_context & battle_context::operator= ( const battle_context other  ) 

const unit_stats& battle_context::get_attacker_stats (  )  const [inline]

const unit_stats& battle_context::get_defender_stats (  )  const [inline]

const combatant & battle_context::get_attacker_combatant ( const combatant prev_def = NULL  ) 

Get the simulation results.

Todo:
FIXME: better to initialize combatant initially (move into unit_stats?), just do fight() when required.

Definition at line 546 of file actions.cpp.

References attacker_combatant_, attacker_stats_, defender_combatant_, defender_stats_, and combatant::fight().

Referenced by ai::attack_analysis::analyze(), and better_attack().

const combatant & battle_context::get_defender_combatant ( const combatant prev_def = NULL  ) 

bool battle_context::better_attack ( class battle_context that,
double  harm_weight 
)

Given this harm_weight, is this attack better than that?

Definition at line 737 of file actions.cpp.

References better_combat(), get_attacker_combatant(), and get_defender_combatant().

Referenced by events::mouse_handler::attack_enemy_().

bool battle_context::better_combat ( const combatant us_a,
const combatant them_a,
const combatant us_b,
const combatant them_b,
double  harm_weight 
) [private]

int battle_context::choose_attacker_weapon ( const unit attacker,
const unit defender,
const gamemap map,
const std::vector< team > &  teams,
const unit_map units,
const gamestatus status,
const gamemap::location attacker_loc,
const gamemap::location defender_loc,
double  harm_weight,
int *  defender_weapon,
const combatant prev_def 
) [private]

int battle_context::choose_defender_weapon ( const unit attacker,
const unit defender,
unsigned  attacker_weapon,
const gamemap map,
const std::vector< team > &  teams,
const unit_map units,
const gamestatus status,
const gamemap::location attacker_loc,
const gamemap::location defender_loc,
const combatant prev_def 
) [private]


Member Data Documentation


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

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