package extend.mj; import java.util.ArrayList; import java.util.Collections; import java.util.List; import com.game.Global; import java.util.Random; import extend.mj.uitl.WinCard; public class RoomCard { public List cardList; EXRoom room; public ArrayList subCardList; public RoomCard(EXRoom table) { this.cardList = new ArrayList(); subCardList = new ArrayList<>(); this.room = table; } public void init() { this.cardList.clear(); this.subCardList.clear(); this.initCard(); this.shuffle(); } private void initCard() { boolean queyimen = false; if (room.config.getBoolean(Config.ROOM_CONFIG_QUEYIMEN) != null) { queyimen = room.config.getBoolean(Config.ROOM_CONFIG_QUEYIMEN); } for (int index = 1; index <= 9; index++) { for (int index2 = 0; index2 < 4; index2++) { this.cardList.add(100 + index); this.cardList.add(200 + index); if (!queyimen) { this.cardList.add(300 + index); } } } boolean laizi = room.config.getBoolean(Config.ROOM_CONFIG_HONGZHONG); boolean laizi8 = room.config.getBoolean(Config.ROOM_CONFIG_HONGZHONG8); if (laizi) { int laiziNum = laizi8 ? 8 : 4; WinCard.zhongWinNum = laiziNum; for (int i = 0; i < laiziNum; ++i) { this.cardList.add(Config.HONGZHONG); } } // this.cardList.add(102); // this.cardList.add(102); // this.cardList.add(102); // this.cardList.add(102); // this.cardList.add(102); // this.cardList.add(102); // this.cardList.add(102); // this.cardList.add(102); // this.cardList.add(102); // this.cardList.add(102); // this.cardList.add(102); // this.cardList.add(102); // this.cardList.add(102); // this.cardList.add(102); } private void shuffle() { for (int i = 0; i < 100; i++) { Math.random(); Collections.shuffle(this.cardList); } } public void reInitCards(List cards) { // 从底牌移除 for (Integer card : cards) { for (int i = cardList.size() - 1; i >= 0; i--) { if (cardList.get(i).intValue() == card.intValue()) { if (cardList.remove(i) > 0) { this.subCardList.add(card); } break; } } } } // public int pop() { // // if (this.cardList.size() == 0) { // this.room.bankerSeat = this.room.activeSeat; //// this.room.roundSettle(); // } // // int card = this.cardList.remove(0); // // return card; // // } public int pop() { Global.logger.info("pop cardlist size=>" + this.cardList.size() + ":sub size==>" + subCardList.size()); int card = 0; if (this.cardList.size() == 0) { if (this.subCardList.size() > 0) { card = this.subCardList.remove(0); } else { this.room.bankerSeat = this.room.activeSeat; } } else { card = this.cardList.remove(0); } return card; } public int popsub() { Global.logger.info("pop sub cardlist size=>" + this.cardList.size() + ":sub size==>" + subCardList.size()); int card = 0; if (this.subCardList.size() == 0) { if (this.cardList.size() == 0) { this.room.bankerSeat = this.room.activeSeat; } else { card = this.cardList.remove(0); } } else { card = this.subCardList.remove(0); } return card; // this.room.roundSettle(); } public int getCount() { return this.cardList.size() + this.subCardList.size(); } // ���� public List deal(boolean isw) { List dealCards = new ArrayList(); if (isw) { boolean laizi8 = room.config.getBoolean(Config.ROOM_CONFIG_HONGZHONG8); Random randomno = new Random(); // boolean value = randomno.nextBoolean(); if (laizi8) { for (int ia = 0; ia < 3; ia++) { int indexhh = this.cardList.indexOf(Config.HONGZHONG); // Global.logger.info("hongzhongid:"+indexhh+"card"+this.cardList); dealCards.add(Config.HONGZHONG); this.cardList.remove(indexhh); Collections.shuffle(this.cardList); } for (int index = 0; index < 10; index++) { dealCards.add(this.pop()); } } else { int flag = 1; // if (value){ // flag = 2; // } for (int ia = 0; ia < flag; ia++) { int indexhh = this.cardList.indexOf(Config.HONGZHONG); // Global.logger.info("hongzhongid:"+indexhh+"card"+this.cardList); dealCards.add(Config.HONGZHONG); if(indexhh!=0) { this.cardList.remove(indexhh); Collections.shuffle(this.cardList); } } for (int index = 0; index < 13 - flag; index++) { dealCards.add(this.pop()); } } } else { for (int index = 0; index < 13; index++) { dealCards.add(this.pop()); } } // dealCards.add(101); // dealCards.add(101); // dealCards.add(101); // dealCards.add(101); // dealCards.add(Config.HONGZHONG); // dealCards.add(Config.HONGZHONG); // dealCards.add(Config.HONGZHONG); // dealCards.add(Config.HONGZHONG); // dealCards.add(102); // dealCards.add(102); // dealCards.add(102); // dealCards.add(102); // dealCards.add(103); // dealCards.add(103); // dealCards.add(103); // dealCards.add(103); // dealCards.add(104); return dealCards; } }