package Map集合;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
/*
* 1.创建map集合
* 2.准备牌
* 3.洗牌
* 4.发牌
* 5.看牌
*/
public class 斗地主2 {
public static void main(String[] args) {
// 1.创建map集合 存储牌
Map map=new LinkedHashMap();
// 2.存储牌的索引 用来排序
ArrayList cards=new ArrayList();
// 3.创建3个玩家和底牌
ArrayList dp=new ArrayList();
ArrayList wj1=new ArrayList();
ArrayList wj2=new ArrayList();
ArrayList wj3=new ArrayList();
//准备牌
String[] colors={"黑桃","红心","梅花","方块"};
String[]nums={"3","4","5","6","7","8","9","10","J","Q","K","A","2"};
int i=0;
for (String n : nums) {
for (String c : colors) {
cards.add(i);
map.put(i++, c+n);
}
}
cards.add(i);
map.put(i++, "小王");
cards.add(i);
map.put(i++, "大王");
//测试打印牌
System.out.println(map);
//洗牌
Collections.shuffle(cards);
//发牌
for(int j=0;j<54;j++){
if(j>=51){
dp.add(cards.get(j));
continue;
}
if(j%3==0){
wj1.add(cards.get(j));
}
if(j%3==1){
wj2.add(cards.get(j));
}
if(j%3==2){
wj3.add(cards.get(j));
}
}
//给玩家的牌排序
Collections.sort(wj1);
Collections.sort(wj2);
Collections.sort(wj3);
Collections.sort(dp);
//打印牌
System.out.println("玩家1");
for(int fp:wj1){
System.out.print(map.get(fp)+",");
}
System.out.println("");
System.out.println("玩家2");
for(int fp:wj2){
System.out.print(map.get(fp)+",");
}
System.out.println("");
System.out.println("玩家3");
for(int fp:wj3){
System.out.print(map.get(fp)+",");
}
System.out.println("");
System.out.println("底牌");
for(int fp:dp){
System.out.print(map.get(fp)+",");
}
}
}