Fix critical bugs, add test framework, improve code quality
Some checks failed
Build and Publish Mana Loop Docker Image / build-and-publish (push) Has been cancelled
Some checks failed
Build and Publish Mana Loop Docker Image / build-and-publish (push) Has been cancelled
- Fix syntax errors with missing brackets in store.ts and crafting-slice.ts - Fix state mutation issues with lootInventory deep cloning - Remove race condition from mid-tick set() call - Fix COMBO_MASTER using wrong counter (totalTicks vs totalSpellsCast) - Add null safety to hasSpecial() function - Clamp mana to 0 in deductSpellCost() to prevent negative values - Set up Vitest testing framework with 36 passing tests
This commit is contained in:
@@ -386,11 +386,12 @@ export function deductSpellCost(
|
||||
const newElements = { ...elements };
|
||||
|
||||
if (cost.type === 'raw') {
|
||||
return { rawMana: rawMana - cost.amount, elements: newElements };
|
||||
// Clamp to 0 to prevent negative mana
|
||||
return { rawMana: Math.max(0, rawMana - cost.amount), elements: newElements };
|
||||
} else if (cost.element && newElements[cost.element]) {
|
||||
newElements[cost.element] = {
|
||||
...newElements[cost.element],
|
||||
current: newElements[cost.element].current - cost.amount
|
||||
current: Math.max(0, newElements[cost.element].current - cost.amount)
|
||||
};
|
||||
return { rawMana, elements: newElements };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user