-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathsuperdogPlayer.java
79 lines (62 loc) · 2.41 KB
/
superdogPlayer.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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;
/**
* Created by : AceMurder
* Created on : 2017/11/6
* Created for : Games.
* Enjoy it !!!!
*/
public class superdogPlayer implements Player {
@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 (isSamePoint(pokers))
return (int) (3 * moneyYouNeedToPayLeast);
if (isSameColor(pokers))
return (int) moneyYouNeedToPayLeast;
if ((isSameColorStraight(pokers)))
return (int)(2.5 * moneyYouNeedToPayLeast);
if (moneyYouNeedToPayLeast<200)
return 200;
return 0;
}
@Override
public void onResult(int time, boolean isWin, List<Poker> pokers) {
}
@Override
public String getName() {
return "郝书逸";
}
@Override
public String getStuNum() {
return "2017213075";
}
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();
}
}