-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDealNode.java
64 lines (49 loc) · 1.47 KB
/
DealNode.java
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
import java.util.List;
import java.util.ArrayList;
public class DealNode extends SimpleGameNode {
public static final int SHARED_CARDS = -1;
private final int forPlayer;
private final List<List<Card>> deals;
private final List<Double> freqs;
public DealNode() {
this(SHARED_CARDS);
}
public DealNode(int forPlayer) {
this(forPlayer, forPlayer == SHARED_CARDS);
}
private DealNode(int forPlayer, boolean publicVis) {
super(SimpleGameNode.PLAYER_NATURE, publicVis);
this.forPlayer = forPlayer;
this.deals = new ArrayList<List<Card>>();
this.freqs = new ArrayList<Double>();
}
public boolean isHoleCards() {
return forPlayer != SHARED_CARDS;
}
public int getForPlayer() {
return forPlayer;
}
public void addChild(GameNode n, List<Card> deal, double freq) {
super.addChild(n);
deals.add(deal);
freqs.add(freq);
}
public void addChild(GameNode n) {
throw new UnsupportedOperationException("use overloaded addChild()");
}
public List<Card> getDeal(int i) {
return deals.get(i);
}
public double getFreq(int i) {
return freqs.get(i);
}
public String getChildString(int cindex) {
StringBuilder sb = new StringBuilder();
sb.append('[');
for (Card c : getDeal(cindex)) {
sb.append(c);
}
sb.append(']');
return sb.toString();
}
}