李泽帆 2025-12-16 21:59:22 +08:00
parent 914bc3923d
commit 109fbe2324
10 changed files with 530 additions and 1682 deletions

View File

@ -3,10 +3,12 @@ package extend.pk;
public class CardObj implements Comparable<CardObj>{
public int card;
public int cardMod;
public int cardCount;
public CardObj(int card) {
this.card = card;
this.cardMod = card % 100;
this.cardCount = 1;
}
@Override

View File

@ -265,95 +265,95 @@ public class EXGameController extends GameController {
TObject param = new TObject();
TArray addPlayerList = new TArray();
int numOne = 0;
int numTwo = 0;
if (room.discard.config == CardConfig.ZHA) {
// 拿ct.card_list第一位数字
numTwo = ct.card_list.get(0).card % 100;
Jedis jediss = Redis.use("group1_db11").getJedis();
String playingGroupIdKeys = "g{" + owner.getRoom().groupId + "}:play:" + owner.getRoom().groupPid;
try {
String score = jediss.hget(playingGroupIdKeys, "hp_times");
// 循环除当前用户外的用户手牌最后一位数
for (Entry<Integer, Player> entry : room.playerMapBySeat.entrySet()) {
EXPlayer player = (EXPlayer) entry.getValue();
if (player.playerid != owner.playerid) {
// 扣分
TObject minusPlayerScoreList = new TObject();
minusPlayerScoreList.putInt("seat", player.seat);
minusPlayerScoreList.putInt("pomSore", -10 * Integer.parseInt(score) / 1000);
addPlayerList.addTObject(minusPlayerScoreList);
pb.addZhaScoreCommand(player.seat, ct, -10 * Integer.parseInt(score) / 1000);
Map<Integer, List> maps = new HashMap();
maps.put(player.seat, player.cardInhand);
// 循环
for (Entry<Integer, List> entry1 : maps.entrySet()) {
List<Integer> cardInhand = entry1.getValue();
for (int i = 0; i < cardInhand.size(); i++) {
CardObj cardObj = CardObj.class.cast(cardInhand.get(i)); // 明确获取 CardObj 对象
int cardValue = cardObj.card % 100;
cardLists.add(cardValue);
}
Map<Integer, List<Integer>> map = cardLists.stream()
.collect(Collectors.groupingBy(Integer::intValue));
for (Entry<Integer, List<Integer>> entry2 : map.entrySet()) {
if (entry2.getValue().size() == 4) {
numOne = entry2.getValue().get(0);
}
}
if (numTwo > numOne) {
cardLists.clear();
}
}
Map<Integer, List<Integer>> map = cardLists.stream()
.collect(Collectors.groupingBy(Integer::intValue));
for (Entry<Integer, List<Integer>> entry2 : map.entrySet()) {
if (entry2.getValue().size() == 4) {
numOne = entry2.getValue().get(0);
}
}
}
}
if (room.maxPlayers == 3) {
// 存储当前用户的座位号和分数
addPlayerScoreList.putInt("seat", owner.seat);
addPlayerScoreList.putInt("pomSore", 20 * Integer.parseInt(score) / 1000);
addPlayerList.addTObject(addPlayerScoreList);
pb.addZhaScoreCommand(owner.seat, ct, 20 * Integer.parseInt(score) / 1000);
} else {
// 存储当前用户的座位号和分数
addPlayerScoreList.putInt("seat", owner.seat);
addPlayerScoreList.putInt("pomSore", 10 * Integer.parseInt(score) / 1000);
addPlayerList.addTObject(addPlayerScoreList);
pb.addZhaScoreCommand(owner.seat, ct, 10 * Integer.parseInt(score) / 1000);
}
} catch (Exception e) {
Global.logger.error(e);
} finally {
jediss.close();
}
param.putTArray("PlayerScoreList", addPlayerList);
if (numTwo > numOne && room.discard.config == CardConfig.ZHA) {
owner.room.broadCastToClient(0, Config.GAME_EVT_BOMB_SCORE, param);
owner.room.broadCastToClientOfSpectator(Config.GAME_EVT_BOMB_SCORE, param);
}
}
// int numOne = 0;
// int numTwo = 0;
// if (room.discard.config == CardConfig.ZHA) {
// // 拿ct.card_list第一位数字
// numTwo = ct.card_list.get(0).card % 100;
// Jedis jediss = Redis.use("group1_db11").getJedis();
//
// String playingGroupIdKeys = "g{" + owner.getRoom().groupId + "}:play:" + owner.getRoom().groupPid;
// try {
// String score = jediss.hget(playingGroupIdKeys, "hp_times");
//
// // 循环除当前用户外的用户手牌最后一位数
// for (Entry<Integer, Player> entry : room.playerMapBySeat.entrySet()) {
// EXPlayer player = (EXPlayer) entry.getValue();
//
// if (player.playerid != owner.playerid) {
// // 扣分
// TObject minusPlayerScoreList = new TObject();
// minusPlayerScoreList.putInt("seat", player.seat);
// minusPlayerScoreList.putInt("pomSore", -10 * Integer.parseInt(score) / 1000);
// addPlayerList.addTObject(minusPlayerScoreList);
// pb.addZhaScoreCommand(player.seat, ct, -10 * Integer.parseInt(score) / 1000);
//
// Map<Integer, List> maps = new HashMap();
// maps.put(player.seat, player.cardInhand);
// // 循环
// for (Entry<Integer, List> entry1 : maps.entrySet()) {
// List<Integer> cardInhand = entry1.getValue();
// for (int i = 0; i < cardInhand.size(); i++) {
// CardObj cardObj = CardObj.class.cast(cardInhand.get(i)); // 明确获取 CardObj 对象
// int cardValue = cardObj.card % 100;
// cardLists.add(cardValue);
// }
//
// Map<Integer, List<Integer>> map = cardLists.stream()
// .collect(Collectors.groupingBy(Integer::intValue));
// for (Entry<Integer, List<Integer>> entry2 : map.entrySet()) {
//
// if (entry2.getValue().size() == 4) {
// numOne = entry2.getValue().get(0);
// }
// }
//
// if (numTwo > numOne) {
// cardLists.clear();
// }
//
// }
// Map<Integer, List<Integer>> map = cardLists.stream()
// .collect(Collectors.groupingBy(Integer::intValue));
// for (Entry<Integer, List<Integer>> entry2 : map.entrySet()) {
// if (entry2.getValue().size() == 4) {
// numOne = entry2.getValue().get(0);
// }
// }
//
// }
//
// }
//
// if (room.maxPlayers == 3) {
// // 存储当前用户的座位号和分数
// addPlayerScoreList.putInt("seat", owner.seat);
// addPlayerScoreList.putInt("pomSore", 20 * Integer.parseInt(score) / 1000);
// addPlayerList.addTObject(addPlayerScoreList);
// pb.addZhaScoreCommand(owner.seat, ct, 20 * Integer.parseInt(score) / 1000);
//
// } else {
// // 存储当前用户的座位号和分数
// addPlayerScoreList.putInt("seat", owner.seat);
// addPlayerScoreList.putInt("pomSore", 10 * Integer.parseInt(score) / 1000);
// addPlayerList.addTObject(addPlayerScoreList);
// pb.addZhaScoreCommand(owner.seat, ct, 10 * Integer.parseInt(score) / 1000);
//
// }
// } catch (Exception e) {
// Global.logger.error(e);
// } finally {
// jediss.close();
// }
// param.putTArray("PlayerScoreList", addPlayerList);
//
// if (numTwo > numOne && room.discard.config == CardConfig.ZHA) {
// owner.room.broadCastToClient(0, Config.GAME_EVT_BOMB_SCORE, param);
// owner.room.broadCastToClientOfSpectator(Config.GAME_EVT_BOMB_SCORE, param);
//
// }
//
// }
}
@ -371,7 +371,7 @@ public class EXGameController extends GameController {
cg.card_list = new ArrayList<>();
cg.config = CardConfig.ZHA;
cg.min_card = entry.getKey();
cg.len = 1;
cg.len = 4;
}
}
return cg;
@ -492,7 +492,6 @@ public class EXGameController extends GameController {
}
Collections.sort(player.cardInhand);
if (!existXingyunhao && (existGeneral || existBlack)) {
@ -599,8 +598,6 @@ public class EXGameController extends GameController {
player.black_white_rate + white_rate, maxDanPai, maxDuizi, maxSanZhang);
}
Collections.sort(player.cardInhand);
}
@ -779,10 +776,9 @@ public class EXGameController extends GameController {
obj.putInt("winscore", player.score.round_score);
player.hp_info(obj);
obj.putInt("thisboomnum", player.boomnum);
obj.putInt("piao", player.piao);
obj.putInt("roundBonusScore", player.roundBonusScore);
obj.putInt("roundCardScore", player.roundCardScore);
obj.putTArray("cards", CardUtil.toTArray(player.cardInhand));
obj.putBoolean("chuntian", player.chuntian);
obj.putTArray("handCards", CardUtil.toTArray(player.cardInhand));
obj.putTArray("outCards", CardUtil.toTArray(player.outCards));
@ -799,8 +795,6 @@ public class EXGameController extends GameController {
} finally {
jedis.close();
}
obj.putInt("daniao", player.daniaoScore);
obj.putInt("award", player.bonusScore);
// if(owner.endType == Constant.END_TYPE_ENTRUST) {
// obj.putInt("entrust", player.entrust ? 1 : 0);

View File

@ -23,7 +23,6 @@ public class EXPlayBack extends BasePlayBack{
ITArray cardInhand = CardUtil.toTArray(player.cardInhand);
obj.putTArray("hand_card", cardInhand);
obj.putInt("score", player.score.total_score);
obj.putInt("piao", player.piao);
player.hp_info(obj);
return obj;

View File

@ -3,16 +3,12 @@ package extend.pk;
import java.util.ArrayList;
import java.util.List;
import com.game.Global;
import com.game.data.Player;
import com.game.data.Room;
import com.game.data.Score;
import com.taurus.core.entity.ITObject;
import com.taurus.core.plugin.redis.Redis;
import extend.pk.uitl.CardUtil;
import redis.clients.jedis.Jedis;
/**
*
@ -20,9 +16,9 @@ import redis.clients.jedis.Jedis;
*/
public class EXPlayer extends Player {
/**默认action时间 20s*/
/** 默认action时间 20s */
public static final int DEFAULT_ACTION_TIME = 20000;
/**默认托管时间 1s*/
/** 默认托管时间 1s */
public static final int DEFAULT_ENTRUST_TIME = 1000;
/**
* 20s
@ -35,32 +31,16 @@ public class EXPlayer extends Player {
// 手牌
public List<CardObj> nextCardInhand = new ArrayList<CardObj>();
//打出的牌
// 打出的牌
public List<CardObj> outCards;
public CardGroup last_outcard;
public boolean pass;
// 放作弊场第一张牌是否关闭
public int open = 0;
/**春天 */
public boolean chuntian;
/**是否有红桃10*/
public boolean isHaveRedTen;
public SettleLog settleLog;
public int boomnum = 0;
public int piao = -1;
public int daniaoScore = 0;
public int bonusScore = 0;
public int awardScore = 0;
public boolean isChoice = false;
public int roundBonusScore = 0;// 当局彩头得分 7炸以上
public int roundCardScore = 0;// 当局牌型得分
public EXPlayer(int playerid, Room table, String session_id) {
super(playerid, table, session_id);
@ -82,12 +62,11 @@ public class EXPlayer extends Player {
public ITObject getReloadInfo() {
ITObject playerData = super.getReloadInfo();
playerData.putInt("card_size", this.cardInhand.size());
playerData.putInt("piao", this.piao);
if(last_outcard!=null) {
if (last_outcard != null) {
playerData.putTObject("last_outcard", last_outcard.toObject(false));
}
if(this.room.isplaying == false) {
if (this.room.isplaying == false) {
playerData.putTArray("cards", CardUtil.toTArray(this.cardInhand));
playerData.putTArray("handCards", CardUtil.toTArray(this.cardInhand));
@ -95,7 +74,6 @@ public class EXPlayer extends Player {
playerData.putInt("score", score.total_score);
playerData.putInt("winscore", score.round_score);
playerData.putInt("thisboomnum", boomnum);
playerData.putInt("open", open);
}
return playerData;
@ -108,7 +86,6 @@ public class EXPlayer extends Player {
return playerData;
}
public void clear() {
super.clear();
@ -121,13 +98,9 @@ public class EXPlayer extends Player {
this.outCards.clear();
this.last_outcard = null;
this.pass = false;
this.chuntian =false;
this.isHaveRedTen=false;
this.open = 0;
this.boomnum = 0;
this.piao = -1;
this.daniaoScore = 0;
this.isChoice=false;
this.roundBonusScore = 0;
this.roundCardScore = 0;
}
public EXRoom getRoom() {

View File

@ -35,8 +35,6 @@ public class EXRoom extends Room {
public Map<Integer, CardConfig> card_config_map;
public int piaoCount = 0;
public List<List<CardObj>> supCards;
public List<CardObj> targetCards;
public int adminSeat = 0;
@ -46,15 +44,12 @@ public class EXRoom extends Room {
public EXRoom(String roomid, Map<String, String> redis_room_map) {
super(roomid, redis_room_map);
card = new RoomCard(this, this.config.getInt(Config.ROOM_CONFIG_CARDNUM) == 1 ? 15 : 16, maxPlayers);
card = new RoomCard(this, 52, maxPlayers);
card_config_map = new HashMap<Integer, CardConfig>();
card_config_map.put(CardConfig.DAN.type, CardConfig.DAN);
card_config_map.put(CardConfig.DUIZI.type, CardConfig.DUIZI);
card_config_map.put(CardConfig.ZHA.type, CardConfig.ZHA);
this.isEntrust = true;
this.supCards = new ArrayList<>();
@ -126,10 +121,8 @@ public class EXRoom extends Room {
// }
//
score = score * this.hpData.getInt("times") / 1000;
destPlayer.score.round_log.put(type, destPlayer.score.round_log.get(type) + score);
fromPlayer.score.round_log.put(type, fromPlayer.score.round_log.get(type) - score);
destPlayer.score.round_score += score;
@ -137,8 +130,6 @@ public class EXRoom extends Room {
fromPlayer.score.round_score -= score;
fromPlayer.score.total_score -= score;
}
/**
@ -149,7 +140,6 @@ public class EXRoom extends Room {
public void addAllBombScore(EXPlayer destPlayer) {
destPlayer.settleLog.add(Config.SETTLE_BOMB_COUNT);
destPlayer.boomnum++;
TArray seatData = TArray.newInstance();
for (Entry<Integer, Player> entry : this.playerMapByPlaying.entrySet()) {
@ -176,62 +166,22 @@ public class EXRoom extends Room {
*
* @param destPlayer
*/
public void addAllScore(Player destPlayer) {
public void addAllScore(Player destPlayer) {
// 将目标玩家转换为扩展玩家类型
EXPlayer dp = (EXPlayer) destPlayer;
// 标记是否有玩家达到春天条件
boolean bSpring = false;
// 遍历所有参与游戏的玩家
for (Entry<Integer, Player> entry : this.playerMapByPlaying.entrySet()) {
// 将当前玩家转换为扩展玩家类型
EXPlayer fromPlayer = (EXPlayer) entry.getValue();
// 确保当前玩家不是目标玩家
if (fromPlayer != destPlayer) {
// 检查当前玩家手中是否有超过一张牌
if (fromPlayer.cardInhand.size() > 1) {
// 计算基础分数
int size = fromPlayer.cardInhand.size();
int score = size;
// 计算出牌数量
int outCard = (this.config.getInt(Config.ROOM_CONFIG_CARDNUM) == 1 ? 15 : 16) - size;
// 检查是否达到春天条件
if (size == (this.config.getInt(Config.ROOM_CONFIG_CARDNUM) == 1 ? 15 : 16)) {
fromPlayer.chuntian = true;
score = size * 2;
bSpring = true;
} else if (outCard < 2 && this.config.getInt(Config.ROOM_CONFIG_SPECIL_ADD) == 1 ) {
// 只出一张牌多10分
score += 10;
} else if (outCard < 4 && this.config.getInt(Config.ROOM_CONFIG_SPECIL_ADD) == 1 ) {
// 出2-3张牌多5分
score += 5;
}
// 加上目标玩家的飘分
if (dp.piao > 0) {
score += dp.piao;
}
// 加上当前玩家的飘分
if (fromPlayer.piao > 0) {
score += fromPlayer.piao;
}
// 更新目标玩家和当前玩家的分数
this.addScore(destPlayer, fromPlayer, score, EXScore.WIN);
}
this.addScore(destPlayer, fromPlayer, 2, EXScore.WIN);
}
}
@ -250,66 +200,8 @@ public void addAllScore(Player destPlayer) {
}
}
// // 增加玩家春天的个数
// if (bSpring) {
// dp.settleLog.add(Config.SETTLE_CHUNTIAN_COUNT);
// }
// 检查是否启用总分模式
// if (totalType()) {
// // 检查房间配置中是否设置了大鸟分,并获取设置值
// if (config.containsKey(Config.ROOM_CONFIG_DANIAO) && config.getInt(Config.ROOM_CONFIG_DANIAO) > 0) {
//
// int daniao = this.config.getInt(Config.ROOM_CONFIG_DANIAO);
// if (daniao == 1)
// daniao = 10;
// else if (daniao == 2)
// daniao = 20;
// else if (daniao == 3)
// daniao = 50;
//
// // 初始化最大总分数和最大总分出现次数
// int maxTotalScore = 0;
// int maxTotalCount = 0;
//
// // 遍历所有玩家,找出最大总分数和出现次数
// for (Entry<Integer, Player> entry : this.playerMapBySeat.entrySet()) {
//
// Player player = entry.getValue();
//
// if (player.score.total_score > maxTotalScore) {
//
// maxTotalScore = player.score.total_score;
// maxTotalCount = 1;
// } else if (player.score.total_score == maxTotalScore && maxTotalScore > 0) {
//
// maxTotalCount++;
// }
// }
//
// // 如果存在大赢家
// if (maxTotalScore > 0 && maxTotalCount > 0) {
//
// // 根据大赢家和非大赢家更新玩家分数
// for (Entry<Integer, Player> entry : this.playerMapBySeat.entrySet()) {
//
// EXPlayer player = (EXPlayer) entry.getValue();
//
// if (player.score.total_score == maxTotalScore) {
//
// player.score.total_score += daniao;
// player.daniaoScore = daniao;
// } else {
//
// player.score.total_score -= daniao * maxTotalCount;
// player.daniaoScore = -daniao * maxTotalCount;
// }
// }
// }
// }
// }
}
}
@Override
protected void roomResult() {
@ -335,13 +227,9 @@ public void addAllScore(Player destPlayer) {
obj.putInt("seat", player.seat);
obj.putInt("score", player.score.total_score);
obj.putInt("winscore", player.score.round_score);
player.hp_info(obj);
obj.putInt("thisboomnum", player.boomnum);
obj.putInt("piao", player.piao);
obj.putTArray("cards", CardUtil.toTArray(player.cardInhand));
obj.putBoolean("chuntian", player.chuntian);
obj.putTArray("handCards", CardUtil.toTArray(player.cardInhand));
obj.putTArray("outCards", CardUtil.toTArray(player.outCards));
@ -350,7 +238,6 @@ public void addAllScore(Player destPlayer) {
Jedis jedis = Redis.use("group1_db11").getJedis();
String playingGroupIdKey = "g{" + owner.groupId + "}:play:" + owner.groupPid;
try {
// int score = player.room.hpData.getInt("times") / 1000;
obj.putInt("total_score", player.score.total_score);
} catch (Exception e) {
@ -358,12 +245,7 @@ public void addAllScore(Player destPlayer) {
} finally {
jedis.close();
}
obj.putInt("daniao", player.daniaoScore);
obj.putInt("award", player.bonusScore);
// if(owner.endType == Constant.END_TYPE_ENTRUST) {
// obj.putInt("entrust", player.entrust ? 1 : 0);
// }
int jieShan = owner.hpData.getInt("JieShan");
if (owner.endType == Constant.END_TYPE_ENTRUST && player.entrust_round < jieShan) {
@ -371,7 +253,6 @@ public void addAllScore(Player destPlayer) {
}
obj.putTObject("settle_log", player.settleLog.toTObject());
// obj.putInt("total_score", player.score.total_score);
}
info.addTObject(obj);
@ -385,10 +266,6 @@ public void addAllScore(Player destPlayer) {
mp.putTArray("info", info);
mp.putInt("xipai_score", owner.xi_pai_score);
return mp;
}
@ -397,7 +274,7 @@ public void addAllScore(Player destPlayer) {
addAllScore(win);
this.chooseover = 0;
//拿结算数据
// 拿结算数据
ITObject mp = getRoomResultData(this, true);
@ -414,7 +291,7 @@ public void addAllScore(Player destPlayer) {
obj.putBoolean("entrust", player.entrust);
info.addTObject(obj);
if (player.entrust == true){
if (player.entrust == true) {
player.entrust_round++;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -186,80 +186,15 @@ public class EXPlayerDiscardState extends StateBase<EXPlayer> {
}
}
// if(owner.getRoom().firstCard != 0 && CardUtil.getCard1(owner.getRoom().firstCard, list) == null) {
// EXMainServer.gameCtr.sendPutError(owner,Config.PUT_ERROR_MUST_OUT_MIN);
// return;
// }
CardGroup ct = CardCheck.getType(list, owner.room.config);
if (ct == null) {
// if (CardCheck.isConfig4_2_and_4_3(owner.room.config)) {
// //四带三摆尾
// if (list.size() == owner.cardInhand.size()) { //最后一把
// Map<Integer, Integer> cardMap =CardUtil.getCardNumMap(list);
//
// if (ct == null) {
// if(owner.room.config.containsKey(Config.ROOM_CONFIG_SIDAI_3) && owner.room.config.getBoolean(Config.ROOM_CONFIG_SIDAI_3)) {
//// if (list.size() == 5 || list.size() == 6) {
//// ct = CardCheck.checkSiWithThree(cardMap,owner.room.config);
//// }
// if (list.size() == 5 ) {
// ct = CardCheck.checkSiWithThree(cardMap,owner.room.config);
// }
//
// }
// }
//
// if (ct != null) {
// for(CardObj cardObj : owner.cardInhand) {
// ct.card_list.add(cardObj);
// }
// ct.card_list_mp = CardUtil.toTArray(ct.card_list);
// }
// }
// }
if (ct == null) {
EXMainServer.gameCtr.sendPutError(owner, Config.PUT_ERROR_INVALID_TYPE);
return;
}
}
// 验证客户端发过来的类型
if (!CardCheck.tryType(ct, owner.cardInhand.size(), owner.room.config)) {
// tryType 判断3条a判断不出来 所以
if (!(ct.config.type == Config.TYPE_ZHA && card_list.size() == 3 &&
CardUtil.checkCard(RoomCard.CARD_A, list, 3))) {
EXMainServer.gameCtr.sendPutError(owner, Config.PUT_ERROR_INVALID_TYPE);
return;
}
}
// 如果炸弹不允许拆分则检测非炸弹和4带三的牌型看他们是否拆分了炸弹
if (ct.config.type != Config.TYPE_ZHA) {
Map<Integer, Integer> hangCardMap = CardUtil.getCardNumMap(owner.cardInhand);
Map<Integer, Integer> cardMap = CardUtil.getCardNumMap(list);
for (Map.Entry<Integer, Integer> entry : cardMap.entrySet()) {
int handNum = hangCardMap.get(entry.getKey());
// 4张牌 不能出现在处大赞的牌型中
if (handNum >= 4) {
EXMainServer.gameCtr.sendPutError(owner, Config.PUT_ERROR_BOMB_CHAI);
return;
}
}
}
doAction(owner, ct, false);
break;
@ -354,23 +289,23 @@ public class EXPlayerDiscardState extends StateBase<EXPlayer> {
outcard = CardCheck.tryCompete(room.discard, ct, room.config);
}
// 如果玩家的下家只有一张牌,玩家出单张必须是最大的
if (outcard && ct.config.type == Config.TYPE_DANPAI) {
EXPlayer playerNext = (EXPlayer) room.playerMapBySeat.get(owner.nextSeat);
if (playerNext != null && playerNext.cardInhand.size() == 1) {
Map<Integer, Integer> cardMap = CardUtil.getCardNumMap(owner.cardInhand);
for (Integer number : cardMap.keySet()) {
if (ct.min_card < number) {
EXMainServer.gameCtr.sendPutError(owner, Config.PUT_ERROR_MUST_OUT_MAX);
return;
}
}
}
}
// // 如果玩家的下家只有一张牌,玩家出单张必须是最大的
// if (outcard && ct.config.type == Config.TYPE_DANPAI) {
//
// EXPlayer playerNext = (EXPlayer) room.playerMapBySeat.get(owner.nextSeat);
// if (playerNext != null && playerNext.cardInhand.size() == 1) {
//
// Map<Integer, Integer> cardMap = CardUtil.getCardNumMap(owner.cardInhand);
// for (Integer number : cardMap.keySet()) {
//
// if (ct.min_card < number) {
//
// EXMainServer.gameCtr.sendPutError(owner, Config.PUT_ERROR_MUST_OUT_MAX);
// return;
// }
// }
// }
// }
}
if (!outcard) {
EXMainServer.gameCtr.sendPutError(owner, Config.PUT_ERROR_INVALID_TYPE);
@ -380,11 +315,6 @@ public class EXPlayerDiscardState extends StateBase<EXPlayer> {
EXMainServer.gameCtr.outCard(owner, ct);
if (owner.cardInhand.size() == 0) {
// 如果最后一手牌是炸弹 则需要添加炸弹分
if (ct.config.type == Config.TYPE_ZHA) {
room.addAllBombScore(owner);// 炸弹玩家增加积分
}
this.over(owner);
} else {
this.toNextState(owner);

View File

@ -5,12 +5,11 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import com.game.Global;
import com.taurus.core.entity.ITArray;
import com.taurus.core.entity.ITObject;
import com.taurus.core.entity.TArray;
import com.taurus.core.entity.TObject;
import extend.pk.CardGroup;
import extend.pk.CardObj;
import extend.pk.Config;
@ -38,12 +37,6 @@ public class CardCheck {
Map<Integer, List<CardObj>> cardMap = CardUtil.getCardListMap(cardInhand);
int handCardSize = cardInhand.size();
// 如果有炸弹 并且玩家手上仅剩下炸弹 就不用找了 直接出牌就可以了
cg = selectZha(cardMap, out, roomConfig);
if (cg != null && cg.card_list.size() == handCardSize) {
cg.card_list_mp = CardUtil.toTArray(cg.card_list);
return cg;
}
// 如果别的玩家出的是一张单牌,则寻找一个合适的单牌,如果找不到就用炸弹,炸弹没有则过
if (out.config.type == Config.TYPE_DANPAI) {
@ -56,7 +49,6 @@ public class CardCheck {
// 如果别的玩家出的是不能带牌的牌型(对子,顺子,连队)则寻找合适的牌型,如果找不到就用炸弹,炸弹没有则过
else if (out.config.type == Config.TYPE_DUIZI) {
CardGroup tempCg = selectWithoutCardType(handCardSize, cardMap, out, roomConfig);
if (tempCg != null) {
cg = tempCg;
@ -89,7 +81,8 @@ public class CardCheck {
* @param roomConfig
* @return
*/
private static CardGroup selectZha(Map<Integer, List<CardObj>> cardMap, CardGroup out, ITObject roomConfig) {
private static CardGroup selectZha(Map<Integer, List<CardObj>> cardMap, CardGroup out, ITObject roomConfig,
int len) {
CardGroup cg = null;
@ -100,7 +93,7 @@ public class CardCheck {
for (Map.Entry<Integer, List<CardObj>> entry : cardMap.entrySet()) {
if (entry.getValue().size() == 4 || (entry.getKey() == RoomCard.CARD_A && entry.getValue().size() == 3)) {
if (entry.getValue().size() >= 4) {
if (entry.getKey() > minValue) {
@ -108,7 +101,7 @@ public class CardCheck {
cg.config = CardConfig.ZHA;
cg.min_card = entry.getKey();
cg.len = 1;
cg.len = len;
cg.card_list = new ArrayList<>();
for (CardObj cardObj : entry.getValue()) {
@ -144,9 +137,7 @@ public class CardCheck {
List<CardObj> listCard = cardMap.get(i);
if (listCard != null && listCard.size() >= 1) {
// 如果是炸弹 并且不能拆分炸弹,则不能用它作为单牌来处理
if ((listCard.size() == 4 || (i == RoomCard.CARD_A && listCard.size() == 3))) {
} else {
cg = new CardGroup();
cg.config = CardConfig.DAN;
@ -158,18 +149,12 @@ public class CardCheck {
break;
}
}
}
} else {
for (int i = 15; i >= minValue; i--) {
List<CardObj> listCard = cardMap.get(i);
if (listCard != null && listCard.size() >= 1) {
// 如果是炸弹 并且不能拆分炸弹,则不能用它作为单牌来处理
if ((listCard.size() == 4 || (i == RoomCard.CARD_A && listCard.size() == 3))) {
} else {
cg = new CardGroup();
cg.config = CardConfig.DAN;
@ -182,7 +167,6 @@ public class CardCheck {
}
}
}
}
return cg;
}
@ -223,7 +207,7 @@ public class CardCheck {
List<CardObj> list = cardMap.get(i);
// 如果牌值对应的牌为空 或者他是炸弹,则之前找到的牌取消
if (list == null || ((list.size() == 4 || (i == RoomCard.CARD_A && list.size() == 3)))) {
if (list == null || (list.size() >= 4)) {
count = 0;
card_list.clear();
continue;
@ -290,7 +274,7 @@ public class CardCheck {
List<CardObj> list = cardMap.get(i);
// 如果牌值对应的牌为空 或者他是炸弹,则之前找到的牌取消
if (list == null || ((list.size() == 4 || (i == RoomCard.CARD_A && list.size() == 3)))) {
if (list == null || (list.size() >= 4)) {
count = 0;
card_list.clear();
continue;
@ -326,7 +310,7 @@ public class CardCheck {
for (Map.Entry<Integer, List<CardObj>> entry : reservedCardMap.entrySet()) {
int num = entry.getValue().size();
if (num == 4 || (entry.getKey() == RoomCard.CARD_A && num == 3)) {
if (num >= 4) {
CardUtil.removeCard(tem_list, entry.getValue());
}
@ -412,22 +396,12 @@ public class CardCheck {
} else if (len == 4) {
cg = checkFour(cardMap, roomConfig);
} else if (len == 5) {
// if (isConfig4_2_and_4_3(roomConfig) && getMaxCardNum(cardMap) == 4) {// 四带一
// return null;// 不能判为三带二
// }
cg = checkFive(cardMap, roomConfig, bSpecial);
} else if (len >= 5) {
cg = checkZha(cardMap, roomConfig, len);
} else {
if (bSpecial) {
}
if (cg == null) {
}
}
if (cg != null) {
for (CardObj cardObj : cardInhand) {
@ -466,7 +440,7 @@ public class CardCheck {
} else if (len == 4) {
cg = checkFour(cardMap, roomConfig);
} else if (len == 5) {
} else if (len >= 5) {
// if (isConfig4_2_and_4_3(roomConfig) && getMaxCardNum(cardMap) == 4) {// 四带一
// return null;// 不能判为三带二
@ -475,17 +449,11 @@ public class CardCheck {
if (cardInhand.size() == 5 && getMaxCardNum(cardMap) == 4) {
return null;
}
cg = checkFive(cardMap, roomConfig, bSpecial);
cg = checkZha(cardMap, roomConfig, len);
} else {
if (bSpecial) {
}
if (cg == null) {
}
}
if (cg != null) {
for (CardObj cardObj : cardInhand) {
@ -565,22 +533,21 @@ public class CardCheck {
cg.card_list = new ArrayList<>();
cg.config = CardConfig.ZHA;
cg.min_card = entry.getKey();
cg.len = 1;
cg.len = 4;
}
}
return cg;
}
private static CardGroup checkFive(Map<Integer, Integer> cardMap, ITObject roomConfig, boolean bSpecial) {
private static CardGroup checkZha(Map<Integer, Integer> cardMap, ITObject roomConfig, int len) {
CardGroup cg = null;
for (Map.Entry<Integer, Integer> entry : cardMap.entrySet()) {
if (entry.getValue() == 4) {
if (entry.getValue() >= 4) {
cg = new CardGroup();
cg.card_list = new ArrayList<>();
cg.config = CardConfig.ZHA;
cg.min_card = entry.getKey();
cg.len = 1;
cg.len = len;
}
}
@ -610,7 +577,7 @@ public class CardCheck {
cg.card_list = out_list;
cg.config = CardConfig.ZHA;
cg.min_card = entry.getKey();
cg.len = 1;
cg.len = 4;
for (CardObj cardObj : cardInhand) {
@ -722,9 +689,11 @@ public class CardCheck {
int size = cardInhand.size();
CardConfig config = other.config;
Map<Integer, List<CardObj>> cardMap = null;
Map<Integer, List<CardObj>> cardCountMap = null;
int len = other.len;
if (size >= len * config.repeat_num) {
if (len < 4) {
int min_card = other.min_card + 1;// 最小的数字是9 加一下一位玩家需要出的牌时从10开始
@ -734,7 +703,7 @@ public class CardCheck {
int count = 0;
cardMap = CardUtil.getCardListMap(cardInhand);
int max = len > 1 ? 14 : 15;
int max = 15;
for (int i = min_card; i <= max; ++i) {
List<CardObj> list = cardMap.get(i);
@ -742,7 +711,7 @@ public class CardCheck {
if (cardMap.containsKey(i) && list.size() >= config.repeat_num) {
// 不出炸牌
if (other.config.type != Config.TYPE_ZHA && list.size() >= 4) {
if (other.config.type != Config.TYPE_ZHA) {
count = 0;
card_list.clear();
continue;
@ -758,34 +727,7 @@ public class CardCheck {
ct.card_list = card_list;
ct.len = len;
ct.min_card = card_list.get(0).cardMod;
if (config.with_card_num > 0) {
List<CardObj> tem_list = new ArrayList<CardObj>();
tem_list.addAll(cardInhand);
CardUtil.removeCard(tem_list, card_list);
// 不把炸牌带出去
int rcard_size = 0;
rcard: for (int k = 0; k < tem_list.size(); ++k) {
int card = tem_list.get(k).cardMod;
List<CardObj> tem_list1 = cardMap.get(card);
if (tem_list1.size() >= 4) {
CardUtil.removeCard(tem_list, tem_list1);
rcard_size += 4;
break rcard;
}
}
int with_card_size = config.with_card_num * len;
if (rcard_size == 0) {
with_card_size = tem_list.size() < with_card_size ? tem_list.size()
: with_card_size;
}
if (tem_list.size() < with_card_size) {
break;
}
for (int k = 0; k < with_card_size; ++k) {
card_list.add(tem_list.get(k));
}
}
return ct;
}
} else {
@ -808,7 +750,51 @@ public class CardCheck {
CardGroup ct = new CardGroup();
ct.config = CardConfig.ZHA;
ct.card_list = list;
ct.len = 1;
ct.len = 4;
ct.min_card = card;
return ct;
}
}
}
// 如果上家出的是炸弹
if (other.config.type == Config.TYPE_ZHA) {
if (cardMap == null) {
cardMap = CardUtil.getCardListMap(cardInhand);
}
for (Entry<Integer, List<CardObj>> entry : cardMap.entrySet()) {
int card = entry.getKey();
List<CardObj> list = entry.getValue();
// 与上家出的炸弹牌数一致,点数大
if (list.size() == len && card > other.config.min_card_num) {
CardGroup ct = new CardGroup();
ct.config = CardConfig.ZHA;
ct.card_list = list;
ct.len = len;
ct.min_card = card;
return ct;
}
// 比上家出的炸弹牌数多
if (list.size() >= len) {
CardGroup ct = new CardGroup();
ct.config = CardConfig.ZHA;
ct.card_list = list;
ct.len = list.size();
ct.min_card = card;
return ct;
}
int sameCount = CardUtil.getSameCardCountMap(cardInhand, card);
int otherCount = 0;
if (sameCount == 4) {
otherCount = 3;
}
// 4张同花额外增加3个
if ((list.size() + otherCount) >= len && card > other.config.min_card_num) {
CardGroup ct = new CardGroup();
ct.config = CardConfig.ZHA;
ct.card_list = list;
ct.len = list.size();
ct.min_card = card;
return ct;
}

View File

@ -6,7 +6,7 @@ public enum CardConfig {
DAN("单牌", Config.TYPE_DANPAI, 1, 1, 1, 1, 0),
DUIZI("对子", Config.TYPE_DUIZI, 1, 2, 2, 2, 0),
SAN("三不带", Config.TYPE_3, 1, 3, 3, 3, 0),
ZHA("炸弹", Config.TYPE_ZHA, 1, 4, 4, 24, 0);
ZHA("炸弹", Config.TYPE_ZHA, 4, 4, 4, 24, 0);
public final int type;
public final String name;

View File

@ -1,15 +1,15 @@
package extend.pk.uitl;
import com.game.Global;
import com.taurus.core.entity.ITArray;
import com.taurus.core.entity.TArray;
import extend.pk.CardObj;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.taurus.core.entity.ITArray;
import com.taurus.core.entity.TArray;
import extend.pk.CardObj;
public class CardUtil {
/**
@ -64,263 +64,6 @@ public class CardUtil {
return false;
}
public static final boolean checkGoodCard(int eventCard, List<CardObj> cardList, int num) {
int result = 0;
for (CardObj card : cardList) {
if (card.cardMod == eventCard) {
result++;
if (result >= num)
return true;
}
}
return false;
}
public static final boolean checkShunZi(int eventCard, List<CardObj> cardList) {
int result = 0;
if (checkGoodCard(eventCard + 1, cardList, 1)) {
result++;
if (checkGoodCard(eventCard + 2, cardList, 1)) {
result++;
if (checkGoodCard(eventCard + 3, cardList, 1)) {
result++;
if (checkGoodCard(eventCard + 4, cardList, 1)) {
result++;
if (checkGoodCard(eventCard + 5, cardList, 1)) {
result++;
}
}
}
}
}
if (checkGoodCard(eventCard - 1, cardList, 1)) {
result++;
if (checkGoodCard(eventCard - 2, cardList, 1)) {
result++;
if (checkGoodCard(eventCard - 3, cardList, 1)) {
result++;
if (checkGoodCard(eventCard - 4, cardList, 1)) {
result++;
if (checkGoodCard(eventCard - 5, cardList, 1)) {
result++;
}
}
}
}
}
if (result >= 5) {
return true;
}
return false;
}
public static final boolean checkSevenShunzi(int eventCard, List<CardObj> cardList) {
int result = 0;
if (checkGoodCard(eventCard + 1, cardList, 1)) {
result++;
if (checkGoodCard(eventCard + 2, cardList, 1)) {
result++;
if (checkGoodCard(eventCard + 3, cardList, 1)) {
result++;
if (checkGoodCard(eventCard + 4, cardList, 1)) {
result++;
if (checkGoodCard(eventCard + 5, cardList, 1)) {
result++;
if (checkGoodCard(eventCard + 6, cardList, 1)) {
result++;
if (checkGoodCard(eventCard + 7, cardList, 1)) {
result++;
}
}
}
}
}
}
}
if (checkGoodCard(eventCard - 1, cardList, 1)) {
result++;
if (checkGoodCard(eventCard - 2, cardList, 1)) {
result++;
if (checkGoodCard(eventCard - 3, cardList, 1)) {
result++;
if (checkGoodCard(eventCard - 4, cardList, 1)) {
result++;
if (checkGoodCard(eventCard - 5, cardList, 1)) {
result++;
if (checkGoodCard(eventCard - 6, cardList, 1)) {
result++;
if (checkGoodCard(eventCard - 7, cardList, 1)) {
result++;
}
}
}
}
}
}
}
if (result >= 6) {
return true;
}
return false;
}
public static final boolean checkSanTiao(int eventCard, List<CardObj> cardList) {
int result = 0;
if (checkGoodCard(eventCard, cardList, 2)) {
if (checkGoodCard(eventCard, cardList, 3)) {
result++;
}
}
if (result >= 2) {
return true;
}
return false;
}
public static final boolean checkFenJi(int eventCard, List<CardObj> cardList) {
int result = 0;
if (checkGoodCard(eventCard, cardList, 2)) {
result++;
if (checkGoodCard(eventCard + 1, cardList, 3)) {
result++;
}
if (checkGoodCard(eventCard - 1, cardList, 3)) {
result++;
}
}
if (result >= 2) {
return true;
}
return false;
}
public static final boolean checkFourDui(int eventCard, List<CardObj> cardList) {
int result = 0;
if (checkGoodCard(eventCard, cardList, 1)) {
result++;
}
if (checkGoodCard(eventCard + 1, cardList, 2)) {
result++;
if (checkGoodCard(eventCard + 2, cardList, 2)) {
result++;
if (checkGoodCard(eventCard + 3, cardList, 2)) {
result++;
if (checkGoodCard(eventCard + 4, cardList, 2)) {
result++;
}
}
}
}
if (checkGoodCard(eventCard - 1, cardList, 2)) {
result++;
if (checkGoodCard(eventCard - 2, cardList, 2)) {
result++;
if (checkGoodCard(eventCard - 3, cardList, 2)) {
result++;
if (checkGoodCard(eventCard - 4, cardList, 2)) {
result++;
}
}
}
}
if (result >= 4) {
return true;
}
return false;
}
public static final boolean checkSixDui(int eventCard, List<CardObj> cardList) {
int result = 0;
if (checkGoodCard(eventCard, cardList, 1)) {
result++;
}
if (checkGoodCard(eventCard + 1, cardList, 2)) {
result++;
if (checkGoodCard(eventCard + 2, cardList, 2)) {
result++;
if (checkGoodCard(eventCard + 3, cardList, 2)) {
result++;
if (checkGoodCard(eventCard + 4, cardList, 2)) {
result++;
if (checkGoodCard(eventCard + 5, cardList, 2)) {
result++;
if (checkGoodCard(eventCard + 6, cardList, 2)) {
result++;
}
}
}
}
}
}
if (checkGoodCard(eventCard - 1, cardList, 2)) {
result++;
if (checkGoodCard(eventCard - 2, cardList, 2)) {
result++;
if (checkGoodCard(eventCard - 3, cardList, 2)) {
result++;
if (checkGoodCard(eventCard - 4, cardList, 2)) {
result++;
if (checkGoodCard(eventCard - 5, cardList, 2)) {
result++;
if (checkGoodCard(eventCard - 6, cardList, 2)) {
result++;
}
}
}
}
}
}
if (result >= 6) {
return true;
}
return false;
}
public static final boolean checkQPai(int eventCard, List<CardObj> cardList) {
int result = 0;
if (eventCard >= 12) {
result++;
for (CardObj card : cardList) {
if (card.cardMod >= 12) {
result++;
}
}
}
if (result >= 5) {
return true;
}
return false;
}
public static final boolean checkKPai(int eventCard, List<CardObj> cardList) {
int result = 0;
if (eventCard >= 14) {
result++;
for (CardObj card : cardList) {
if (card.cardMod >= 14) {
result++;
}
}
}
if (result >= 1) {
return true;
}
return false;
}
/**
* TArray to list
*
@ -406,6 +149,22 @@ public class CardUtil {
return result;
}
/**
* MAP
*
* @param cardList
* @return
*/
public static final int getSameCardCountMap(List<CardObj> cardList, int dealCard) {
int sameCard = 0;
for (CardObj card : cardList) {
if (card.card == dealCard) {
sameCard++;
}
}
return sameCard;
}
static public void removeCard(List<CardObj> cardList, List<CardObj> cards) {
for (int i = 0; i < cards.size(); i++) {
for (int j = 0; j < cardList.size(); j++) {