public static void main(String[] args) {
//准备牌
ArrayList<String> puke = new ArrayList<>();
String[] color = {"♣", "♦", "♥", "♠"};
String[] number = {"2", "A", "K", "Q", "J", "10", "9", "8", "7", "6", "5", "4", "3"};
puke.add("大王");
puke.add("小王");
for (String colors : color) {
for (String num : number) {
puke.add(colors + num);
}
}
//洗牌
Collections.shuffle(puke);
//System.out.println(puke);
//创建三个玩家和底牌集合,存放牌
ArrayList<String> play1 = new ArrayList<>();
ArrayList<String> play2 = new ArrayList<>();
ArrayList<String> play3 = new ArrayList<>();
ArrayList<String> dp = new ArrayList<>();
//发牌
for (int i = 0; i < puke.size(); i++) {
String a = puke.get(i);
if (i >= 51) {
dp.add(a);
} else if (i % 3 == 0) {
play1.add(a);
} else if (i % 3 == 1) {
play2.add(a);
} else if (i % 3 == 2) {
play3.add(a);
}
}
System.out.println("play1 = " + play1);
System.out.println("play2 = " + play2);
System.out.println("play3 = " + play3);
System.out.println("dipai = " + dp);
}
集合斗地主
最新推荐文章于 2024-03-25 09:41:52 发布