Skip to content

Commit

Permalink
v1.0.3: fixed cases where metal could be applied at full durability
Browse files Browse the repository at this point in the history
  • Loading branch information
00-Evan committed Aug 31, 2021
1 parent da12bb5 commit def4d8b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,21 +114,21 @@ public void onSelect( Item item ) {
int maxToUse = 5*(m.tier+1);
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
float percentDurabilityLeft = 0.999f - (m.durabilityLeft()/100f);
maxToUse = (int)Math.ceil(maxToUse*percentDurabilityLeft);
if (maxToUse == 0){
float percentDurabilityLost = 0.999f - (m.durabilityLeft()/100f);
maxToUse = (int)Math.ceil(maxToUse*percentDurabilityLost);
if (maxToUse == 0 || percentDurabilityLost < m.durabilityPerUse()/100f){
GLog.w(Messages.get(LiquidMetal.class, "already_fixed"));
return;
} else if (maxToUse < quantity()) {
m.repair(maxToUse*durabilityPerUse);
m.repair(maxToUse*durabilityPerMetal);
quantity(quantity()-maxToUse);
GLog.i(Messages.get(LiquidMetal.class, "apply", maxToUse));

} else {
m.repair(quantity()*durabilityPerUse);
m.repair(quantity()*durabilityPerMetal);
GLog.i(Messages.get(LiquidMetal.class, "apply", quantity()));
detachAll(Dungeon.hero.belongings.backpack);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public void repair( float amount ){
durability += amount;
}

protected float durabilityPerUse(){
public float durabilityPerUse(){
float usages = baseUses * (float)(Math.pow(3, level()));

//+50%/75% durability
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public int proc(Char attacker, Char defender, int damage) {
}

@Override
protected float durabilityPerUse() {
public float durabilityPerUse() {
return 100f;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ protected void rangedHit(Char enemy, int cell) {
private static int targetPos = -1;

@Override
protected float durabilityPerUse() {
public float durabilityPerUse() {
float use = super.durabilityPerUse();

use /= (1 + Dungeon.hero.pointsInTalent(Talent.DURABLE_TIPS));
Expand Down

0 comments on commit def4d8b

Please sign in to comment.