package com.cardfgf;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.card.CardsHand;
/**
*手牌信息
* @author DESTINY
*
*/
//♦ ♣ ♥ ♠
public class FgfCardHand implements CardsHand {
public static Map<Integer,String> HAND_TYPE = new HashMap<Integer,String>();
public static int HAND_TYPE_VALUE_DSP = 1;
public static int HAND_TYPE_VALUE_DZP = 2;
public static int HAND_TYPE_VALUE_LSP = 3;
public static int HAND_TYPE_VALUE_LJP = 4;
public static int HAND_TYPE_VALUE_SJP = 5;
public static int HAND_TYPE_VALUE_BZP = 6;
static {
HAND_TYPE.put(1, "单散牌");
HAND_TYPE.put(2, "对子牌");
HAND_TYPE.put(3, "栾顺牌");
HAND_TYPE.put(4, "乱金牌");
HAND_TYPE.put(5, "顺金牌");
HAND_TYPE.put(6, "豹子牌");
}
private String playerName;
private Pokeer poker1;
private Pokeer poker2;
private Pokeer poker3;
private int cardsType;
public FgfCardHand(String playerName, Pokeer poker1, Pokeer poker2, Pokeer poker3) {
super();
this.playerName = playerName;
List<Pokeer> pokers = new ArrayList<>();
pokers.add(poker1);
pokers.add(poker2);
pokers.add(poker3);
Collections.sort(pokers);
this.poker1 = pokers.get(0);
this.poker2 = pokers.get(1);
this.poker3 = pokers.get(2);
this.cardsType = getCardsTypesFun();
}
public int getCardsTypesFun(){
//豹子
if(this.poker1.getPointValue() == this.poker2.getPointValue() && this.poker2.getPointValue() == this.poker3.getPointValue()) {
return HAND_TYPE_VALUE_BZP;
}
//金牌
if(this.poker1.getTypeValue() == this.poker2.getTypeValue() && this.poker2.getTypeValue() == this.poker3.getTypeValue()) {
//顺金
if(this.poker3.getPointValue() - this.poker2.getPointValue() == 1 && this.poker2.getPointValue() - this.poker1.getPointValue() == 1){
return HAND_TYPE_VALUE_SJP;
} else {
return HAND_TYPE_VALUE_LJP;
}
} else {
//乱顺
if(this.poker3.getPointValue() - this.poker2.getPointValue() == 1 && this.poker2.getPointValue() - this.poker1.getPointValue() == 1){
return HAND_TYPE_VALUE_LSP;
} else {
//对子
if(this.poker3.getPointValue() == this.poker2.getPointValue() || this.poker1.getPointValue() == this.poker2.getPointValue()){
return HAND_TYPE_VALUE_DZP;
//散排
} else {
return HAND_TYPE_VALUE_DSP;
}
}
}
}
@Override
public String toString() {
return this.playerName + "" + HAND_TYPE.get(this.cardsType) + "["+ this.poker1 + "," + this.poker2 + "," + this.poker3 + "]";
}
@Override
public int compareTo(CardsHand o) {
FgfCardHand cardHand = (FgfCardHand) o;
return FgfGameRuleServer.getInstance().rule(cardHand,this);
}
public String getPlayerName() {
return playerName;
}
public void setPlayerName(String playerName) {
this.playerName = playerName;
}
public Pokeer getPoker1() {
return poker1;
}
public void setPoker1(Pokeer poker1) {
this.poker1 = poker1;
}
public Pokeer getPoker2() {
return poker2;
}
public void setPoker2(Pokeer poker2) {
this.poker2 = poker2;
}
public Pokeer getPoker3() {
return poker3;
}
public void setPoker3(Pokeer poker3) {
this.poker3 = poker3;
}
public int getCardsType() {
return cardsType;
}
public static void main(String[] args) {
List<FgfCardHand> list = new ArrayList<FgfCardHand>();
for(int i = 0; i < 10; i++ ) {
String playerName = "PLAYER" + i;
int j = (int) (Math.random() * 4);
int k = (int) (Math.random() * 13);
String tp = Pokeer.TYPES[j] + Pokeer.POINTS[k];
Pokeer poker1 = new Pokeer(tp);
j = (int) (Math.random() * 4);
k = (int) (Math.random() * 13);
tp = Pokeer.TYPES[j] + Pokeer.POINTS[k];
Pokeer poker2 = new Pokeer(tp);
j = (int) (Math.random() * 4);
k = (int) (Math.random() * 13);
tp = Pokeer.TYPES[j] + Pokeer.POINTS[k];
Pokeer poker3 = new Pokeer(tp);
FgfCardHand cardHand = new FgfCardHand(playerName, poker1,poker2, poker3 );
list.add(cardHand);
}
Collections.sort(list);
for(FgfCardHand tp:list) {
System.out.println(tp);
}
}
}
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.card.CardsHand;
/**
*手牌信息
* @author DESTINY
*
*/
//♦ ♣ ♥ ♠
public class FgfCardHand implements CardsHand {
public static Map<Integer,String> HAND_TYPE = new HashMap<Integer,String>();
public static int HAND_TYPE_VALUE_DSP = 1;
public static int HAND_TYPE_VALUE_DZP = 2;
public static int HAND_TYPE_VALUE_LSP = 3;
public static int HAND_TYPE_VALUE_LJP = 4;
public static int HAND_TYPE_VALUE_SJP = 5;
public static int HAND_TYPE_VALUE_BZP = 6;
static {
HAND_TYPE.put(1, "单散牌");
HAND_TYPE.put(2, "对子牌");
HAND_TYPE.put(3, "栾顺牌");
HAND_TYPE.put(4, "乱金牌");
HAND_TYPE.put(5, "顺金牌");
HAND_TYPE.put(6, "豹子牌");
}
private String playerName;
private Pokeer poker1;
private Pokeer poker2;
private Pokeer poker3;
private int cardsType;
public FgfCardHand(String playerName, Pokeer poker1, Pokeer poker2, Pokeer poker3) {
super();
this.playerName = playerName;
List<Pokeer> pokers = new ArrayList<>();
pokers.add(poker1);
pokers.add(poker2);
pokers.add(poker3);
Collections.sort(pokers);
this.poker1 = pokers.get(0);
this.poker2 = pokers.get(1);
this.poker3 = pokers.get(2);
this.cardsType = getCardsTypesFun();
}
public int getCardsTypesFun(){
//豹子
if(this.poker1.getPointValue() == this.poker2.getPointValue() && this.poker2.getPointValue() == this.poker3.getPointValue()) {
return HAND_TYPE_VALUE_BZP;
}
//金牌
if(this.poker1.getTypeValue() == this.poker2.getTypeValue() && this.poker2.getTypeValue() == this.poker3.getTypeValue()) {
//顺金
if(this.poker3.getPointValue() - this.poker2.getPointValue() == 1 && this.poker2.getPointValue() - this.poker1.getPointValue() == 1){
return HAND_TYPE_VALUE_SJP;
} else {
return HAND_TYPE_VALUE_LJP;
}
} else {
//乱顺
if(this.poker3.getPointValue() - this.poker2.getPointValue() == 1 && this.poker2.getPointValue() - this.poker1.getPointValue() == 1){
return HAND_TYPE_VALUE_LSP;
} else {
//对子
if(this.poker3.getPointValue() == this.poker2.getPointValue() || this.poker1.getPointValue() == this.poker2.getPointValue()){
return HAND_TYPE_VALUE_DZP;
//散排
} else {
return HAND_TYPE_VALUE_DSP;
}
}
}
}
@Override
public String toString() {
return this.playerName + "" + HAND_TYPE.get(this.cardsType) + "["+ this.poker1 + "," + this.poker2 + "," + this.poker3 + "]";
}
@Override
public int compareTo(CardsHand o) {
FgfCardHand cardHand = (FgfCardHand) o;
return FgfGameRuleServer.getInstance().rule(cardHand,this);
}
public String getPlayerName() {
return playerName;
}
public void setPlayerName(String playerName) {
this.playerName = playerName;
}
public Pokeer getPoker1() {
return poker1;
}
public void setPoker1(Pokeer poker1) {
this.poker1 = poker1;
}
public Pokeer getPoker2() {
return poker2;
}
public void setPoker2(Pokeer poker2) {
this.poker2 = poker2;
}
public Pokeer getPoker3() {
return poker3;
}
public void setPoker3(Pokeer poker3) {
this.poker3 = poker3;
}
public int getCardsType() {
return cardsType;
}
public static void main(String[] args) {
List<FgfCardHand> list = new ArrayList<FgfCardHand>();
for(int i = 0; i < 10; i++ ) {
String playerName = "PLAYER" + i;
int j = (int) (Math.random() * 4);
int k = (int) (Math.random() * 13);
String tp = Pokeer.TYPES[j] + Pokeer.POINTS[k];
Pokeer poker1 = new Pokeer(tp);
j = (int) (Math.random() * 4);
k = (int) (Math.random() * 13);
tp = Pokeer.TYPES[j] + Pokeer.POINTS[k];
Pokeer poker2 = new Pokeer(tp);
j = (int) (Math.random() * 4);
k = (int) (Math.random() * 13);
tp = Pokeer.TYPES[j] + Pokeer.POINTS[k];
Pokeer poker3 = new Pokeer(tp);
FgfCardHand cardHand = new FgfCardHand(playerName, poker1,poker2, poker3 );
list.add(cardHand);
}
Collections.sort(list);
for(FgfCardHand tp:list) {
System.out.println(tp);
}
}
}