private static int getTurnsToKillTarget(Actor attacker, Actor target) {
    if (hasCriticalAttack(attacker, target)) {
      if (attacker.getDamagePotential().max * attacker.getCriticalMultiplier()
          <= target.getDamageResistance()) return 999;
    } else {
      if (attacker.getDamagePotential().max <= target.getDamageResistance()) return 999;
    }

    float averageDamagePerTurn = getAverageDamagePerTurn(attacker, target);
    if (averageDamagePerTurn <= 0) return 100;
    return (int) FloatMath.ceil(target.getMaxHP() / averageDamagePerTurn);
  }
Esempio n. 2
0
  public static void update(ViewGroup group, Actor actor) {
    TableLayout actorinfo_stats_table =
        (TableLayout) group.findViewById(R.id.actorinfo_stats_table);

    updateTraitsTable(
        actorinfo_stats_table,
        actor.getMoveCost(),
        actor.getAttackCost(),
        actor.getAttackChance(),
        actor.getDamagePotential(),
        actor.getCriticalSkill(),
        actor.getCriticalMultiplier(),
        actor.getBlockChance(),
        actor.getDamageResistance(),
        actor.isImmuneToCriticalHits());

    TextView actorinfo_currentconditions_title =
        (TextView) group.findViewById(R.id.actorinfo_currentconditions_title);
    ActorConditionList actorinfo_currentconditions =
        (ActorConditionList) group.findViewById(R.id.actorinfo_currentconditions);
    if (actor.conditions.isEmpty()) {
      actorinfo_currentconditions_title.setVisibility(View.GONE);
      actorinfo_currentconditions.setVisibility(View.GONE);
    } else {
      actorinfo_currentconditions_title.setVisibility(View.VISIBLE);
      actorinfo_currentconditions.setVisibility(View.VISIBLE);
      actorinfo_currentconditions.update(actor.conditions);
    }
  }
 private static float getAverageDamagePerHit(Actor attacker, Actor target) {
   float result =
       (float) (getAttackHitChance(attacker, target))
           * attacker.getDamagePotential().average()
           / 100;
   if (hasCriticalAttack(attacker, target)) {
     result +=
         (float) attacker.getEffectiveCriticalChance()
             * result
             * attacker.getCriticalMultiplier()
             / 100;
   }
   result -= target.getDamageResistance();
   return result;
 }
  private AttackResult attack(final Actor attacker, final Actor target) {
    int hitChance = getAttackHitChance(attacker, target);
    if (!Constants.roll100(hitChance)) return AttackResult.MISS;

    int damage = Constants.rollValue(attacker.getDamagePotential());
    boolean isCriticalHit = false;
    if (hasCriticalAttack(attacker, target)) {
      isCriticalHit = Constants.roll100(attacker.getEffectiveCriticalChance());
      if (isCriticalHit) {
        damage *= attacker.getCriticalMultiplier();
      }
    }
    damage -= target.getDamageResistance();
    if (damage < 0) damage = 0;
    controllers.actorStatsController.removeActorHealth(target, damage);

    applyAttackHitStatusEffects(attacker, target);

    return new AttackResult(true, isCriticalHit, damage, target.isDead());
  }