v1.0.3: fixed cases where metal could be applied at full durability

This commit is contained in:
Evan Debenham 2021-08-31 18:58:28 -04:00
parent da12bb5029
commit def4d8b598
4 changed files with 9 additions and 9 deletions

View File

@ -114,21 +114,21 @@ public class LiquidMetal extends Item {
int maxToUse = 5*(m.tier+1); int maxToUse = 5*(m.tier+1);
maxToUse *= Math.pow(2, m.level()); maxToUse *= Math.pow(2, m.level());
float durabilityPerUse = 100 / (float)maxToUse; float durabilityPerMetal = 100 / (float)maxToUse;
//we remove a tiny amount here to account for rounding errors //we remove a tiny amount here to account for rounding errors
float percentDurabilityLeft = 0.999f - (m.durabilityLeft()/100f); float percentDurabilityLost = 0.999f - (m.durabilityLeft()/100f);
maxToUse = (int)Math.ceil(maxToUse*percentDurabilityLeft); maxToUse = (int)Math.ceil(maxToUse*percentDurabilityLost);
if (maxToUse == 0){ if (maxToUse == 0 || percentDurabilityLost < m.durabilityPerUse()/100f){
GLog.w(Messages.get(LiquidMetal.class, "already_fixed")); GLog.w(Messages.get(LiquidMetal.class, "already_fixed"));
return; return;
} else if (maxToUse < quantity()) { } else if (maxToUse < quantity()) {
m.repair(maxToUse*durabilityPerUse); m.repair(maxToUse*durabilityPerMetal);
quantity(quantity()-maxToUse); quantity(quantity()-maxToUse);
GLog.i(Messages.get(LiquidMetal.class, "apply", maxToUse)); GLog.i(Messages.get(LiquidMetal.class, "apply", maxToUse));
} else { } else {
m.repair(quantity()*durabilityPerUse); m.repair(quantity()*durabilityPerMetal);
GLog.i(Messages.get(LiquidMetal.class, "apply", quantity())); GLog.i(Messages.get(LiquidMetal.class, "apply", quantity()));
detachAll(Dungeon.hero.belongings.backpack); detachAll(Dungeon.hero.belongings.backpack);
} }

View File

@ -267,7 +267,7 @@ abstract public class MissileWeapon extends Weapon {
durability += amount; durability += amount;
} }
protected float durabilityPerUse(){ public float durabilityPerUse(){
float usages = baseUses * (float)(Math.pow(3, level())); float usages = baseUses * (float)(Math.pow(3, level()));
//+50%/75% durability //+50%/75% durability

View File

@ -48,7 +48,7 @@ public class RotDart extends TippedDart {
} }
@Override @Override
protected float durabilityPerUse() { public float durabilityPerUse() {
return 100f; return 100f;
} }
} }

View File

@ -129,7 +129,7 @@ public abstract class TippedDart extends Dart {
private static int targetPos = -1; private static int targetPos = -1;
@Override @Override
protected float durabilityPerUse() { public float durabilityPerUse() {
float use = super.durabilityPerUse(); float use = super.durabilityPerUse();
use /= (1 + Dungeon.hero.pointsInTalent(Talent.DURABLE_TIPS)); use /= (1 + Dungeon.hero.pointsInTalent(Talent.DURABLE_TIPS));