blob: 8bda17914bcced2209f0254132d58987daa5c631 (
plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
package ch.asynk.tankontank.engine;
import java.util.List;
import java.util.ArrayList;
import java.util.Random;
import java.util.Iterator;
import ch.asynk.tankontank.engine.Pawn;
public abstract class Player
{
public Faction faction;
public ArrayList<Pawn> units;
public ArrayList<Pawn> casualties;
public ArrayList<Pawn> reinforcement;
public abstract void turnEnd();
public abstract void turnStart();
public Player(Faction faction, int n)
{
this.faction = faction;
this.units = new ArrayList<Pawn>(n);
this.casualties = new ArrayList<Pawn>(n);
this.reinforcement = new ArrayList<Pawn>(n);
}
public String getName()
{
return faction.toString();
}
public boolean is(Faction faction)
{
return (this.faction == faction);
}
public boolean isEnemy(Pawn pawn)
{
return pawn.isEnemy(faction);
}
public boolean isEnemy(Faction other)
{
return faction.isEnemy(other);
}
public int unitsLeft()
{
return (units.size() + reinforcement.size());
}
public int reinforcement()
{
return reinforcement.size();
}
public int casualties()
{
return casualties.size();
}
public void addUnit(Pawn pawn)
{
units.add(pawn);
}
public void addReinforcement(Pawn pawn)
{
reinforcement.add(pawn);
}
public void unitEntry(Pawn pawn)
{
reinforcement.remove(pawn);
units.add(pawn);
}
public void revertUnitEntry(Pawn pawn)
{
units.remove(pawn);
reinforcement.add(pawn);
}
public void casualty(Pawn pawn)
{
units.remove(pawn);
casualties.add(pawn);
}
}
|