-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBattle.cs
27 lines (20 loc) · 919 Bytes
/
Battle.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
namespace ArenaGame {
public class BattleEnvironment(List<IAttacker> allies) {
List<IAttacker> _allies = allies;
public List<IAttacker> getAllies() { return _allies; }
}
public record Battle(IAttacker[] attackers, IAttackable[] defenders, BattleEnvironment surroundings) {
private readonly IAttacker[] _attackers = attackers;
private readonly IAttackable[] _defenders = defenders;
private readonly BattleEnvironment _surroundings = surroundings;
public void resolveBattle() {
_defenders.Shuffle();
foreach (IAttacker attacker in _attackers) {
Attack[] attacks = attacker.createAttacks(_defenders, _surroundings);
foreach (Attack attack in attacks) {
attack.getTarget().receiveAttack(attack);
}
}
}
}
}