Tweak some typedefs to make unit_abilities::effect easier to work with.

This commit is contained in:
J. Tyne 2012-08-26 02:01:26 +00:00
parent e7e7f68722
commit 127b8ba098
3 changed files with 10 additions and 8 deletions

View File

@ -128,8 +128,8 @@ void calculate_healing(int side, bool update_display)
unit_abilities::effect heal_effect(heal,0,false); unit_abilities::effect heal_effect(heal,0,false);
healing = heal_effect.get_composite_value(); healing = heal_effect.get_composite_value();
for(std::vector<unit_abilities::individual_effect>::const_iterator heal_loc = heal_effect.begin(); heal_loc != heal_effect.end(); ++heal_loc) { BOOST_FOREACH (const unit_abilities::individual_effect &heal_loc, heal_effect ) {
healers.push_back(&*units.find(heal_loc->loc)); healers.push_back(&*units.find(heal_loc.loc));
} }
if (!healers.empty()) { if (!healers.empty()) {

View File

@ -162,7 +162,7 @@ void battle_prediction_pane::get_unit_strings(const battle_context_unit_stats& s
// Get the SET damage modifier, if any. // Get the SET damage modifier, if any.
const unit_abilities::individual_effect *set_dmg_effect = NULL; const unit_abilities::individual_effect *set_dmg_effect = NULL;
unit_abilities::effect_list::const_iterator i; unit_abilities::effect::const_iterator i;
for(i = dmg_effect.begin(); i != dmg_effect.end(); ++i) { for(i = dmg_effect.begin(); i != dmg_effect.end(); ++i) {
if(i->type == unit_abilities::SET) { if(i->type == unit_abilities::SET) {
set_dmg_effect = &*i; set_dmg_effect = &*i;

View File

@ -39,21 +39,23 @@ struct individual_effect
map_location loc; map_location loc;
}; };
typedef std::vector<individual_effect> effect_list;
class effect class effect
{ {
public: public:
effect(const unit_ability_list& list, int def, bool backstab); effect(const unit_ability_list& list, int def, bool backstab);
// Provide read-only access to the effect list:
typedef std::vector<individual_effect>::const_iterator iterator;
typedef std::vector<individual_effect>::const_iterator const_iterator;
int get_composite_value() const int get_composite_value() const
{ return composite_value_; } { return composite_value_; }
effect_list::const_iterator begin() const const_iterator begin() const
{ return effect_list_.begin(); } { return effect_list_.begin(); }
effect_list::const_iterator end() const const_iterator end() const
{ return effect_list_.end(); } { return effect_list_.end(); }
private: private:
effect_list effect_list_; std::vector<individual_effect> effect_list_;
int composite_value_; int composite_value_;
}; };