Example #1
0
 // Warrior special attack/spell. Does 4 damage
 public void specialAttack(Character other) {
   System.out.println("Used special attack 'Power Strike'");
   int hitroll = this.roll(3, 6);
   System.out.println(this.getName() + " rolled " + hitroll);
   System.out.println(this.getName() + "'s effDex: " + (getEffDx()));
   if (hitroll < this.getEffDx()) {
     other.setHp(other.getHp() - 4);
     System.out.println("Attack successful");
   } else {
     System.out.println("Attack missed");
   }
 }
Example #2
0
  public void fajt(Character a, Character b) {
    while (true) {
      int dam = a.hit(b);
      b.setHp(b.getHp() - dam);

      if (b.getHp() < 1) {
        b.dies();
        System.out.println(a.getName() + " har krossat " + b.getName());
        System.out.println(
            "Det verkar som om " + a.getWeapon().getType() + " är ett överlägset vapen.");
        break;
      }

      dam = b.hit(a);
      a.setHp(a.getHp() - dam);
      if (a.getHp() < 1) {
        a.dies();
        System.out.println(b.getName() + " har krossat " + a.getName());
        System.out.println(
            "Det verkar som om " + b.getWeapon().getType() + " är ett överlägset vapen.");
        break;
      }
    }
  }