diff --git a/game_pk_duoduo/src/main/java/extend/pk/CardObj.java b/game_pk_duoduo/src/main/java/extend/pk/CardObj.java index bc2d762..e6ddb17 100644 --- a/game_pk_duoduo/src/main/java/extend/pk/CardObj.java +++ b/game_pk_duoduo/src/main/java/extend/pk/CardObj.java @@ -3,10 +3,12 @@ package extend.pk; public class CardObj implements Comparable{ public int card; public int cardMod; - + public int cardCount; + public CardObj(int card) { this.card = card; this.cardMod = card % 100; + this.cardCount = 1; } @Override diff --git a/game_pk_duoduo/src/main/java/extend/pk/EXGameController.java b/game_pk_duoduo/src/main/java/extend/pk/EXGameController.java index 4ecf7a0..8c84afb 100644 --- a/game_pk_duoduo/src/main/java/extend/pk/EXGameController.java +++ b/game_pk_duoduo/src/main/java/extend/pk/EXGameController.java @@ -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 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 maps = new HashMap(); - maps.put(player.seat, player.cardInhand); - // 循环 - for (Entry entry1 : maps.entrySet()) { - List 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> map = cardLists.stream() - .collect(Collectors.groupingBy(Integer::intValue)); - for (Entry> entry2 : map.entrySet()) { - - if (entry2.getValue().size() == 4) { - numOne = entry2.getValue().get(0); - } - } - - if (numTwo > numOne) { - cardLists.clear(); - } - - } - Map> map = cardLists.stream() - .collect(Collectors.groupingBy(Integer::intValue)); - for (Entry> 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 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 maps = new HashMap(); +// maps.put(player.seat, player.cardInhand); +// // 循环 +// for (Entry entry1 : maps.entrySet()) { +// List 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> map = cardLists.stream() +// .collect(Collectors.groupingBy(Integer::intValue)); +// for (Entry> entry2 : map.entrySet()) { +// +// if (entry2.getValue().size() == 4) { +// numOne = entry2.getValue().get(0); +// } +// } +// +// if (numTwo > numOne) { +// cardLists.clear(); +// } +// +// } +// Map> map = cardLists.stream() +// .collect(Collectors.groupingBy(Integer::intValue)); +// for (Entry> 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); diff --git a/game_pk_duoduo/src/main/java/extend/pk/EXPlayBack.java b/game_pk_duoduo/src/main/java/extend/pk/EXPlayBack.java index c9328f3..9e75958 100644 --- a/game_pk_duoduo/src/main/java/extend/pk/EXPlayBack.java +++ b/game_pk_duoduo/src/main/java/extend/pk/EXPlayBack.java @@ -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; diff --git a/game_pk_duoduo/src/main/java/extend/pk/EXPlayer.java b/game_pk_duoduo/src/main/java/extend/pk/EXPlayer.java index 1660127..18d46ed 100644 --- a/game_pk_duoduo/src/main/java/extend/pk/EXPlayer.java +++ b/game_pk_duoduo/src/main/java/extend/pk/EXPlayer.java @@ -3,91 +3,70 @@ 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; - /** * * */ public class EXPlayer extends Player { - - /**默认action时间 20s*/ - public static final int DEFAULT_ACTION_TIME = 20000; - /**默认托管时间 1s*/ - public static final int DEFAULT_ENTRUST_TIME = 1000; + + /** 默认action时间 20s */ + public static final int DEFAULT_ACTION_TIME = 20000; + /** 默认托管时间 1s */ + public static final int DEFAULT_ENTRUST_TIME = 1000; /** * 默认准备时间 20s */ - public static final int DEFAULT_READY_TIME = 20000; - + public static final int DEFAULT_READY_TIME = 20000; + // 手牌 public List cardInhand; - + // 手牌 public List nextCardInhand = new ArrayList(); - - //打出的牌 + // 打出的牌 public List 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 SettleLog settleLog; + public int roundBonusScore = 0;// 当局彩头得分 7炸以上 + public int roundCardScore = 0;// 当局牌型得分 public EXPlayer(int playerid, Room table, String session_id) { super(playerid, table, session_id); cardInhand = new ArrayList<>(); - outCards = new ArrayList<>(); - + outCards = new ArrayList<>(); + settleLog = new SettleLog(); settleLog.put(Config.SETTLE_WIN_COUNT, 0); settleLog.put(Config.SETTLE_CHUNTIAN_COUNT, 0); settleLog.put(Config.SETTLE_BOMB_COUNT, 0); settleLog.put(Config.SETTLE_MAX_SCORE, 0); } - + protected Score newScore() { return new EXScore(this); } - + @Override 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,39 +74,33 @@ 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; } - + @Override public ITObject getInfo() { ITObject playerData = super.getInfo(); playerData.putInt("score", score.total_score); return playerData; } - public void clear() { super.clear(); - + } - + public void clearEx() { - + this.score.resetRound(); this.cardInhand.clear(); 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() { diff --git a/game_pk_duoduo/src/main/java/extend/pk/EXRoom.java b/game_pk_duoduo/src/main/java/extend/pk/EXRoom.java index 02615a9..81de65b 100644 --- a/game_pk_duoduo/src/main/java/extend/pk/EXRoom.java +++ b/game_pk_duoduo/src/main/java/extend/pk/EXRoom.java @@ -35,8 +35,6 @@ public class EXRoom extends Room { public Map card_config_map; - public int piaoCount = 0; - public List> supCards; public List targetCards; public int adminSeat = 0; @@ -46,15 +44,12 @@ public class EXRoom extends Room { public EXRoom(String roomid, Map 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(); 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 entry : this.playerMapByPlaying.entrySet()) { @@ -172,144 +162,46 @@ public class EXRoom extends Room { } /** - * 变更游戏积分 - * - * @param destPlayer 目标玩家,将接收其他玩家的分数 - */ -public void addAllScore(Player destPlayer) { + * 变更游戏积分 + * + * @param destPlayer 目标玩家,将接收其他玩家的分数 + */ + public void addAllScore(Player destPlayer) { - // 将目标玩家转换为扩展玩家类型 - EXPlayer dp = (EXPlayer) destPlayer; + // 将目标玩家转换为扩展玩家类型 + EXPlayer dp = (EXPlayer) destPlayer; - // 标记是否有玩家达到春天条件 - boolean bSpring = false; - // 遍历所有参与游戏的玩家 - for (Entry entry : this.playerMapByPlaying.entrySet()) { + // 遍历所有参与游戏的玩家 + for (Entry entry : this.playerMapByPlaying.entrySet()) { - // 将当前玩家转换为扩展玩家类型 - EXPlayer fromPlayer = (EXPlayer) entry.getValue(); + // 将当前玩家转换为扩展玩家类型 + EXPlayer fromPlayer = (EXPlayer) entry.getValue(); + // 确保当前玩家不是目标玩家 + if (fromPlayer != destPlayer) { - // 确保当前玩家不是目标玩家 - if (fromPlayer != destPlayer) { + // 更新目标玩家和当前玩家的分数 + this.addScore(destPlayer, fromPlayer, 2, EXScore.WIN); + } + } - // 检查当前玩家手中是否有超过一张牌 - if (fromPlayer.cardInhand.size() > 1) { + // 设置玩家的当初最大分数 + for (Entry entry : this.playerMapByPlaying.entrySet()) { + EXPlayer player = (EXPlayer) entry.getValue(); - // 计算基础分数 - int size = fromPlayer.cardInhand.size(); - int score = size; + // 为目标玩家增加胜利次数记录 + if (destPlayer == player) { + player.settleLog.add(Config.SETTLE_WIN_COUNT); + } - // 计算出牌数量 - int outCard = (this.config.getInt(Config.ROOM_CONFIG_CARDNUM) == 1 ? 15 : 16) - size; + // 更新玩家的最高分数记录 + if (player.score.round_score > player.settleLog.get(Config.SETTLE_MAX_SCORE)) { + player.settleLog.put(Config.SETTLE_MAX_SCORE, player.score.round_score); + } + } - // 检查是否达到春天条件 - 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); - } - } - } - - // 设置玩家的当初最大分数 - for (Entry entry : this.playerMapByPlaying.entrySet()) { - EXPlayer player = (EXPlayer) entry.getValue(); - - // 为目标玩家增加胜利次数记录 - if (destPlayer == player) { - player.settleLog.add(Config.SETTLE_WIN_COUNT); - } - - // 更新玩家的最高分数记录 - if (player.score.round_score > player.settleLog.get(Config.SETTLE_MAX_SCORE)) { - player.settleLog.put(Config.SETTLE_MAX_SCORE, player.score.round_score); - } - } - -// // 增加玩家春天的个数 -// 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 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 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++; } } diff --git a/game_pk_duoduo/src/main/java/extend/pk/RoomCard.java b/game_pk_duoduo/src/main/java/extend/pk/RoomCard.java index efc11e9..3917078 100644 --- a/game_pk_duoduo/src/main/java/extend/pk/RoomCard.java +++ b/game_pk_duoduo/src/main/java/extend/pk/RoomCard.java @@ -68,34 +68,33 @@ public class RoomCard { } private void initCard() { - for (int index = 3; index <= 13; index++) { + for (int i = 0; i < 4; i++) { + for (int index = 3; index <= 13; index++) { - if (!(index == 13 && this.num == 15)) { - // 方片 this.cardList.add(new CardObj(100 + index)); + // 梅花 + this.cardList.add(new CardObj(200 + index)); + // 红桃 + this.cardList.add(new CardObj(300 + index)); + // 黑桃 + this.cardList.add(new CardObj(400 + index)); } - // 梅花 - this.cardList.add(new CardObj(200 + index)); - // 红桃 - this.cardList.add(new CardObj(300 + index)); - // 黑桃 - this.cardList.add(new CardObj(400 + index)); } - if (this.num == 16) { - this.cardList.add(new CardObj(214)); - this.cardList.add(new CardObj(314)); - this.cardList.add(new CardObj(414)); + // 增加8张大小王 + this.cardList.add(new CardObj(500 + 1)); + this.cardList.add(new CardObj(500 + 1)); + this.cardList.add(new CardObj(500 + 1)); + this.cardList.add(new CardObj(500 + 1)); - this.cardList.add(new CardObj(415)); - } else { - this.cardList.add(new CardObj(214)); - this.cardList.add(new CardObj(415)); - } + this.cardList.add(new CardObj(500 + 2)); + this.cardList.add(new CardObj(500 + 2)); + this.cardList.add(new CardObj(500 + 2)); + this.cardList.add(new CardObj(500 + 2)); rand.setSeed(System.currentTimeMillis()); int len = this.cardList.size(); - for (int i = 0; i < len; i++) { + for (int i = 0; i < len - 8; i++) { int randpos = rand.nextInt(1000000000) % len; CardObj cotemp = this.cardList.get(i); @@ -105,46 +104,46 @@ public class RoomCard { } } - - public void initNextCard() { - this.nextCardList.clear(); - for (int index = 3; index <= 13; index++) { - if (!(index == 13 && this.num == 15)) { - // 方片 - this.nextCardList.add(new CardObj(100 + index)); - } - // 梅花 - this.nextCardList.add(new CardObj(200 + index)); - // 红桃 - this.nextCardList.add(new CardObj(300 + index)); - // 黑桃 - this.nextCardList.add(new CardObj(400 + index)); - } - - if (this.num == 16) { - this.nextCardList.add(new CardObj(214)); - this.nextCardList.add(new CardObj(314)); - this.nextCardList.add(new CardObj(414)); - - this.nextCardList.add(new CardObj(415)); - } else { - this.nextCardList.add(new CardObj(214)); - this.nextCardList.add(new CardObj(415)); - } - - rand.setSeed(System.currentTimeMillis()); - int len = this.nextCardList.size(); - for (int i = 0; i < len; i++) { - - int randpos = rand.nextInt(1000000000) % len; - CardObj cotemp = this.nextCardList.get(i); - - this.nextCardList.set(i, this.nextCardList.get(randpos)); - this.nextCardList.set(randpos, cotemp); - } - - } +// public void initNextCard() { +// this.nextCardList.clear(); +// for (int index = 3; index <= 13; index++) { +// +// if (!(index == 13 && this.num == 15)) { +// // 方片 +// this.nextCardList.add(new CardObj(100 + index)); +// } +// // 梅花 +// this.nextCardList.add(new CardObj(200 + index)); +// // 红桃 +// this.nextCardList.add(new CardObj(300 + index)); +// // 黑桃 +// this.nextCardList.add(new CardObj(400 + index)); +// } +// +// if (this.num == 16) { +// this.nextCardList.add(new CardObj(214)); +// this.nextCardList.add(new CardObj(314)); +// this.nextCardList.add(new CardObj(414)); +// +// this.nextCardList.add(new CardObj(415)); +// } else { +// this.nextCardList.add(new CardObj(214)); +// this.nextCardList.add(new CardObj(415)); +// } +// +// rand.setSeed(System.currentTimeMillis()); +// int len = this.nextCardList.size(); +// for (int i = 0; i < len; i++) { +// +// int randpos = rand.nextInt(1000000000) % len; +// CardObj cotemp = this.nextCardList.get(i); +// +// this.nextCardList.set(i, this.nextCardList.get(randpos)); +// this.nextCardList.set(randpos, cotemp); +// } +// +// } private void shuffle() { for (int i = 0; i < 100; i++) { @@ -155,7 +154,7 @@ public class RoomCard { for (int i = 0; i < 10000; i++) { rand.setSeed(System.currentTimeMillis()); - if(len<=0) { + if (len <= 0) { continue; } // System.out.println("len:"+len); @@ -167,7 +166,7 @@ public class RoomCard { this.cardList.set(end, co); } } - + private void shuffleNext() { for (int i = 0; i < 100; i++) { Collections.shuffle(this.nextCardList); @@ -177,7 +176,7 @@ public class RoomCard { for (int i = 0; i < 10000; i++) { rand.setSeed(System.currentTimeMillis()); - if(len<=0) { + if (len <= 0) { continue; } // System.out.println("len:"+len); @@ -194,9 +193,9 @@ public class RoomCard { CardObj card = this.cardList.remove(0); return card; } - + public CardObj nextPop() { - + CardObj card = this.nextCardList.remove(0); return card; } @@ -244,7 +243,7 @@ public class RoomCard { dealCards.add(new CardObj(303)); dealCards.add(new CardObj(214)); - }else if (seat == 3){ + } else if (seat == 3) { dealCards.add(new CardObj(109)); dealCards.add(new CardObj(209)); dealCards.add(new CardObj(309)); @@ -258,7 +257,6 @@ public class RoomCard { dealCards.add(new CardObj(314)); dealCards.add(new CardObj(113)); dealCards.add(new CardObj(112)); - dealCards.add(new CardObj(111)); dealCards.add(new CardObj(110)); } @@ -266,908 +264,238 @@ public class RoomCard { return dealCards; } - public List deal1(int seat) { - List dealCards = new ArrayList(); - - if (seat == 1) { - dealCards.add(new CardObj(414)); - dealCards.add(new CardObj(415)); - dealCards.add(new CardObj(413)); - - dealCards.add(new CardObj(404)); - dealCards.add(new CardObj(405)); - dealCards.add(new CardObj(406)); - - dealCards.add(new CardObj(104)); - dealCards.add(new CardObj(304)); - dealCards.add(new CardObj(204)); - - dealCards.add(new CardObj(103)); - dealCards.add(new CardObj(203)); - dealCards.add(new CardObj(303)); - - dealCards.add(new CardObj(115)); - dealCards.add(new CardObj(215)); - dealCards.add(new CardObj(315)); - - } else if (seat == 2) { - - dealCards.add(new CardObj(106)); - dealCards.add(new CardObj(206)); - - dealCards.add(new CardObj(107)); - dealCards.add(new CardObj(207)); - - dealCards.add(new CardObj(108)); - dealCards.add(new CardObj(208)); - - dealCards.add(new CardObj(109)); - dealCards.add(new CardObj(209)); - - dealCards.add(new CardObj(314)); - dealCards.add(new CardObj(214)); - dealCards.add(new CardObj(111)); - - dealCards.add(new CardObj(311)); - dealCards.add(new CardObj(211)); - dealCards.add(new CardObj(111)); - dealCards.add(new CardObj(110)); - - } - - return dealCards; - } - - public List deal2(int seat) { - List dealCards = new ArrayList(); - - if (seat == 1) { - dealCards.add(new CardObj(106)); - dealCards.add(new CardObj(206)); - dealCards.add(new CardObj(306)); - dealCards.add(new CardObj(105)); - dealCards.add(new CardObj(205)); - dealCards.add(new CardObj(305)); - dealCards.add(new CardObj(107)); - dealCards.add(new CardObj(108)); - - dealCards.add(new CardObj(110)); - - } else if (seat == 2) { - - dealCards.add(new CardObj(109)); - dealCards.add(new CardObj(209)); - dealCards.add(new CardObj(309)); - dealCards.add(new CardObj(110)); - dealCards.add(new CardObj(210)); - dealCards.add(new CardObj(310)); - - // dealCards.add(new CardObj(107)); - } - - return dealCards; - } - - public List deal3(int seat) { - - List dealCards = new ArrayList(); - - if (seat == 1) { - dealCards.add(new CardObj(106)); - dealCards.add(new CardObj(206)); - dealCards.add(new CardObj(306)); - - dealCards.add(new CardObj(107)); - dealCards.add(new CardObj(107)); - dealCards.add(new CardObj(107)); - - dealCards.add(new CardObj(108)); - dealCards.add(new CardObj(108)); - dealCards.add(new CardObj(108)); - - dealCards.add(new CardObj(109)); - dealCards.add(new CardObj(110)); - dealCards.add(new CardObj(111)); - dealCards.add(new CardObj(112)); - dealCards.add(new CardObj(113)); - dealCards.add(new CardObj(114)); - dealCards.add(new CardObj(215)); - } else if (seat == 2) { - - dealCards.add(new CardObj(106)); - dealCards.add(new CardObj(206)); - dealCards.add(new CardObj(306)); - - dealCards.add(new CardObj(107)); - } - - return dealCards; - } - - public List deal4(int seat) { - List dealCards = new ArrayList(); - - if (seat == 1) { - - dealCards.add(new CardObj(106)); - dealCards.add(new CardObj(206)); - dealCards.add(new CardObj(306)); - - dealCards.add(new CardObj(107)); - dealCards.add(new CardObj(207)); - dealCards.add(new CardObj(307)); - - dealCards.add(new CardObj(108)); - dealCards.add(new CardObj(208)); - dealCards.add(new CardObj(308)); - - dealCards.add(new CardObj(109)); - dealCards.add(new CardObj(209)); - dealCards.add(new CardObj(309)); - - dealCards.add(new CardObj(110)); - dealCards.add(new CardObj(210)); - dealCards.add(new CardObj(310)); - dealCards.add(new CardObj(410)); - } else if (seat == 2) { - - dealCards.add(new CardObj(106)); - dealCards.add(new CardObj(206)); - dealCards.add(new CardObj(306)); - - dealCards.add(new CardObj(107)); - } - - return dealCards; - } - - public List deal6(int seat) { - List dealCards = new ArrayList(); - - if (seat == 1) { - dealCards.add(new CardObj(103)); - dealCards.add(new CardObj(203)); - - dealCards.add(new CardObj(104)); - dealCards.add(new CardObj(204)); - - dealCards.add(new CardObj(105)); - dealCards.add(new CardObj(105)); - - dealCards.add(new CardObj(106)); - dealCards.add(new CardObj(106)); - - dealCards.add(new CardObj(107)); - dealCards.add(new CardObj(107)); - - dealCards.add(new CardObj(108)); - dealCards.add(new CardObj(108)); - - dealCards.add(new CardObj(109)); - dealCards.add(new CardObj(109)); - - dealCards.add(new CardObj(110)); - dealCards.add(new CardObj(110)); - } else if (seat == 2) { - - dealCards.add(new CardObj(106)); - dealCards.add(new CardObj(206)); - dealCards.add(new CardObj(306)); - - dealCards.add(new CardObj(107)); - } - - return dealCards; - } - - public List dealTest(int seat) { - - List dealCards = deal2(seat); - if (dealCards == null || dealCards.size() == 0) { - - dealCards = deal(); - } - - return dealCards; - } - // 发牌 public List deal(boolean room_white, boolean is_white, double room_rate, int white_black_status, double black_white_rate, double black_black_rate, int maxDanPai, int maxDuizi, int maxSanZhang) { List dealCards = new ArrayList(); shuffle(); + for (int i = 0; i < this.num; i++) { + CardObj tempCard = this.pop(); + ArrayList tempCardList = new ArrayList(); + tempCardList.add(tempCard); + dealCards.add(tempCard); + this.cardList.addAll(tempCardList); - double rand1 = Math.random() % 100 * 100; - for (int index = 0; index < this.num; index++) { - if (room_white && is_white) { - if (rand1 > room_rate) { - if (index == 0) { - if (maxDanPai == 0) { - Global.logger.info("dealcards rand card"); - } else { - Global.logger.info("dealcards xingyun card"); - } - } - ArrayList tempCardList = new ArrayList(); - int count = 0; - do { - CardObj tempCard = this.pop(); - - if (isGooodCard3(tempCard.cardMod, dealCards, false, maxDanPai, maxDuizi, maxSanZhang)) { - if (this.cardList.size() > 0 && count++ <= this.cardList.size()) { - tempCardList.add(tempCard); - continue; - } - } - - dealCards.add(tempCard); - break; - } while (true); - - this.cardList.addAll(tempCardList); - } else { - - if (index == 0) - Global.logger.info("dealcards rand card"); - ArrayList tempCardList = new ArrayList(); - int count = 0; - do { - CardObj tempCard = this.pop(); - - if (isGooodCard4(tempCard.cardMod, dealCards, false, 0, 6, 6)) { - if (this.cardList.size() > 0 && count++ <= this.cardList.size()) { - tempCardList.add(tempCard); - continue; - } - } - - dealCards.add(tempCard); - break; - } while (true); - this.cardList.addAll(tempCardList); - } - } else { - if (white_black_status == 2) { - if (rand1 < black_white_rate) { - if (index == 0) { - if (maxDanPai == 0) { - Global.logger.info("dealcards rand card"); - } else { - Global.logger.info("dealcards white card"); - } - } - - ArrayList tempCardList = new ArrayList(); - int count = 0; - do { - CardObj tempCard = this.pop(); - - if (isGooodCard(tempCard.cardMod, dealCards, false, maxDanPai, maxDuizi, maxSanZhang)) { - if (this.cardList.size() > 0 && count++ <= this.cardList.size()) { - tempCardList.add(tempCard); - continue; - } - } - - dealCards.add(tempCard); - break; - } while (true); - - this.cardList.addAll(tempCardList); - } else { - if (index == 0) - Global.logger.info("dealcards rand card"); - ArrayList tempCardList = new ArrayList(); - int count = 0; - do { - CardObj tempCard = this.pop(); - - if (isGooodCard2(tempCard.cardMod, dealCards, false, 0, 0, 0)) { - if (this.cardList.size() > 0 && count++ <= this.cardList.size()) { - tempCardList.add(tempCard); - continue; - } - } - - dealCards.add(tempCard); - break; - } while (true); - - this.cardList.addAll(tempCardList); - } - } else if (white_black_status == 1) { - if (rand1 < black_white_rate) { - if (index == 0) { - if (maxDanPai == 0) { - Global.logger.info("dealcards rand card"); - } else { - Global.logger.info("dealcards black card"); - } - } - ; - ArrayList tempCardList = new ArrayList(); - int count = 0; - do { - CardObj tempCard = this.pop(); - - if (isGooodCard(tempCard.cardMod, dealCards, true, maxDanPai, maxDuizi, maxSanZhang)) { - if (this.cardList.size() > 0 && count++ <= this.cardList.size()) { - tempCardList.add(tempCard); - continue; - } - } - - dealCards.add(tempCard); - break; - } while (true); - this.cardList.addAll(tempCardList); - } else { - if (index == 0) - Global.logger.info("dealcards rand card"); - ArrayList tempCardList = new ArrayList(); - int count = 0; - do { - CardObj tempCard = this.pop(); - - if (isGooodCard2(tempCard.cardMod, dealCards, true, 0, 0, 0)) { - if (this.cardList.size() > 0 && count++ <= this.cardList.size()) { - tempCardList.add(tempCard); - continue; - } - } - - dealCards.add(tempCard); - break; - } while (true); - - this.cardList.addAll(tempCardList); - } - } else { - if (room_white && rand1 > room_rate) { - if (index == 0) { - if (maxDanPai == 0) { - Global.logger.info("dealcards rand card"); - } else { - Global.logger.info("dealcards general cha card"); - } - } - - ArrayList tempCardList = new ArrayList(); - int count = 0; - do { - CardObj tempCard = this.pop(); - - if (isGooodCard(tempCard.cardMod, dealCards, false, maxDanPai, maxDuizi, maxSanZhang)) { - if (this.cardList.size() > 0 && count++ <= this.cardList.size()) { - tempCardList.add(tempCard); - continue; - } - } - - dealCards.add(tempCard); - break; - } while (true); - - this.cardList.addAll(tempCardList); - } else { - if (rand1 < black_white_rate) { - if (index == 0) { - if (maxDanPai == 0) { - Global.logger.info("dealcards rand card"); - } else { - Global.logger.info("dealcards general cha card"); - } - } - ArrayList tempCardList = new ArrayList(); - int count = 0; - do { - CardObj tempCard = this.pop(); - - if (isGooodCard(tempCard.cardMod, dealCards, false, maxDanPai, maxDuizi, maxSanZhang)) { - if (this.cardList.size() > 0 && count++ <= this.cardList.size()) { - tempCardList.add(tempCard); - continue; - } - } - - dealCards.add(tempCard); - break; - } while (true); - - this.cardList.addAll(tempCardList); - } else { - if (index == 0) - Global.logger.info("dealcards rand card"); - ArrayList tempCardList = new ArrayList(); - int count = 0; - do { - CardObj tempCard = this.pop(); - - if (isGooodCard2(tempCard.cardMod, dealCards, false, 0, 0, 0)) { - if (this.cardList.size() > 0 && count++ <= this.cardList.size()) { - tempCardList.add(tempCard); - continue; - } - } - - dealCards.add(tempCard); - break; - } while (true); - - this.cardList.addAll(tempCardList); - } - } - } - } } shuffle(); - Map result = new HashMap(); CardUtil.getCardNumMap(result, dealCards); - for (Map.Entry entry : result.entrySet()) { - if (entry.getValue() >= 4) { - this.totalBoomNum++; - } else if (entry.getValue() == 3) { - this.totalSanZhangNum++; - } - } - return dealCards; } - - // 发牌 - public List dealNext(boolean room_white, boolean is_white, double room_rate, int white_black_status, - double black_white_rate, double black_black_rate, int maxDanPai, int maxDuizi, int maxSanZhang) { - List dealCards = new ArrayList(); - shuffleNext(); - double rand1 = Math.random() % 100 * 100; - for (int index = 0; index < this.num; index++) { - if (room_white && is_white) { - if (rand1 > room_rate) { - if (index == 0) { - if (maxDanPai == 0) { - Global.logger.info("dealcards rand card"); - } else { - Global.logger.info("dealcards xingyun card"); - } - } - ArrayList tempCardList = new ArrayList(); - int count = 0; - do { - CardObj tempCard = this.nextPop(); - - if (isGooodCard3(tempCard.cardMod, dealCards, false, maxDanPai, maxDuizi, maxSanZhang)) { - if (this.nextCardList.size() > 0 && count++ <= this.nextCardList.size()) { - tempCardList.add(tempCard); - continue; - } - } - - dealCards.add(tempCard); - break; - } while (true); - this.nextCardList.addAll(tempCardList); - } else { - - if (index == 0) - Global.logger.info("dealcards rand card"); - ArrayList tempCardList = new ArrayList(); - int count = 0; - do { - CardObj tempCard = this.nextPop(); - - if (isGooodCard4(tempCard.cardMod, dealCards, false, 2, 4, 3)) { - if (this.nextCardList.size() > 0 && count++ <= this.nextCardList.size()) { - tempCardList.add(tempCard); - continue; - } - } - - dealCards.add(tempCard); - break; - } while (true); - this.nextCardList.addAll(tempCardList); - } - } else { - if (white_black_status == 2) { - if (rand1 < black_white_rate) { - if (index == 0) { - if (maxDanPai == 0) { - Global.logger.info("dealcards rand card"); - } else { - Global.logger.info("dealcards white card"); - } - } - - ArrayList tempCardList = new ArrayList(); - int count = 0; - do { - CardObj tempCard = this.nextPop(); - - if (isGooodCard(tempCard.cardMod, dealCards, false, maxDanPai, maxDuizi, maxSanZhang)) { - if (this.nextCardList.size() > 0 && count++ <= this.nextCardList.size()) { - tempCardList.add(tempCard); - continue; - } - } - - dealCards.add(tempCard); - break; - } while (true); - this.nextCardList.addAll(tempCardList); - } else { - if (index == 0) - Global.logger.info("dealcards rand card"); - ArrayList tempCardList = new ArrayList(); - int count = 0; - do { - CardObj tempCard = this.nextPop(); - - if (isGooodCard2(tempCard.cardMod, dealCards, false, 0, 0, 0)) { - if (this.nextCardList.size() > 0 && count++ <= this.nextCardList.size()) { - tempCardList.add(tempCard); - continue; - } - } - - dealCards.add(tempCard); - break; - } while (true); - this.nextCardList.addAll(tempCardList); - } - } else if (white_black_status == 1) { - if (rand1 < black_white_rate) { - if (index == 0) { - if (maxDanPai == 0) { - Global.logger.info("dealcards rand card"); - } else { - Global.logger.info("dealcards black card"); - } - } - ; - ArrayList tempCardList = new ArrayList(); - int count = 0; - do { - CardObj tempCard = this.nextPop(); - - if (isGooodCard(tempCard.cardMod, dealCards, true, maxDanPai, maxDuizi, maxSanZhang)) { - if (this.nextCardList.size() > 0 && count++ <= this.nextCardList.size()) { - tempCardList.add(tempCard); - continue; - } - } - - dealCards.add(tempCard); - break; - } while (true); - this.nextCardList.addAll(tempCardList); - } else { - if (index == 0) - Global.logger.info("dealcards rand card"); - ArrayList tempCardList = new ArrayList(); - int count = 0; - do { - CardObj tempCard = this.nextPop(); - - if (isGooodCard2(tempCard.cardMod, dealCards, true, 0, 0, 0)) { - if (this.nextCardList.size() > 0 && count++ <= this.nextCardList.size()) { - tempCardList.add(tempCard); - continue; - } - } - - dealCards.add(tempCard); - break; - } while (true); - this.nextCardList.addAll(tempCardList); - } - } else { - if (room_white && rand1 > room_rate) { - if (index == 0) { - if (maxDanPai == 0) { - Global.logger.info("dealcards rand card"); - } else { - Global.logger.info("dealcards general cha card"); - } - } - - ArrayList tempCardList = new ArrayList(); - int count = 0; - do { - CardObj tempCard = this.nextPop(); - - if (isGooodCard(tempCard.cardMod, dealCards, false, maxDanPai, maxDuizi, maxSanZhang)) { - if (this.nextCardList.size() > 0 && count++ <= this.nextCardList.size()) { - tempCardList.add(tempCard); - continue; - } - } - - dealCards.add(tempCard); - break; - } while (true); - this.nextCardList.addAll(tempCardList); - } else { - if (rand1 < black_white_rate) { - if (index == 0) { - if (maxDanPai == 0) { - Global.logger.info("dealcards rand card"); - } else { - Global.logger.info("dealcards general cha card"); - } - } - ArrayList tempCardList = new ArrayList(); - int count = 0; - do { - CardObj tempCard = this.nextPop(); - - if (isGooodCard(tempCard.cardMod, dealCards, false, maxDanPai, maxDuizi, maxSanZhang)) { - if (this.nextCardList.size() > 0 && count++ <= this.nextCardList.size()) { - tempCardList.add(tempCard); - continue; - } - } - - dealCards.add(tempCard); - break; - } while (true); - this.nextCardList.addAll(tempCardList); - } else { - if (index == 0) - Global.logger.info("dealcards rand card"); - ArrayList tempCardList = new ArrayList(); - int count = 0; - do { - CardObj tempCard = this.nextPop(); - - if (isGooodCard2(tempCard.cardMod, dealCards, false, 0, 0, 0)) { - if (this.nextCardList.size() > 0 && count++ <= this.nextCardList.size()) { - tempCardList.add(tempCard); - continue; - } - } - - dealCards.add(tempCard); - break; - } while (true); - this.nextCardList.addAll(tempCardList); - } - } - } - } - } - shuffleNext(); - - Map result = new HashMap(); - CardUtil.getCardNumMap(result, dealCards); - for (Map.Entry entry : result.entrySet()) { - if (entry.getValue() >= 4) { - this.totalBoomNum++; - } else if (entry.getValue() == 3) { - this.totalSanZhangNum++; - } - } - - return dealCards; - } - - boolean isGooodCard(int card, List dealCards, boolean black, int maxDanPai, int maxDuizi, - int maxSanZhang) { - if (isGooodCard2(card, dealCards, black, maxDanPai, maxDuizi, maxSanZhang)) { - return true; - } - - if (maxDanPai != 0) { - if (card >= maxDanPai) { - return true; - } - } - - if (maxDanPai != 0) { - if (CardUtil.checkGoodCard(card, dealCards, 1)) { - if (card >= maxDuizi) { - return true; - } - } - } - - if (maxDanPai != 0) { - if (CardUtil.checkGoodCard(card, dealCards, 2)) { - if (card >= maxSanZhang) { - return true; - } - } - } - - return false; - } - - boolean isGooodCard2(int card, List dealCards, boolean black, int maxDanPai, int maxDuizi, - int maxSanZhang) { - double rand = Math.random() % 100 * 100; - if (black) { - if (CardUtil.checkGoodCard(card, dealCards, 3) && rand < 70) { - Global.logger.info("remove zhadan"); - return true; - } - - if (CardUtil.checkFenJi(card, dealCards) && rand < 70) { - Global.logger.info("remove feiji"); - return true; - } - - if (CardUtil.checkSevenShunzi(card, dealCards) && rand < 70) { - Global.logger.info("remove sevent shun zi"); - return true; - } - - if (CardUtil.checkFourDui(card, dealCards) && rand < 70) { - Global.logger.info("remove four dui"); - return true; - } - - if (CardUtil.checkQPai(card, dealCards) && rand < 70) { - Global.logger.info("remove checkQPai"); - return true; - } - } else { - if (CardUtil.checkGoodCard(card, dealCards, 3) && rand < 50) { - Global.logger.info("remove zhadan"); - return true; - } - - if (CardUtil.checkFenJi(card, dealCards) && rand < 50) { - Global.logger.info("remove feiji"); - return true; - } - - if (CardUtil.checkSevenShunzi(card, dealCards) && rand < 50) { - Global.logger.info("remove sevent shun zi"); - return true; - } - - if (CardUtil.checkFourDui(card, dealCards) && rand < 50) { - Global.logger.info("remove four dui"); - return true; - } - - if (CardUtil.checkQPai(card, dealCards) && rand < 50) { - Global.logger.info("remove checkQPai"); - return true; - } - } - - return false; - } - - boolean isGooodCard3(int card, List dealCards, boolean black, int maxDanPai, int maxDuizi, - int maxSanZhang) { - double rand = Math.random() % 100 * 100; - if (black) { - if (CardUtil.checkGoodCard(card, dealCards, 3) && rand < 50) { - Global.logger.info("remove zhadan"); - return true; - } - - if (CardUtil.checkFenJi(card, dealCards) && rand < 50) { - Global.logger.info("remove feiji"); - return true; - } - - if (CardUtil.checkSevenShunzi(card, dealCards) && rand < 50) { - Global.logger.info("remove sevent shun zi"); - return true; - } - - if (CardUtil.checkFourDui(card, dealCards) && rand < 70) { - Global.logger.info("remove four dui"); - return true; - } - - if (CardUtil.checkQPai(card, dealCards) && rand < 50) { - Global.logger.info("remove checkQPai"); - return true; - } - } else { - if (CardUtil.checkGoodCard(card, dealCards, 3) && rand < 40) { - Global.logger.info("remove zhadan"); - return true; - } - - if (CardUtil.checkFenJi(card, dealCards) && rand < 40) { - Global.logger.info("remove feiji"); - return true; - } - - if (CardUtil.checkSevenShunzi(card, dealCards) && rand < 40) { - Global.logger.info("remove sevent shun zi"); - return true; - } - - if (CardUtil.checkFourDui(card, dealCards) && rand < 40) { - Global.logger.info("remove four dui"); - return true; - } - - if (CardUtil.checkQPai(card, dealCards) && rand < 40) { - Global.logger.info("remove checkQPai"); - return true; - } - } - - return false; - } - - boolean isGooodCard4(int card, List dealCards, boolean black, int maxDanPai, int maxDuizi, - int maxSanZhang) { -// double rand = Math.random() % 100 * 100; -// if (black) { -// if (CardUtil.checkKPai(card, dealCards) && rand < 5) { -// Global.logger.info("remove checkQPai"); +// boolean isGooodCard(int card, List dealCards, boolean black, int maxDanPai, int maxDuizi, +// int maxSanZhang) { +// if (isGooodCard2(card, dealCards, black, maxDanPai, maxDuizi, maxSanZhang)) { +// return true; +// } +// +// if (maxDanPai != 0) { +// if (card >= maxDanPai) { // return true; // } -// if (CardUtil.checkGoodCard(card, dealCards, 5) && rand < 5) { +// } +// +// if (maxDanPai != 0) { +// if (CardUtil.checkGoodCard(card, dealCards, 1)) { +// if (card >= maxDuizi) { +// return true; +// } +// } +// } +// +// if (maxDanPai != 0) { +// if (CardUtil.checkGoodCard(card, dealCards, 2)) { +// if (card >= maxSanZhang) { +// return true; +// } +// } +// } +// +// return false; +// } +// +// boolean isGooodCard2(int card, List dealCards, boolean black, int maxDanPai, int maxDuizi, +// int maxSanZhang) { +// double rand = Math.random() % 100 * 100; +// if (black) { +// if (CardUtil.checkGoodCard(card, dealCards, 3) && rand < 70) { // Global.logger.info("remove zhadan"); // return true; // } // -// if (CardUtil.checkFenJi(card, dealCards) && rand < 5) { +// if (CardUtil.checkFenJi(card, dealCards) && rand < 70) { // Global.logger.info("remove feiji"); // return true; // } // -// if (CardUtil.checkSevenShunzi(card, dealCards) && rand < 5) { +// if (CardUtil.checkSevenShunzi(card, dealCards) && rand < 70) { // Global.logger.info("remove sevent shun zi"); // return true; // } // -// if (CardUtil.checkFourDui(card, dealCards) && rand < 5) { +// if (CardUtil.checkFourDui(card, dealCards) && rand < 70) { // Global.logger.info("remove four dui"); // return true; // } -// -// } else - { - if (CardUtil.checkGoodCard(card, dealCards, 8) ) { - Global.logger.info("remove zhadan"); - return true; - } -// if (CardUtil.checkShunZi(card, dealCards)) { -// Global.logger.info("remove shun zi"); +// +// if (CardUtil.checkQPai(card, dealCards) && rand < 70) { +// Global.logger.info("remove checkQPai"); // return true; // } - if (CardUtil.checkFenJi(card, dealCards)) { - Global.logger.info("remove feiji"); - return true; - } - -// if (CardUtil.checkSevenShunzi(card, dealCards)) { +// } else { +// if (CardUtil.checkGoodCard(card, dealCards, 3) && rand < 50) { +// Global.logger.info("remove zhadan"); +// return true; +// } +// +// if (CardUtil.checkFenJi(card, dealCards) && rand < 50) { +// Global.logger.info("remove feiji"); +// return true; +// } +// +// if (CardUtil.checkSevenShunzi(card, dealCards) && rand < 50) { // Global.logger.info("remove sevent shun zi"); // return true; // } - - -// if (CardUtil.checkSanTiao(card, dealCards)) { -// Global.logger.info("remove sevent san tiao"); +// +// if (CardUtil.checkFourDui(card, dealCards) && rand < 50) { +// Global.logger.info("remove four dui"); // return true; // } - - - - if (CardUtil.checkSixDui(card, dealCards)) { - Global.logger.info("remove five dui"); - return true; - } - -// if (CardUtil.checkKPai(card, dealCards)) { -// Global.logger.info("remove checkKPai"); +// +// if (CardUtil.checkQPai(card, dealCards) && rand < 50) { +// Global.logger.info("remove checkQPai"); // return true; // } - } - - return false; - } +// } +// +// return false; +// } +// +// boolean isGooodCard3(int card, List dealCards, boolean black, int maxDanPai, int maxDuizi, +// int maxSanZhang) { +// double rand = Math.random() % 100 * 100; +// if (black) { +// if (CardUtil.checkGoodCard(card, dealCards, 3) && rand < 50) { +// Global.logger.info("remove zhadan"); +// return true; +// } +// +// if (CardUtil.checkFenJi(card, dealCards) && rand < 50) { +// Global.logger.info("remove feiji"); +// return true; +// } +// +// if (CardUtil.checkSevenShunzi(card, dealCards) && rand < 50) { +// Global.logger.info("remove sevent shun zi"); +// return true; +// } +// +// if (CardUtil.checkFourDui(card, dealCards) && rand < 70) { +// Global.logger.info("remove four dui"); +// return true; +// } +// +// if (CardUtil.checkQPai(card, dealCards) && rand < 50) { +// Global.logger.info("remove checkQPai"); +// return true; +// } +// } else { +// if (CardUtil.checkGoodCard(card, dealCards, 3) && rand < 40) { +// Global.logger.info("remove zhadan"); +// return true; +// } +// +// if (CardUtil.checkFenJi(card, dealCards) && rand < 40) { +// Global.logger.info("remove feiji"); +// return true; +// } +// +// if (CardUtil.checkSevenShunzi(card, dealCards) && rand < 40) { +// Global.logger.info("remove sevent shun zi"); +// return true; +// } +// +// if (CardUtil.checkFourDui(card, dealCards) && rand < 40) { +// Global.logger.info("remove four dui"); +// return true; +// } +// +// if (CardUtil.checkQPai(card, dealCards) && rand < 40) { +// Global.logger.info("remove checkQPai"); +// return true; +// } +// } +// +// return false; +// } +// +// boolean isGooodCard4(int card, List dealCards, boolean black, int maxDanPai, int maxDuizi, +// int maxSanZhang) { +//// double rand = Math.random() % 100 * 100; +//// if (black) { +//// if (CardUtil.checkKPai(card, dealCards) && rand < 5) { +//// Global.logger.info("remove checkQPai"); +//// return true; +//// } +//// if (CardUtil.checkGoodCard(card, dealCards, 5) && rand < 5) { +//// Global.logger.info("remove zhadan"); +//// return true; +//// } +//// +//// if (CardUtil.checkFenJi(card, dealCards) && rand < 5) { +//// Global.logger.info("remove feiji"); +//// return true; +//// } +//// +//// if (CardUtil.checkSevenShunzi(card, dealCards) && rand < 5) { +//// Global.logger.info("remove sevent shun zi"); +//// return true; +//// } +//// +//// if (CardUtil.checkFourDui(card, dealCards) && rand < 5) { +//// Global.logger.info("remove four dui"); +//// return true; +//// } +//// +//// } else +// { +// if (CardUtil.checkGoodCard(card, dealCards, 8)) { +// Global.logger.info("remove zhadan"); +// return true; +// } +//// if (CardUtil.checkShunZi(card, dealCards)) { +//// Global.logger.info("remove shun zi"); +//// return true; +//// } +// if (CardUtil.checkFenJi(card, dealCards)) { +// Global.logger.info("remove feiji"); +// return true; +// } +// +//// if (CardUtil.checkSevenShunzi(card, dealCards)) { +//// Global.logger.info("remove sevent shun zi"); +//// return true; +//// } +// +//// if (CardUtil.checkSanTiao(card, dealCards)) { +//// Global.logger.info("remove sevent san tiao"); +//// return true; +//// } +// +// if (CardUtil.checkSixDui(card, dealCards)) { +// Global.logger.info("remove five dui"); +// return true; +// } +// +//// if (CardUtil.checkKPai(card, dealCards)) { +//// Global.logger.info("remove checkKPai"); +//// return true; +//// } +// } +// +// return false; +// } public List deal() { List dealCards = new ArrayList(); diff --git a/game_pk_duoduo/src/main/java/extend/pk/player/state/EXPlayerDiscardState.java b/game_pk_duoduo/src/main/java/extend/pk/player/state/EXPlayerDiscardState.java index d767588..77218e9 100644 --- a/game_pk_duoduo/src/main/java/extend/pk/player/state/EXPlayerDiscardState.java +++ b/game_pk_duoduo/src/main/java/extend/pk/player/state/EXPlayerDiscardState.java @@ -186,80 +186,15 @@ public class EXPlayerDiscardState extends StateBase { } } -// 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 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 hangCardMap = CardUtil.getCardNumMap(owner.cardInhand); - Map cardMap = CardUtil.getCardNumMap(list); - for (Map.Entry 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 { 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 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 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 { 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); diff --git a/game_pk_duoduo/src/main/java/extend/pk/uitl/CardCheck.java b/game_pk_duoduo/src/main/java/extend/pk/uitl/CardCheck.java index 6a9d618..85e82df 100644 --- a/game_pk_duoduo/src/main/java/extend/pk/uitl/CardCheck.java +++ b/game_pk_duoduo/src/main/java/extend/pk/uitl/CardCheck.java @@ -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> 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> cardMap, CardGroup out, ITObject roomConfig) { + private static CardGroup selectZha(Map> cardMap, CardGroup out, ITObject roomConfig, + int len) { CardGroup cg = null; @@ -100,7 +93,7 @@ public class CardCheck { for (Map.Entry> 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,19 +137,16 @@ public class CardCheck { List 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 = new CardGroup(); - cg.config = CardConfig.DAN; - cg.min_card = i; - cg.len = 1; + cg.config = CardConfig.DAN; + cg.min_card = i; + cg.len = 1; - cg.card_list = new ArrayList<>(); - cg.card_list.add(listCard.get(0)); - break; - } + cg.card_list = new ArrayList<>(); + cg.card_list.add(listCard.get(0)); + break; } } } else { @@ -165,21 +155,15 @@ public class CardCheck { List listCard = cardMap.get(i); if (listCard != null && listCard.size() >= 1) { - // 如果是炸弹 并且不能拆分炸弹,则不能用它作为单牌来处理 - if ((listCard.size() == 4 || (i == RoomCard.CARD_A && listCard.size() == 3))) { + cg = new CardGroup(); - } else { + cg.config = CardConfig.DAN; + cg.min_card = i; + cg.len = 1; - cg = new CardGroup(); - - cg.config = CardConfig.DAN; - cg.min_card = i; - cg.len = 1; - - cg.card_list = new ArrayList<>(); - cg.card_list.add(listCard.get(0)); - break; - } + cg.card_list = new ArrayList<>(); + cg.card_list.add(listCard.get(0)); + break; } } } @@ -223,7 +207,7 @@ public class CardCheck { List 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 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> 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,20 +396,10 @@ 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) { @@ -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,15 +449,9 @@ 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) { @@ -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 cardMap, ITObject roomConfig, boolean bSpecial) { + private static CardGroup checkZha(Map cardMap, ITObject roomConfig, int len) { CardGroup cg = null; for (Map.Entry 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> cardMap = null; + Map> 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 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 tem_list = new ArrayList(); - 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 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> entry : cardMap.entrySet()) { + int card = entry.getKey(); + List 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; } diff --git a/game_pk_duoduo/src/main/java/extend/pk/uitl/CardConfig.java b/game_pk_duoduo/src/main/java/extend/pk/uitl/CardConfig.java index f49f09e..d1e6682 100644 --- a/game_pk_duoduo/src/main/java/extend/pk/uitl/CardConfig.java +++ b/game_pk_duoduo/src/main/java/extend/pk/uitl/CardConfig.java @@ -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; diff --git a/game_pk_duoduo/src/main/java/extend/pk/uitl/CardUtil.java b/game_pk_duoduo/src/main/java/extend/pk/uitl/CardUtil.java index 741ff18..13937e6 100644 --- a/game_pk_duoduo/src/main/java/extend/pk/uitl/CardUtil.java +++ b/game_pk_duoduo/src/main/java/extend/pk/uitl/CardUtil.java @@ -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 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 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 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 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 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 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 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 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 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 cardList, int dealCard) { + int sameCard = 0; + for (CardObj card : cardList) { + if (card.card == dealCard) { + sameCard++; + } + } + return sameCard; + } + static public void removeCard(List cardList, List cards) { for (int i = 0; i < cards.size(); i++) { for (int j = 0; j < cardList.size(); j++) {