try to fix an issue with sanity/insanity interactions
This commit is contained in:
@@ -58,18 +58,17 @@ public class SanityCapability implements ISanity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setBonusMaxSanity(float bonusMaxSanity) {
|
public void setBonusMaxSanity(float bonusMaxSanity) {
|
||||||
float oldMax = getMaxSanity();
|
|
||||||
this.bonusMaxSanity = Math.max(0f, bonusMaxSanity);
|
this.bonusMaxSanity = Math.max(0f, bonusMaxSanity);
|
||||||
float newMax = getMaxSanity();
|
clampToMax();
|
||||||
if (oldMax > 0) {
|
|
||||||
float pct = sanity / oldMax;
|
|
||||||
sanity = pct * newMax;
|
|
||||||
}
|
|
||||||
setSanity(sanity);
|
|
||||||
setInsanity(insanity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getBonusMaxSanity() {
|
public float getBonusMaxSanity() {
|
||||||
return bonusMaxSanity;
|
return bonusMaxSanity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void clampToMax() {
|
||||||
|
float max = getMaxSanity();
|
||||||
|
this.sanity = Math.max(0, Math.min(max, this.sanity));
|
||||||
|
this.insanity = Math.max(0, Math.min(max, this.insanity));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,17 +47,11 @@ public class TempoCapability implements ITempo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setBonusMaxTempo(float bonusMaxTempo) {
|
public void setBonusMaxTempo(float bonusMaxTempo) {
|
||||||
int oldMax = getMaxTempo();
|
|
||||||
this.bonusMaxTempo = Math.max(0f, bonusMaxTempo);
|
this.bonusMaxTempo = Math.max(0f, bonusMaxTempo);
|
||||||
int newMax = getMaxTempo();
|
setTempo(this.tempo);
|
||||||
if (oldMax > 0) {
|
|
||||||
float pct = (float) tempo / (float) oldMax;
|
|
||||||
tempo = Math.round(pct * newMax);
|
|
||||||
}
|
|
||||||
setTempo(tempo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getBonusMaxTempo() {
|
public float getBonusMaxTempo() {
|
||||||
return bonusMaxTempo;
|
return bonusMaxTempo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user