Browse Source

Enemy mobs now attack player when in combat

remotes/origin/fight-engine
fdai7430 2 years ago
parent
commit
230a939ea2
  1. 16
      src/main/java/org/bitbiome/commands/UseCommand.java

16
src/main/java/org/bitbiome/commands/UseCommand.java

@ -13,6 +13,22 @@ public class UseCommand implements CommandAPI {
System.out.println(getUseMessage(message.split(" ", 2)[1], engine));
if(engine.getPlayer().getHp() <= 0)
System.exit(0);
Location loc = engine.getPlayer().getLocation();
ArrayList<Mob> mobs = loc.getMobList();
for(int i = 0; i<mobs.size(); i++) {
Mob mob = mobs.get(i);
if(!mob.isFriendly()) {
float hp = engine.getPlayer().getHp();
hp -= mob.getDamage();
System.out.println(mob.getName() + " attacked you for " + mob.getDamage() + " damage.");
if(hp <= 0) {
engine.getPlayer().setHp(0);
System.out.println("You died.");
System.exit(0);
}
engine.getPlayer().setHp(hp);
}
}
} while(getNumOfEnemyMobs(engine) > 0);
}

Loading…
Cancel
Save