1 #ifndef BATTLE_BATTLE_H_
2 #define BATTLE_BATTLE_H_
26 /// This class models a battle between a party of monsters and one
28 /// See http://luke.redirectme.net/redmine/projects/l2e/wiki/Battle for
29 /// an explanation of how to use this interface.
33 Battle(const PartyLayout *heroesLayout, const PartyLayout *monstersLayout);
36 void AddHero(const Hero &);
37 void AddMonster(const Monster &);
38 void SetCapsule(const Capsule &);
40 int NumHeroes() const;
41 int MaxHeroes() const;
42 int NumMonsters() const;
43 int MaxMonsters() const;
44 bool HasCapsule() const;
46 bool HeroPositionOccupied(int index) const;
47 bool HeroAlive(int index) const;
48 bool MonsterPositionOccupied(int index) const;
49 bool MonsterAlive(int index) const;
50 bool CapsuleAlive() const;
52 std::vector<Hero>::iterator HeroesBegin() { return heroes.begin(); }
53 std::vector<Hero>::const_iterator HeroesBegin() const { return heroes.begin(); }
54 std::vector<Hero>::iterator HeroesEnd() { return heroes.end(); }
55 std::vector<Hero>::const_iterator HeroesEnd() const { return heroes.end(); }
56 Hero &HeroAt(int index);
57 const Hero &HeroAt(int index) const;
59 std::vector<Monster>::const_iterator MonstersBegin() const { return monsters.begin(); }
60 std::vector<Monster>::const_iterator MonstersEnd() const { return monsters.end(); }
61 Monster &MonsterAt(int index);
62 const Monster &MonsterAt(int index) const;
64 Capsule &GetCapsule() { return capsule; }
65 const Capsule &GetCapsule() const { return capsule; }
67 const PartyLayout &HeroesLayout() const { return *heroesLayout; }
68 const PartyLayout &MonstersLayout() const { return *monstersLayout; }
71 bool BeforeFirstHero() const { return activeHero < 0; }
73 void SwapHeroes(int lhs, int rhs);
74 Hero &ActiveHero() { return HeroAt(activeHero); }
75 const Hero &ActiveHero() const { return HeroAt(activeHero); }
76 bool IsActiveHero(int index) const { return index == activeHero; }
77 bool HasChosenAttackType() const;
78 bool AttackSelectionDone() const;
86 Order(Performer by, int index = 0)
87 : index(index), by(by) { }
88 AttackChoice &GetAttackChoice(Battle &) const;
89 common::Stats &GetStats(Battle &) const;
90 bool IsHero() const { return by == HERO; }
91 bool IsCapsule() const { return by == CAPSULE; }
92 bool IsMonster() const { return by == MONSTER; }
97 void CalculateAttackOrder();
99 bool AttacksFinished() const;
100 void CalculateDamage();
102 const Order &CurrentAttack() const;
103 AttackChoice &CurrentAttackAttackChoice();
104 void ClearAllAttacks();
106 void DecideMonsterAttack(Monster &);
107 void DecideCapsuleAttack();
108 void CalculateDamage(const common::Stats &attackerStats, TargetSelection &targets) const;
109 Uint16 CalculateDamage(const common::Stats &attacker, const common::Stats &defender) const;
111 bool Victory() const;
114 int ExpReward() const { return expReward; }
115 int GoldReward() const { return goldReward; }
118 std::vector<common::Upgrade> &);
121 const PartyLayout *heroesLayout;
122 const PartyLayout *monstersLayout;
123 std::vector<Hero> heroes;
124 std::vector<Monster> monsters;
129 std::vector<Order> attackOrder;