libram 0.5.5 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mood.js +14 -2
- package/package.json +1 -1
package/dist/mood.js
CHANGED
|
@@ -131,13 +131,25 @@ class PotionMoodElement extends MoodElement {
|
|
|
131
131
|
if (mallPrice(this.potion) > this.maxPricePerTurn * turnsPerUse) {
|
|
132
132
|
return false;
|
|
133
133
|
}
|
|
134
|
+
//integer part
|
|
134
135
|
if (effectTurns < ensureTurns) {
|
|
135
|
-
const uses = (ensureTurns - effectTurns) / turnsPerUse;
|
|
136
|
+
const uses = Math.floor((ensureTurns - effectTurns) / turnsPerUse);
|
|
136
137
|
const quantityToBuy = clamp(uses - availableAmount(this.potion), 0, 100);
|
|
137
|
-
buy(quantityToBuy, this.potion, this.maxPricePerTurn * turnsPerUse);
|
|
138
|
+
buy(quantityToBuy, this.potion, Math.floor(this.maxPricePerTurn * turnsPerUse));
|
|
138
139
|
const quantityToUse = clamp(uses, 0, availableAmount(this.potion));
|
|
139
140
|
use(quantityToUse, this.potion);
|
|
140
141
|
}
|
|
142
|
+
//fractional part
|
|
143
|
+
const remainingDifference = ensureTurns - haveEffect(effect);
|
|
144
|
+
if (remainingDifference > 0) {
|
|
145
|
+
const price = this.maxPricePerTurn * remainingDifference;
|
|
146
|
+
if (price <= mallPrice(this.potion)) {
|
|
147
|
+
if (availableAmount(this.potion) ||
|
|
148
|
+
buy(1, this.potion, Math.floor(price))) {
|
|
149
|
+
use(1, this.potion);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
141
153
|
return haveEffect(effect) >= ensureTurns;
|
|
142
154
|
}
|
|
143
155
|
}
|