Repository navigation
Fix combat math: spell mana cost, weapon attack, companion, level-up - #8
Merged
Merged
Conversation
- Each attack costs 10 + the spell's mana cost; expensive spells used to add mana because the cost was subtracted from 10. - Give the -3 weapon attack back when mana returns mid-battle instead of clearing the flag and losing it permanently. - A dead companion no longer takes damage, and its death is announced once instead of every enemy turn. - Keep XP above the level-up threshold and raise max HP/mana before the level-up heal.
su8
reviewed
Oct 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Spell mana cost (
battle()):mana -= 10 - manaCostmade 15/20-cost spells add mana. Each attack now costs the base 10 plus the spell's cost:Weapon attack: when mana came back mid-battle (auto-potion), the "attack decreased" flag was cleared without giving back the 3 attack, so the loss was permanent. It's now restored when the flag is cleared.
Companion: a dead companion no longer takes damage (its HP stays at 0 instead of going negative), and "has fallen" prints once instead of every enemy turn.
Level-up (
gainXP()):xp -= level * 50instead ofxp = 0.Testing
A throwaway test (not committed) ran 200 random seeds and checked:
It fails on
mainand passes on this branch.Question
The shop between floors charges 20 gold for the small potion, while the potion shop sells it for 15. Is that intentional? I didn't change it.
Fixes #4