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>::iterator HeroesBegin() { return heroes.begin(); }
51 std::vector<Hero>::const_iterator HeroesBegin() const { return heroes.begin(); }
52 std::vector<Hero>::iterator HeroesEnd() { return heroes.end(); }
53 std::vector<Hero>::const_iterator HeroesEnd() const { return heroes.end(); }
54 Hero &HeroAt(int index);
55 const Hero &HeroAt(int index) const;
57 std::vector<Monster>::const_iterator MonstersBegin() const { return monsters.begin(); }
58 std::vector<Monster>::const_iterator MonstersEnd() const { return monsters.end(); }
59 Monster &MonsterAt(int index);
60 const Monster &MonsterAt(int index) const;
62 Capsule &GetCapsule() { return capsule; }
63 const Capsule &GetCapsule() const { return capsule; }
65 const PartyLayout &HeroesLayout() const { return *heroesLayout; }
66 const PartyLayout &MonstersLayout() const { return *monstersLayout; }
69 bool BeforeFirstHero() const { return activeHero < 0; }
71 void SwapHeroes(int lhs, int rhs);
72 Hero &ActiveHero() { return HeroAt(activeHero); }
73 const Hero &ActiveHero() const { return HeroAt(activeHero); }
74 bool IsActiveHero(int index) const { return index == activeHero; }
75 bool HasChosenAttackType() const;
76 bool AttackSelectionDone() const;
84 Order(Performer by, int index = 0)
85 : index(index), by(by) { }
86 AttackChoice &GetAttackChoice(Battle &) const;
87 common::Stats &GetStats(Battle &) const;
88 bool IsHero() const { return by == HERO; }
89 bool IsCapsule() const { return by == CAPSULE; }
90 bool IsMonster() const { return by == MONSTER; }
95 void CalculateAttackOrder();
97 bool AttacksFinished() const;
98 void CalculateDamage();
100 const Order &CurrentAttack() const;
101 AttackChoice &CurrentAttackAttackChoice();
102 void ClearAllAttacks();
104 void DecideMonsterAttack(Monster &);
105 void DecideCapsuleAttack();
106 void CalculateDamage(const common::Stats &attackerStats, TargetSelection &targets) const;
107 Uint16 CalculateDamage(const common::Stats &attacker, const common::Stats &defender) const;
109 bool Victory() const;
112 int ExpReward() const { return expReward; }
113 int GoldReward() const { return goldReward; }
116 const PartyLayout *heroesLayout;
117 const PartyLayout *monstersLayout;
118 std::vector<Hero> heroes;
119 std::vector<Monster> monsters;
124 std::vector<Order> attackOrder;