Bootstrap

PHP怎么制作扑克牌游戏,我是这样开发简易扑克牌游戏

扑克牌创建好麻烦,为了方便我只创建了几张牌,欢迎大家指正。

package com.xy.game;

import java.util.ArrayList;

import java.util.Arrays;

import java.util.Collections;

import java.util.List;

import java.util.Scanner;

public class pokerList {

public static void main(String[] args) {

/*

* 创建一副扑克牌

*/

List pokerAll = new ArrayList();

Poker[] pk = { new Poker("方片", "2"), new Poker("方片", "3"),

new Poker("方片", "4"), new Poker("方片", "5"),

new Poker("方片", "6"), new Poker("方片", "7"),

new Poker("方片", "8"), new Poker("方片", "9"),

new Poker("方片", "10"), new Poker("方片", "J"),

new Poker("方片", "Q"), new Poker("方片", "K"),

new Poker("方片", "A"), new Poker("梅花", "2"),

new Poker("梅花", "3"), new Poker("梅花", "4"),

new Poker("梅花", "5"), new Poker("梅花", "6"),

new Poker("梅花", "7"), new Poker("梅花", "8"), };

pokerAll.addAll(0, Arrays.asList(pk));

System.out.println("------创建扑克牌-------");

//洗牌

System.out.println("------洗牌-------");

Collections.shuffle(pokerAll);

/*

* 创建玩家

*/

Scanner in = new Scanner(System.in);

System.out.println("请输入第一个玩家的ID:");

String p1Id = in.next();

System.out.println("请输入第一个玩家的姓名:");

String p1Name = in.next();

Player p1 = new Player(p1Id, p1Name);

System.out.println("请输入第二个玩家的ID:");

String p2Id = in.next();

System.out.println("请输入第二个玩家的姓名:");

String p2Name = in.next();

Player p2 = new Player(p2Id, p2Name);

System.out.println("-------发牌---------");

System.out.println("玩家" + p1Name + "拿牌");

System.out.println("玩家" + p2Name + "拿牌");

System.out.println("玩家" + p1Name + "拿牌");

System.out.println("玩家" + p2Name + "拿牌");

System.out.println("-----发牌结束,开始游戏-------");

/*

* 玩家拿牌

*/

List p1Pokers = new ArrayList();

p1Pokers.add(pokerAll.get(0));

p1Pokers.add(pokerAll.get(2));

Collections.sort(p1Pokers);

List p2Pokers = new ArrayList();

p2Pokers.add(pokerAll.get(1));

p2Pokers.add(pokerAll.get(3));

Collections.sort(p2Pokers);

/*

* 判断最大手牌

*/

System.out.println("玩家:"+p1Name+"最大的手牌为"+p1Pokers.get(1).huase+p1Pokers.get(1).number);

System.out.println("玩家:"+p2Name+"最大的手牌为"+p2Pokers.get(1).huase+p2Pokers.get(1).number);

/*

* 判断胜负

*/

List end = new ArrayList();

end.add(p1Pokers.get(1));

end.add(p2Pokers.get(1));

Collections.sort(end);

if(end.get(1)==p1Pokers.get(1)){

System.out.println("玩家"+p1Name+"win!");

}else{

System.out.println("玩家"+p2Name+"win!");

}

System.out.println("玩家"+p1Name+"的手牌为"+p1Pokers.get(0).huase+p1Pokers.get(0).number+p1Pokers.get(1).huase+p1Pokers.get(1).number);

System.out.println("玩家"+p1Name+"的手牌为"+p2Pokers.get(0).huase+p2Pokers.get(0).number+p2Pokers.get(1).huase+p2Pokers.get(1).number);

}

}

;