import java.util.Scanner;
public class MainSGS {
/**
* @param args
*/
/*
* 主函数,程序的入口
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("======欢迎来到炒鸡三国杀======");
System.out.println("===============================");
System.out.println("三国杀是一款以三国为题材的桌游\n炒鸡版三国杀是一款以JAVA开发的控制程序");
System.out.println("===============================");
System.out.println("----武将列表----");
// int lblnum=1;
// String lbName ="刘备";
// int lbBlood = 4;
// String lbKill ="仁德";
//
// int zynum=2;
// String zylName ="赵云";
// int zylBlood = 4;
// String zyKill ="龙胆";
//
// int ccnum=3;
// String cclName ="曹操";
// int cclBlood = 4;
// String ccKill ="奸雄";
//
// int xhdnum=4;
// String xhdlName ="夏侯惇";
// int xhdlBlood = 4;
// String xhdKill ="刚烈";
//
// int sqnum=5;
// String sqlName ="孙权";
// int sqlBlood = 4;
// String sqKill ="制衡";
//
// int zysnum=6;
// String zyName ="周瑜";
// int zyBlood = 4;
// String zy2Kill ="反间";
//
// System.out.println(lblnum+"."+lbName+"\t血量:"+lbBlood+"\t技能:"+lbKill);
// System.out.println(zynum+"."+zylName+"\t血量:"+zylBlood+"\t技能:"+zyKill);
// System.out.println(ccnum+"."+cclName+"\t血量:"+cclBlood+"\t技能:"+ccKill);
// System.out.println(xhdnum+"."+xhdlName+"\t血量:"+xhdlBlood+"\t技能:"+xhdKill);
// System.out.println(sqnum+"."+sqlName+"\t血量:"+sqlBlood+"\t技能:"+sqKill);
// System.out.println(zysnum+"."+zyName+"\t血量:"+zyBlood+"\t技能:"+zy2Kill);
// System.out.println("请输入要选择的武将名字");
// Scanner name = new Scanner(System.in);
// String names = name.next();
// if(names.equals(lbName) || names.equals(zylName) || names.equals(cclName) || names.equals(xhdlName) || names.equals(sqlName) || names.equals(zyName) )
// {
// System.out.println("你选择的武将为"+names);
// }
// else
// {
// System.out.println("没有此武将,错失机会");
// }
// System.out.println("请输入要选择的武将序列");
// Scanner num = new Scanner(System.in);
// int num1 = num.nextInt();
// if(num1==1)
// System.out.println("你选择了刘备进行游戏");
// else if(num1==2)
// System.out.println("你选择了赵云进行游戏");
// else if(num1==3)
// System.out.println("你选择了曹操进行游戏");
// else if(num1==4)
// System.out.println("你选择了夏侯惇进行游戏");
// else if(num1==5)
// System.out.println("你选择了孙权进行游戏");
// else if(num1==6)
// System.out.println("你选择了周瑜进行游戏");
// System.out.println("请输入对手的武将序列:");
// Scanner num2 = new Scanner(System.in);
// int num3 = num2.nextInt();
// switch(num3)
// {
// case 1:
// System.out.println("对手选择了刘备进行游戏");
// break;
// case 2:
// System.out.println("对手选择了赵云进行游戏");
// break;
// case 3:
// System.out.println("对手选择了曹操进行游戏");
// break;
// case 4:
// System.out.println("对手选择了夏侯惇进行游戏");
// break;
// case 5:
// System.out.println("对手选择了孙权进行游戏");
// break;
// case 6:
// System.out.println("对手选择了周瑜进行游戏");
// break;
// }
//卡牌初始化
// int cardCount = 104;
// for(int j = 0;j<cardCount;j++)
// {
// //使用数组初始化卡牌
// }
System.out.println("====================================");
System.out.println("发牌给:玩家");
System.out.println("");
// for(int s=1;s<=4;s++)
// {
// System.out.print("【卡牌"+s+"】\t");
// }
// System.out.println("");
// System.out.println("发牌给:对手");
// for(int s=1;s<=4;s++)
// {
// System.out.print("【卡牌"+s+"】\t");
// }
// int gs=1;
// do
// {
// gs++;
// System.out.print("【卡牌"+gs+"】\t");
// }
// while(gs<4);
//
// System.out.println("----曹冲来算数----\n请输入两个整数");
// Scanner scOne = new Scanner(System.in);
// int one = scOne.nextInt();
// Scanner scTwo = new Scanner(System.in);
// int two = scTwo.nextInt();
//
// System.out.println("曹冲计算加法:"+one+"+"+two+"="+(one+two));
// System.out.println("曹冲计算减法:"+one+"-"+two+"="+(one-two));
// System.out.println("曹冲计算乘法:"+one+"*"+two+"="+(one*two));
// System.out.println("曹冲计算除法:"+one+"÷"+two+"="+(Math.round(one*100/two)/100.0));
//
// int numMax = one>two?one:two;
// System.out.println(numMax+"较大");
int cardCount=104;
String[][] cardArray = new String[cardCount][2];
for(int v=0;v<cardCount;v++)
{
if(v<42)
{
if(v<21)
{
cardArray[v][0]="(黑桃)";
}
else
{
cardArray[v][0]="(梅花)";
}
cardArray[v][1]="杀";
}
else if(v<42*2)
{
cardArray[v][0]="(方块)";
cardArray[v][1]="闪";
}
else if(v<cardCount)
{
cardArray[v][0]="(红桃)";
cardArray[v][1]="桃";
}
}
武将通过二维码数组初始化
String[] [] wujiangArray = {{"刘备","4","仁德"},{"赵云","4","龙胆"},
{"曹操","4","奸雄"},{"夏侯惇","4","刚烈"},
{"孙权","4","制衡"},{"周瑜","3","反间"}};
便利数组,输出武将信息
for(int lo=0;lo<wujiangArray.length;lo++)
{
System.out.println((lo+1)+"."+wujiangArray[lo][0]+"\t血量:"+wujiangArray[lo][1]
+"\t技能:"+wujiangArray[lo][2]);
}
初始化武将姓名和血量
//我方
String playerName = "";
int playerBlood = 4;
//敌方
String diName = "";
int diBlood = 4;
选择角色
System.out.println("请输入我方武将序号:");
Scanner wujiangSc = new Scanner(System.in);
int wujiangScstring = wujiangSc.nextInt();
System.out.println("你选择了武将:"+wujiangArray[wujiangScstring-1][0]);
//存储我方武将信息
playerName=wujiangArray[wujiangScstring-1][0];
if(wujiangScstring==6)
{
playerBlood=3;
}
System.out.println("初始血量为:"+playerBlood);
System.out.println("请输入敌方武将序号:");
Scanner wujiangSc1 = new Scanner(System.in);
int wujiangScstring1 = wujiangSc1.nextInt();
System.out.println("敌方武将为:"+wujiangArray[wujiangScstring1-1][0]);
//存储敌方武将信息
diName=wujiangArray[wujiangScstring1-1][0];
if(wujiangScstring1==6)
{
diBlood=3;
}
System.out.println("初始血量为:"+diBlood);
玩家发牌
// for(int q =1;q<=4;q++)
// {
// int ran = (int)(Math.random()*104);
// System.out.print("【卡牌"+q+"】:"+cardArray[ran][0]+cardArray[ran][1]+"\t");
// }
// int you =0;
// do
// {
// you++;
// System.out.print("【卡牌"+you+"】\t");
//
// }
// while(you<4);
// while(you<4)
// {
// you++;
// System.out.print("【卡牌"+you+"】\t");
// }
// for(int q =1;q<=4;q++)
// {
// int ran = (int)(Math.random()*104);
// System.out.print("【卡牌"+q+"】:"+cardArray[ran][0]+cardArray[ran][1]+"\t");
// }
System.out.println("发牌给:玩家");
String[] arrPlayerI = new String[20];
int playerNumI =0;
for(int j=1;j<=4;j++)
{
int ran = (int)(Math.random()*104);
arrPlayerI[playerNumI]= cardArray[ran][1];
System.out.print("【卡牌"+j+"】:"+cardArray[ran][0]+cardArray[ran][1]+"\t");
playerNumI++;
}
System.out.println("");
System.out.println("发牌给:对手");
String[] arrPlayer = new String[20];
int playerNum =0;
for(int j=1;j<=4;j++)
{
int ran = (int)(Math.random()*104);
arrPlayer[playerNum]= cardArray[ran][1];
System.out.print("【卡牌"+j+"】:"+cardArray[ran][0]+cardArray[ran][1]+"\t");
playerNum++;
}
System.out.println("");
boolean isOuts = true;
while(isOuts){
摸牌代码
for(int i=0;i<2;i++)
{
int ran = (int)(Math.random()*104);
arrPlayerI[playerNumI] = cardArray[ran][1];
playerNumI++;
}
System.out.println(playerName+"摸了两张手牌");
System.out.print(playerName+"的手牌有:");
for(int i = 0;i<playerNumI;i++)
{
System.out.print((i+1+"."+arrPlayerI[i]+" "));
}
boolean isOut = true;
while(isOut)
{
System.out.println("请输入要出的牌序号(0为弃牌)");
Scanner scPlayer = new Scanner(System.in);
int numSelect = scPlayer.nextInt();
if(numSelect==0)
{
isOut=false;
break;
}
if(arrPlayerI[numSelect-1].equals("杀"))
{
//导致对手失血
diBlood--;
System.out.println(diName+"感觉头一晕,失去一滴血,还剩"+diBlood);
isOut=false;
}
else if (arrPlayerI[numSelect-1].equals("闪")) {
System.out.println("此卡牌不能主动出");
}
else if (arrPlayerI[numSelect-1].equals("桃")) {
System.out.println("血量满,此卡不能出");
}
}
if(diBlood==0)
{
System.out.println(diName+"举起降旗,"+playerName+"获胜");
break;
}
//敌方摸牌
for(int i=0;i<2;i++)
{
int ran = (int)(Math.random()*104);
arrPlayer[playerNum] = cardArray[ran][1];
playerNum++;
}
System.out.println(diName+"摸了两张手牌");
System.out.print(diName+"的手牌有:");
for(int i = 0;i<playerNum;i++)
{
System.out.print((i+1+"."+arrPlayer[i]+" "));
}
System.out.println("");
for(int i = 0;i<arrPlayer.length;i++)
{
if(arrPlayer[i].equals("杀"))
{
// for(int s =0;s<arrPlayerI.length;s++)
// {
// if(arrPlayerI[s].equals("闪"))
// {
// System.out.println(playerName+"左右招架,使用一张闪");
// }
// else
// {
playerBlood--;
System.out.println(playerName+"感觉头一晕,失去一滴血,还剩"+playerBlood);
break;
// }
// }
}
}
if(diBlood>0 && playerBlood>0)
{
System.out.println("两人你来我往,难分上下");
}
if(playerBlood==0)
{
System.out.println(playerName+"举起降旗,"+diName+"获胜");
break;
}
}
}
}
public class MainSGS {
/**
* @param args
*/
/*
* 主函数,程序的入口
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("======欢迎来到炒鸡三国杀======");
System.out.println("===============================");
System.out.println("三国杀是一款以三国为题材的桌游\n炒鸡版三国杀是一款以JAVA开发的控制程序");
System.out.println("===============================");
System.out.println("----武将列表----");
// int lblnum=1;
// String lbName ="刘备";
// int lbBlood = 4;
// String lbKill ="仁德";
//
// int zynum=2;
// String zylName ="赵云";
// int zylBlood = 4;
// String zyKill ="龙胆";
//
// int ccnum=3;
// String cclName ="曹操";
// int cclBlood = 4;
// String ccKill ="奸雄";
//
// int xhdnum=4;
// String xhdlName ="夏侯惇";
// int xhdlBlood = 4;
// String xhdKill ="刚烈";
//
// int sqnum=5;
// String sqlName ="孙权";
// int sqlBlood = 4;
// String sqKill ="制衡";
//
// int zysnum=6;
// String zyName ="周瑜";
// int zyBlood = 4;
// String zy2Kill ="反间";
//
// System.out.println(lblnum+"."+lbName+"\t血量:"+lbBlood+"\t技能:"+lbKill);
// System.out.println(zynum+"."+zylName+"\t血量:"+zylBlood+"\t技能:"+zyKill);
// System.out.println(ccnum+"."+cclName+"\t血量:"+cclBlood+"\t技能:"+ccKill);
// System.out.println(xhdnum+"."+xhdlName+"\t血量:"+xhdlBlood+"\t技能:"+xhdKill);
// System.out.println(sqnum+"."+sqlName+"\t血量:"+sqlBlood+"\t技能:"+sqKill);
// System.out.println(zysnum+"."+zyName+"\t血量:"+zyBlood+"\t技能:"+zy2Kill);
// System.out.println("请输入要选择的武将名字");
// Scanner name = new Scanner(System.in);
// String names = name.next();
// if(names.equals(lbName) || names.equals(zylName) || names.equals(cclName) || names.equals(xhdlName) || names.equals(sqlName) || names.equals(zyName) )
// {
// System.out.println("你选择的武将为"+names);
// }
// else
// {
// System.out.println("没有此武将,错失机会");
// }
// System.out.println("请输入要选择的武将序列");
// Scanner num = new Scanner(System.in);
// int num1 = num.nextInt();
// if(num1==1)
// System.out.println("你选择了刘备进行游戏");
// else if(num1==2)
// System.out.println("你选择了赵云进行游戏");
// else if(num1==3)
// System.out.println("你选择了曹操进行游戏");
// else if(num1==4)
// System.out.println("你选择了夏侯惇进行游戏");
// else if(num1==5)
// System.out.println("你选择了孙权进行游戏");
// else if(num1==6)
// System.out.println("你选择了周瑜进行游戏");
// System.out.println("请输入对手的武将序列:");
// Scanner num2 = new Scanner(System.in);
// int num3 = num2.nextInt();
// switch(num3)
// {
// case 1:
// System.out.println("对手选择了刘备进行游戏");
// break;
// case 2:
// System.out.println("对手选择了赵云进行游戏");
// break;
// case 3:
// System.out.println("对手选择了曹操进行游戏");
// break;
// case 4:
// System.out.println("对手选择了夏侯惇进行游戏");
// break;
// case 5:
// System.out.println("对手选择了孙权进行游戏");
// break;
// case 6:
// System.out.println("对手选择了周瑜进行游戏");
// break;
// }
//卡牌初始化
// int cardCount = 104;
// for(int j = 0;j<cardCount;j++)
// {
// //使用数组初始化卡牌
// }
System.out.println("====================================");
System.out.println("发牌给:玩家");
System.out.println("");
// for(int s=1;s<=4;s++)
// {
// System.out.print("【卡牌"+s+"】\t");
// }
// System.out.println("");
// System.out.println("发牌给:对手");
// for(int s=1;s<=4;s++)
// {
// System.out.print("【卡牌"+s+"】\t");
// }
// int gs=1;
// do
// {
// gs++;
// System.out.print("【卡牌"+gs+"】\t");
// }
// while(gs<4);
//
// System.out.println("----曹冲来算数----\n请输入两个整数");
// Scanner scOne = new Scanner(System.in);
// int one = scOne.nextInt();
// Scanner scTwo = new Scanner(System.in);
// int two = scTwo.nextInt();
//
// System.out.println("曹冲计算加法:"+one+"+"+two+"="+(one+two));
// System.out.println("曹冲计算减法:"+one+"-"+two+"="+(one-two));
// System.out.println("曹冲计算乘法:"+one+"*"+two+"="+(one*two));
// System.out.println("曹冲计算除法:"+one+"÷"+two+"="+(Math.round(one*100/two)/100.0));
//
// int numMax = one>two?one:two;
// System.out.println(numMax+"较大");
int cardCount=104;
String[][] cardArray = new String[cardCount][2];
for(int v=0;v<cardCount;v++)
{
if(v<42)
{
if(v<21)
{
cardArray[v][0]="(黑桃)";
}
else
{
cardArray[v][0]="(梅花)";
}
cardArray[v][1]="杀";
}
else if(v<42*2)
{
cardArray[v][0]="(方块)";
cardArray[v][1]="闪";
}
else if(v<cardCount)
{
cardArray[v][0]="(红桃)";
cardArray[v][1]="桃";
}
}
武将通过二维码数组初始化
String[] [] wujiangArray = {{"刘备","4","仁德"},{"赵云","4","龙胆"},
{"曹操","4","奸雄"},{"夏侯惇","4","刚烈"},
{"孙权","4","制衡"},{"周瑜","3","反间"}};
便利数组,输出武将信息
for(int lo=0;lo<wujiangArray.length;lo++)
{
System.out.println((lo+1)+"."+wujiangArray[lo][0]+"\t血量:"+wujiangArray[lo][1]
+"\t技能:"+wujiangArray[lo][2]);
}
初始化武将姓名和血量
//我方
String playerName = "";
int playerBlood = 4;
//敌方
String diName = "";
int diBlood = 4;
选择角色
System.out.println("请输入我方武将序号:");
Scanner wujiangSc = new Scanner(System.in);
int wujiangScstring = wujiangSc.nextInt();
System.out.println("你选择了武将:"+wujiangArray[wujiangScstring-1][0]);
//存储我方武将信息
playerName=wujiangArray[wujiangScstring-1][0];
if(wujiangScstring==6)
{
playerBlood=3;
}
System.out.println("初始血量为:"+playerBlood);
System.out.println("请输入敌方武将序号:");
Scanner wujiangSc1 = new Scanner(System.in);
int wujiangScstring1 = wujiangSc1.nextInt();
System.out.println("敌方武将为:"+wujiangArray[wujiangScstring1-1][0]);
//存储敌方武将信息
diName=wujiangArray[wujiangScstring1-1][0];
if(wujiangScstring1==6)
{
diBlood=3;
}
System.out.println("初始血量为:"+diBlood);
玩家发牌
// for(int q =1;q<=4;q++)
// {
// int ran = (int)(Math.random()*104);
// System.out.print("【卡牌"+q+"】:"+cardArray[ran][0]+cardArray[ran][1]+"\t");
// }
// int you =0;
// do
// {
// you++;
// System.out.print("【卡牌"+you+"】\t");
//
// }
// while(you<4);
// while(you<4)
// {
// you++;
// System.out.print("【卡牌"+you+"】\t");
// }
// for(int q =1;q<=4;q++)
// {
// int ran = (int)(Math.random()*104);
// System.out.print("【卡牌"+q+"】:"+cardArray[ran][0]+cardArray[ran][1]+"\t");
// }
System.out.println("发牌给:玩家");
String[] arrPlayerI = new String[20];
int playerNumI =0;
for(int j=1;j<=4;j++)
{
int ran = (int)(Math.random()*104);
arrPlayerI[playerNumI]= cardArray[ran][1];
System.out.print("【卡牌"+j+"】:"+cardArray[ran][0]+cardArray[ran][1]+"\t");
playerNumI++;
}
System.out.println("");
System.out.println("发牌给:对手");
String[] arrPlayer = new String[20];
int playerNum =0;
for(int j=1;j<=4;j++)
{
int ran = (int)(Math.random()*104);
arrPlayer[playerNum]= cardArray[ran][1];
System.out.print("【卡牌"+j+"】:"+cardArray[ran][0]+cardArray[ran][1]+"\t");
playerNum++;
}
System.out.println("");
boolean isOuts = true;
while(isOuts){
摸牌代码
for(int i=0;i<2;i++)
{
int ran = (int)(Math.random()*104);
arrPlayerI[playerNumI] = cardArray[ran][1];
playerNumI++;
}
System.out.println(playerName+"摸了两张手牌");
System.out.print(playerName+"的手牌有:");
for(int i = 0;i<playerNumI;i++)
{
System.out.print((i+1+"."+arrPlayerI[i]+" "));
}
boolean isOut = true;
while(isOut)
{
System.out.println("请输入要出的牌序号(0为弃牌)");
Scanner scPlayer = new Scanner(System.in);
int numSelect = scPlayer.nextInt();
if(numSelect==0)
{
isOut=false;
break;
}
if(arrPlayerI[numSelect-1].equals("杀"))
{
//导致对手失血
diBlood--;
System.out.println(diName+"感觉头一晕,失去一滴血,还剩"+diBlood);
isOut=false;
}
else if (arrPlayerI[numSelect-1].equals("闪")) {
System.out.println("此卡牌不能主动出");
}
else if (arrPlayerI[numSelect-1].equals("桃")) {
System.out.println("血量满,此卡不能出");
}
}
if(diBlood==0)
{
System.out.println(diName+"举起降旗,"+playerName+"获胜");
break;
}
//敌方摸牌
for(int i=0;i<2;i++)
{
int ran = (int)(Math.random()*104);
arrPlayer[playerNum] = cardArray[ran][1];
playerNum++;
}
System.out.println(diName+"摸了两张手牌");
System.out.print(diName+"的手牌有:");
for(int i = 0;i<playerNum;i++)
{
System.out.print((i+1+"."+arrPlayer[i]+" "));
}
System.out.println("");
for(int i = 0;i<arrPlayer.length;i++)
{
if(arrPlayer[i].equals("杀"))
{
// for(int s =0;s<arrPlayerI.length;s++)
// {
// if(arrPlayerI[s].equals("闪"))
// {
// System.out.println(playerName+"左右招架,使用一张闪");
// }
// else
// {
playerBlood--;
System.out.println(playerName+"感觉头一晕,失去一滴血,还剩"+playerBlood);
break;
// }
// }
}
}
if(diBlood>0 && playerBlood>0)
{
System.out.println("两人你来我往,难分上下");
}
if(playerBlood==0)
{
System.out.println(playerName+"举起降旗,"+diName+"获胜");
break;
}
}
}
}