forked from acemurder/GoldenFlower
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CcPlayer
76 lines (60 loc) · 2.47 KB
/
CcPlayer
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
package com.acemurder.game.player;
import com.acemurder.game.Manager;
import com.acemurder.game.Player;
import com.acemurder.game.Poker;
import java.util.Collections;
import java.util.List;
public class CcPlayer implements Player {
@Override
public String getName() {
return "陈材";
}
@Override
public String getStuNum() {
return "2016210515";
}
@Override
public void onGameStart(Manager manager, int totalPlayer) {
}
@Override
public int bet(int time, int round, int lastPerson, int moneyOnDesk, int moneyYouNeedToPayLeast, List<Poker> pokers) {
Collections.sort(pokers);
if (isSameColor(pokers) )
return moneyYouNeedToPayLeast * 3;
if ( (isSameColorStraight(pokers) || isSamePoint(pokers)) )
return moneyYouNeedToPayLeast * 3;
if (isPair(pokers)&&moneyYouNeedToPayLeast<1000)
return moneyYouNeedToPayLeast;
if (isStraight(pokers)&&moneyYouNeedToPayLeast<3000)
return moneyYouNeedToPayLeast;
for (Poker p : pokers){
if ( p.getPoint().getNum() >= 11&&round < 1)
return moneyYouNeedToPayLeast;
}
return 0;
}
@Override
public void onResult(int time, boolean isWin, List<Poker> pokers) {
}
private boolean isSameColor(List<Poker> pokers) {
return pokers.get(0).getSuit() == pokers.get(1).getSuit() &&
pokers.get(1).getSuit() == pokers.get(2).getSuit();
}
private boolean isPair(List<Poker> pokers) {
return pokers.get(0).getPoint().getNum() == pokers.get(1).getPoint().getNum()
|| pokers.get(1).getPoint().getNum() == pokers.get(2).getPoint().getNum()
|| pokers.get(0).getPoint().getNum() == pokers.get(2).getPoint().getNum();
}
private boolean isStraight(List<Poker> pokers) {
Collections.sort(pokers);
return Math.abs(pokers.get(0).getPoint().getNum() - pokers.get(1).getPoint().getNum()) == 1
&& Math.abs(pokers.get(1).getPoint().getNum() - pokers.get(2).getPoint().getNum()) == 1;
}
private boolean isSameColorStraight(List<Poker> handCards) {
return isSameColor(handCards) && isStraight(handCards);
}
private boolean isSamePoint(List<Poker> handCards) {
return handCards.get(0).getPoint() == handCards.get(1).getPoint()
&& handCards.get(2).getPoint() == handCards.get(1).getPoint();
}
}