예제 #1
0
 private void setLevel(int level) {
   for (Subject subject : subjectList) {
     int mod = dice.nextInt(3) - 1;
     if (level + mod > 0) {
       subject.setLevel(level + mod);
     } else subject.setLevel(level);
   }
 }
예제 #2
0
  private void hit(
      Subject targetSubject, Attack attack, double damageModifier, boolean criticalHit) {
    double typeModifier = attack.getAttackModifier(targetSubject);
    double STAB = 1;
    if (attack.getType().is(type.getType())) {
      STAB = 1.5;
    }
    double randNumber = dice.nextInt(151) / 1000 + 0.85;
    boolean superEffective = false;
    boolean notEffective = false;
    if (typeModifier == 2.0) {
      superEffective = true;
    } else if (typeModifier == 0.5) {
      notEffective = true;
    }
    int offence = 1;
    int defence = 1;

    offence = (attack.isPracticalAttack()) ? getPracticalOffence() : getTheoreticalOffence();
    defence =
        (attack.isPracticalDefence())
            ? targetSubject.getPracticalDefence()
            : targetSubject.getTheoreticalDefence();

    int damage =
        (int)
            Math.floor(
                ((2 * level + 10)
                            * attack.getDamage()
                            * offence
                            * damageAndHpMultiplier
                            / 250
                            / defence
                        + 2)
                    * damageModifier
                    * randNumber
                    * STAB
                    * typeModifier);

    String combatText =
        String.format("%s bruker %s! (%d skade)", nickname, attack.getName(), damage);

    if (criticalHit) {
      combatText += " (kritisk treff!)";
    }
    if (superEffective) {
      combatText += " (kjempeeffektivt!)";
    } else if (notEffective) {
      combatText += " (ikke så veldig effektivt!)";
    }

    DisplayText.add(nickname, combatText);

    targetSubject.takeDamage(damage);
  }
예제 #3
0
 public NPC copy(Vector position, int level) {
   NPC npc = new NPC(position, getImage(), world);
   for (Subject subject : subjectList) {
     npc.addSubject(subject.copy(level, this));
   }
   List<String> lines = new ArrayList<String>();
   for (String line : textLines) {
     lines.add(line);
   }
   npc.setTextLines(lines);
   return npc;
 }
예제 #4
0
 public void attack(Subject targetSubject, int attackNumber) {
   Attack attack = attacks.get(attackNumber);
   int hitModifier =
       dice.nextInt(100) + attack.getAccuracyBonus() + getAccuracy() - targetSubject.getEvasion();
   if (hitModifier >= 95) {
     hit(targetSubject, attack, 2, true);
   } else if (hitModifier >= 15) {
     hit(targetSubject, attack, 1, false);
   } else {
     DisplayText.add(
         nickname, String.format("%s brukte %s, men bommet", nickname, attack.getName()));
   }
 }
예제 #5
0
 public Subject copy(int level, Entity owner) {
   Subject newSubject =
       new Subject(
           getImage(),
           world,
           name,
           level,
           hpMax,
           practicalOffence,
           theoreticalOffence,
           practicalDefence,
           theoreticalDefence,
           speed,
           accuracy,
           evasion,
           type.toString(),
           allAttacks,
           attackLevels);
   newSubject.setOwner(owner);
   newSubject.setLevel(level);
   newSubject.setExperienceTotal(XPNextLevel(level - 1));
   return newSubject;
 }