public void step(final int leftHP,final int rounds){
  float stepSize=leftHP / (float)player.getBaseHP();
  stepSize=Math.signum(stepSize) * Math.min(Math.abs(stepSize),0.5f);
  final int oldAtk=creature.getAtk();
  int newAtk=Math.max(1,Math.round(creature.getAtk() + stepSize * creature.getAtk()));
  if ((leftHP < 0) && (newAtk == oldAtk)) {
    newAtk--;
  }
  final int level=creature.getLevel();
  final int oldDef=creature.getDef();
  int newDef=oldDef;
  final double preferred=preferredDuration(level);
  if (!isWithinDurationRange(preferred,rounds)) {
    if ((leftHP > 0) || (preferred < rounds)) {
      newDef=Math.max(1,(int)(creature.getDef() + preferred - rounds + 0.5));
    }
  }
 else {
    newDef=Math.max(1,(int)(creature.getDef() + 5 * stepSize * creature.getDef() + 0.5f));
  }
  if (newDef > 1.1 * oldDef) {
    newDef=Math.max((int)(1.1 * oldDef),oldDef + 1);
  }
 else   if (newDef < 0.9 * oldDef) {
    newDef=Math.max(1,Math.min((int)(0.9 * oldDef),oldDef - 1));
  }
  creature.setAtk(newAtk);
  creature.setDef(newDef);
}

public void step ( final int leftHP , final int rounds ) { float stepSize = leftHP / ( float ) player . getBaseHP ( ) ; stepSize = Math . signum ( stepSize ) * Math . min ( Math . abs ( stepSize ) , 0.5f ) ; final int oldAtk = creature . getAtk ( ) ; int newAtk = Math . max ( 1 , Math . round ( creature . getAtk ( ) + stepSize * creature . getAtk ( ) ) ) ; if ( ( leftHP < 0 ) && ( newAtk == oldAtk ) ) { newAtk -- ; } final int level = creature . getLevel ( ) ; final int oldDef = creature . getDef ( ) ; int newDef = oldDef ; final double preferred = preferredDuration ( level ) ; if ( ! isWithinDurationRange ( preferred , rounds ) ) { if ( ( leftHP > 0 ) || ( preferred < rounds ) ) { newDef = Math . max ( 1 , ( int ) ( creature . getDef ( ) + preferred - rounds + 0.5 ) ) ; } } else { newDef = Math . max ( 1 , ( int ) ( creature . getDef ( ) + 5 * stepSize * creature . getDef ( ) + 0.5f ) ) ; } if ( newDef > 1.1 * oldDef ) { newDef = Math . max ( ( int ) ( 1.1 * oldDef ) , oldDef + 1 ) ; } else if ( newDef < 0.9 * oldDef ) { newDef = Math . max ( 1 , Math . min ( ( int ) ( 0.9 * oldDef ) , oldDef - 1 ) ) ; } creature . setAtk ( newAtk ) ; creature . setDef ( newDef ) ; }
adjust creature stats using results from the previous run .
