1 #ifndef BATTLE_BATTLE_H_
2 #define BATTLE_BATTLE_H_
24 /// This class models a battle between a party of monsters and one
26 /// See http://luke.redirectme.net/redmine/projects/l2e/wiki/Battle for
27 /// an explanation of how to use this interface.
31 Battle(const PartyLayout *heroesLayout, const PartyLayout *monstersLayout);
34 void AddHero(const Hero &);
35 void AddMonster(const Monster &);
36 void SetCapsule(const Capsule &);
38 int NumHeroes() const;
39 int MaxHeroes() const;
40 int NumMonsters() const;
41 int MaxMonsters() const;
42 bool HasCapsule() const;
44 bool HeroPositionOccupied(int index) const;
45 bool HeroAlive(int index) const;
46 bool MonsterPositionOccupied(int index) const;
47 bool MonsterAlive(int index) const;
48 bool CapsuleAlive() const;
50 std::vector<Hero>::const_iterator HeroesBegin() const { return heroes.begin(); }
51 std::vector<Hero>::const_iterator HeroesEnd() const { return heroes.end(); }
52 Hero &HeroAt(int index);
53 const Hero &HeroAt(int index) const;
55 std::vector<Monster>::const_iterator MonstersBegin() const { return monsters.begin(); }
56 std::vector<Monster>::const_iterator MonstersEnd() const { return monsters.end(); }
57 Monster &MonsterAt(int index);
58 const Monster &MonsterAt(int index) const;
60 Capsule &GetCapsule() { return capsule; }
61 const Capsule &GetCapsule() const { return capsule; }
63 const PartyLayout &HeroesLayout() const { return *heroesLayout; }
64 const PartyLayout &MonstersLayout() const { return *monstersLayout; }
67 bool BeforeFirstHero() const { return activeHero < 0; }
69 void SwapHeroes(int lhs, int rhs);
70 Hero &ActiveHero() { return HeroAt(activeHero); }
71 const Hero &ActiveHero() const { return HeroAt(activeHero); }
72 bool IsActiveHero(int index) const { return index == activeHero; }
73 bool HasChosenAttackType() const;
74 bool AttackSelectionDone() const;
82 Order(Performer by, int index = 0)
83 : index(index), by(by) { }
84 AttackChoice &GetAttackChoice(Battle &) const;
85 common::Stats &GetStats(Battle &) const;
86 bool IsHero() const { return by == HERO; }
87 bool IsCapsule() const { return by == CAPSULE; }
88 bool IsMonster() const { return by == MONSTER; }
93 void CalculateAttackOrder();
95 bool AttacksFinished() const;
96 void CalculateDamage();
98 const Order &CurrentAttack() const;
99 AttackChoice &CurrentAttackAttackChoice();
100 void ClearAllAttacks();
102 void DecideMonsterAttack(Monster &);
103 void DecideCapsuleAttack();
104 void CalculateDamage(const common::Stats &attackerStats, TargetSelection &targets) const;
105 Uint16 CalculateDamage(const common::Stats &attacker, const common::Stats &defender) const;
107 bool Victory() const;
110 int ExpReward() const { return expReward; }
111 int GoldReward() const { return goldReward; }
114 const PartyLayout *heroesLayout;
115 const PartyLayout *monstersLayout;
116 std::vector<Hero> heroes;
117 std::vector<Monster> monsters;
122 std::vector<Order> attackOrder;