import java.util.Scanner;
public class RpgGame {
public static void main(String[] args) {
System.out.println("--------------------亲爱的勇士欢迎来到文字世界--------------------");
System.out.println("--------------------这是一个充斥着危险的世界!--------------------)");
System.out.println("--------------------亲爱的勇士,你准备好了吗?--------------------");
System.out.println("1:准备好了|其他键位:退出游戏");
Scanner start = new Scanner(System.in);
Scanner help = new Scanner(System.in);
Scanner fire = new Scanner(System.in);
int Start = start.nextInt();
if (Start == 1) {
int playharm = 20;//人物的攻击力
int playhealth = 100;//人物的血量
int cbout = 0;//回合数
int xsmonsterhealth = 50;//怪物的血量
int xsmonsterharm = 5;//怪物的攻击力
int playdefense = 0;//人物防御
int weapons = 0;
int armor = 0;
boolean isWin = false;//是否胜利
String wq1 = "拳头";
String fj1 = "手臂";
String guaiwu1 = "赤拳强盗";
System.out.println("“......我...我在哪...这是...”");
System.out.println("你眼前一片白芒......白芒渐渐消散,一个崭新的世界出现在你的眼前");
System.out.println("新手村村长:”这位大人,您就是上天派来救赎我们的勇士吧!请您一定要救救我们!“");
System.out.println("突然,你的眼前出现了三个赤手强盗");
System.out.println("获取任务:斩杀眼前的新手村强盗(0/3)");
System.out.println("帮助系统:输入Help及即可获取帮助");
System.out.println("战斗开始!");
cbout = cbout + 1;
System.out.println("敌人:赤拳强盗");
while (true) {
//小于0结束循环
if (xsmonsterhealth <= 0) {
isWin = true;
break;
}
System.out.println("回合数:" + cbout);
System.out.println("——————————————————————————该你行动了————————————————————————————");
System.out.println("战斗系统:输入1进行攻击,输入2进行防御,输入3进行逃跑");
int Fire = fire.nextInt();
if (Fire == 1) {
System.out.println("你挥动着你的" + wq1 + ",对敌人进行攻击");
System.out.println("怪物损失了" + playharm + "点血量");
xsmonsterhealth = xsmonsterhealth - playharm;
System.out.println("怪物还有" + (xsmonsterhealth <= 0 ? 0 : xsmonsterhealth) + "点血量");
System.out.println("强盗气势汹汹的向你挥拳");
System.out.println("你损失了" + xsmonsterharm + "点血量");
playhealth = playhealth - xsmonsterharm;
System.out.println("你还有" + playhealth + "点血量");
Fire = 0;
} else if (Fire == 2) {
System.out.println("将" + fj1 + "放于身前,准备好防御姿态");
System.out.println("防御得到提升↑");
playdefense = playdefense + 5;
System.out.println("强盗气势汹汹的向你挥拳");
//如果当前BOSS的攻击力小于防御力的情况下,固定人物造成伤害为1
if (xsmonsterharm - playdefense <= 0) {
System.out.println("你损失了" + 1 + "点血量");
playhealth -= 1;//人物血量减1
playdefense -= 5;//护甲值减5
if (playhealth <= 0) {
System.out.println("你失败了,你的血量已清零");
break;
}
System.out.println("人物剩余" + playhealth + "点血量");
cbout += 1;//回合数加1
continue;
}
//当前BOSS攻击力大于防御力的情况下(不应该X2.5倍)
System.out.println("你损失了" + (xsmonsterharm - playdefense) + "点血量");
playhealth -= (xsmonsterharm - playdefense);
if (playhealth <= 0) {
System.out.println("你失败了,你的血量已清零");
break;
}
System.out.println("人物剩余" + playhealth + "点血量");
playdefense = playdefense - 5;
cbout += 1;//回合数加1
Fire = 0;
} else if (Fire == 3) {
System.out.println("你被BOSS虐的逃跑了");
break;
}
}
if (isWin) {
System.out.println("————————————————————————————战斗结束—————————————————————————————");
System.out.println(guaiwu1 + "倒下了");
System.out.println("恭喜勇士,您取得了胜利!");
}
}
}
}
一键复制
编辑
Web IDE
原始数据
按行查看
历史