概述
总共6个java文件
1、allObject.java
package com.home.jiangfan;
public interface allObject {
void escap();
void generalAttack();
void magicAttack();
}
2、JudgementPk.java
package com.home.jiangfan;
public class JudgementPK {
//判断等级提升
public void judgementLv(Player player){
if(player.exp>=(player.lv+player.lv)*10){
player.lv++;
player.hp = player.lv*200;
player.mp = player.lv*30;
player.attack = (player.lv*player.lv+10)*player.lv+player.weapon;
player.armor = player.lv*player.lv;
player.exp=0;
System.out.println("恭喜您~等级提升到:"+player.lv);
System.out.println("您的hp提升到:"+player.hp);
System.out.println("您的mp提升到:"+player.mp);
System.out.println("您的攻击力提升到:"+player.attack);
System.out.println("您的防御力提升到:"+player.armor);
}
}
//普通攻击
public void judgementGA(Player player,Monster monster){
if(player.hp>0 && monster.hp>0){
player.generalAttack(monster);
monster.generalAttack(player);
System.out.println("本回合较量完毕!");
System.out.println("你对敌人造成:"+player.attack+"点伤害!");
System.out.println("敌人对你造成:"+monster.attack+"点伤害!");
System.out.println("你的当前hp:"+player.hp);
System.out.println("敌人当前hp:"+monster.hp);
//处理玩家死亡
if(player.hp<=0){
player.fail(monster);
System.out.println("战斗结束!");
//返回主菜单
UserFace back=new UserFace();
back.printOperations(player);
}
//处理怪物死亡
if(monster.hp<=0){
player.victory(monster);
System.out.println("战斗结束!");
player.exp+=monster.lv*10;
System.out.println("战斗获得经验值:"+monster.lv*10);
judgementLv(player);
//返回主菜单
UserFace back=new UserFace();
back.printOperations(player);
}
}
}
//法术攻击
public void judgementMA(Player player,Monster monster){
if(player.hp>0 && monster.hp>0){
//判断玩家mp是否足够释放技能,如果通过就执行下面
if(player.mp>=player.lv*10){
player.magicAttack(monster);
monster.generalAttack(player);
System.out.println("本回合较量完毕!");
int mgAttack=player.attack+player.lv*10;
System.out.println("你对敌人造成:"+mgAttack+"点伤害!");
System.out.println("敌人对你造成:"+monster.attack+"点伤害!");
System.out.println("你的当前hp:"+player.hp);
System.out.println("敌人当前hp:"+monster.hp);
}
//玩家mp不足执行下面
else{
System.out.println("mp不足!");
monster.generalAttack(player);
System.out.println("mp不足,无法施放技能!!");
System.out.println("敌人对你造成:"+monster.attack+"点伤害!");
System.out.println("你的当前hp:"+player.hp);
System.out.println("敌人当前hp:"+monster.hp);
}
//处理玩家死亡
if(player.hp<=0){
player.fail(monster);
System.out.println("战斗结束!");
//返回主菜单
UserFace back=new UserFace();
back.printOperations(player);
}
//处理怪物死亡
if(monster.hp<=0){
player.victory(monster);
System.out.println("战斗结束!");
player.exp+=monster.lv*10;
System.out.println("战斗获得经验值:"+monster.lv*10);
judgementLv(player);
//返回主菜单
UserFace back=new UserFace();
back.printOperations(player);
}
}
}
}
最后
以上就是魔幻饼干为你收集整理的java梦游_自写游戏(梦游世界)源代码(一)的全部内容,希望文章能够帮你解决java梦游_自写游戏(梦游世界)源代码(一)所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复