李泽帆 2026-05-01 15:26:04 +08:00
parent 82e32f285d
commit 90cc9fe340
1 changed files with 42 additions and 42 deletions

View File

@ -9,15 +9,14 @@ import com.game.Global;
import java.util.Random; import java.util.Random;
import extend.mj.uitl.WinCard; import extend.mj.uitl.WinCard;
public class RoomCard { public class RoomCard {
public List<Integer> cardList; public List<Integer> cardList;
EXRoom room; EXRoom room;
public ArrayList<Integer> subCardList; public ArrayList<Integer> subCardList;
public RoomCard(EXRoom table) { public RoomCard(EXRoom table) {
this.cardList = new ArrayList<Integer>(); this.cardList = new ArrayList<Integer>();
subCardList = new ArrayList<>(); subCardList = new ArrayList<>();
this.room = table; this.room = table;
} }
@ -28,23 +27,28 @@ public class RoomCard {
this.shuffle(); this.shuffle();
} }
private void initCard() { 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 index = 1; index <= 9; index++) {
for (int index2 = 0; index2 < 4; index2++) { for (int index2 = 0; index2 < 4; index2++) {
this.cardList.add(100 + index); this.cardList.add(100 + index);
this.cardList.add(200 + index); this.cardList.add(200 + index);
this.cardList.add(300 + index); if (!queyimen) {
this.cardList.add(300 + index);
}
} }
} }
boolean laizi = room.config.getBoolean(Config.ROOM_CONFIG_HONGZHONG); boolean laizi = room.config.getBoolean(Config.ROOM_CONFIG_HONGZHONG);
boolean laizi8 = room.config.getBoolean(Config.ROOM_CONFIG_HONGZHONG8); boolean laizi8 = room.config.getBoolean(Config.ROOM_CONFIG_HONGZHONG8);
if(laizi) { if (laizi) {
int laiziNum = laizi8 ? 8 :4; int laiziNum = laizi8 ? 8 : 4;
WinCard.zhongWinNum = laiziNum; WinCard.zhongWinNum = laiziNum;
for(int i =0;i<laiziNum;++i) { for (int i = 0; i < laiziNum; ++i) {
this.cardList.add(Config.HONGZHONG); this.cardList.add(Config.HONGZHONG);
} }
} }
@ -67,19 +71,18 @@ public class RoomCard {
} }
private void shuffle() { private void shuffle() {
for(int i = 0; i < 100; i++) for (int i = 0; i < 100; i++) {
{
Math.random(); Math.random();
Collections.shuffle(this.cardList); Collections.shuffle(this.cardList);
} }
} }
public void reInitCards(List<Integer> cards) { public void reInitCards(List<Integer> cards) {
//从底牌移除 // 从底牌移除
for(Integer card : cards) { for (Integer card : cards) {
for(int i = cardList.size() - 1;i >= 0;i--) { for (int i = cardList.size() - 1; i >= 0; i--) {
if(cardList.get(i).intValue() == card.intValue()) { if (cardList.get(i).intValue() == card.intValue()) {
if(cardList.remove(i) > 0) { if (cardList.remove(i) > 0) {
this.subCardList.add(card); this.subCardList.add(card);
} }
break; break;
@ -102,15 +105,15 @@ public class RoomCard {
// } // }
public int pop() { public int pop() {
Global.logger.info("pop cardlist size=>"+this.cardList.size()+":sub size==>"+subCardList.size()); Global.logger.info("pop cardlist size=>" + this.cardList.size() + ":sub size==>" + subCardList.size());
int card = 0; int card = 0;
if (this.cardList.size() == 0) { if (this.cardList.size() == 0) {
if(this.subCardList.size() > 0) { if (this.subCardList.size() > 0) {
card = this.subCardList.remove(0); card = this.subCardList.remove(0);
}else { } else {
this.room.bankerSeat = this.room.activeSeat; this.room.bankerSeat = this.room.activeSeat;
} }
}else { } else {
card = this.cardList.remove(0); card = this.cardList.remove(0);
} }
return card; return card;
@ -118,15 +121,15 @@ public class RoomCard {
} }
public int popsub() { public int popsub() {
Global.logger.info("pop sub cardlist size=>"+this.cardList.size()+":sub size==>"+subCardList.size()); Global.logger.info("pop sub cardlist size=>" + this.cardList.size() + ":sub size==>" + subCardList.size());
int card = 0; int card = 0;
if (this.subCardList.size() == 0) { if (this.subCardList.size() == 0) {
if (this.cardList.size() == 0) { if (this.cardList.size() == 0) {
this.room.bankerSeat = this.room.activeSeat; this.room.bankerSeat = this.room.activeSeat;
}else { } else {
card = this.cardList.remove(0); card = this.cardList.remove(0);
} }
}else { } else {
card = this.subCardList.remove(0); card = this.subCardList.remove(0);
} }
return card; return card;
@ -141,16 +144,15 @@ public class RoomCard {
public List<Integer> deal(boolean isw) { public List<Integer> deal(boolean isw) {
List<Integer> dealCards = new ArrayList<Integer>(); List<Integer> dealCards = new ArrayList<Integer>();
if (isw) {
if (isw){
boolean laizi8 = room.config.getBoolean(Config.ROOM_CONFIG_HONGZHONG8); boolean laizi8 = room.config.getBoolean(Config.ROOM_CONFIG_HONGZHONG8);
Random randomno = new Random(); Random randomno = new Random();
//boolean value = randomno.nextBoolean(); // boolean value = randomno.nextBoolean();
if (laizi8){ if (laizi8) {
for (int ia = 0; ia<3;ia++){ for (int ia = 0; ia < 3; ia++) {
int indexhh = this.cardList.indexOf(Config.HONGZHONG); int indexhh = this.cardList.indexOf(Config.HONGZHONG);
//Global.logger.info("hongzhongid:"+indexhh+"card"+this.cardList); // Global.logger.info("hongzhongid:"+indexhh+"card"+this.cardList);
dealCards.add(Config.HONGZHONG); dealCards.add(Config.HONGZHONG);
this.cardList.remove(indexhh); this.cardList.remove(indexhh);
Collections.shuffle(this.cardList); Collections.shuffle(this.cardList);
@ -159,31 +161,29 @@ public class RoomCard {
for (int index = 0; index < 10; index++) { for (int index = 0; index < 10; index++) {
dealCards.add(this.pop()); dealCards.add(this.pop());
} }
}else{ } else {
int flag = 1; int flag = 1;
//if (value){ // if (value){
// flag = 2; // flag = 2;
//} // }
for (int ia = 0; ia<flag;ia++){ for (int ia = 0; ia < flag; ia++) {
int indexhh = this.cardList.indexOf(Config.HONGZHONG); int indexhh = this.cardList.indexOf(Config.HONGZHONG);
//Global.logger.info("hongzhongid:"+indexhh+"card"+this.cardList); // Global.logger.info("hongzhongid:"+indexhh+"card"+this.cardList);
dealCards.add(Config.HONGZHONG); dealCards.add(Config.HONGZHONG);
this.cardList.remove(indexhh); this.cardList.remove(indexhh);
Collections.shuffle(this.cardList); Collections.shuffle(this.cardList);
} }
for (int index = 0; index < 13-flag; index++) { for (int index = 0; index < 13 - flag; index++) {
dealCards.add(this.pop()); dealCards.add(this.pop());
} }
} }
}else{ } else {
for (int index = 0; index < 13; index++) { for (int index = 0; index < 13; index++) {
dealCards.add(this.pop()); dealCards.add(this.pop());
} }
} }
// dealCards.add(101); // dealCards.add(101);
// dealCards.add(101); // dealCards.add(101);
// dealCards.add(101); // dealCards.add(101);