Following the initial plan, I worked on effects this week. Effects (buffs/debuffs) can have positive or negative consequences, like stat boosts, damage over time and so on. Skills can apply effects, and effects can also apply other effects.
I made a few improvements in other places as well. A gif should say way more than a thousand words;
Notice that text is more animated now? I’ve also made changes to existing skills and started adding new ones, I’ll talk more about this next week.
Ordering of combat steps
One of my goals for this game is to have deterministic, turn based, combat. This means that there is no random number generator involved. There are no critical hits, random misses, or random ordering.
Who goes first is determined by the dexterity stat, however if they are equal, both players act at the same time. This is especially challenging to implement, combat (skills and effects) has to be broken down into multiple steps. The outcome should be completely deterministic regardless of what functions are technically called first. Current steps for case when both players act at the same time:
- Calculate outcome of skills for both players - amount of damage, healing etc. to apply
- Apply outcomes of skills - Use data from step 1 to deal damage, heal, etc.
- Add any queued effects to players (Skills can queue effects to be added)
- Remove any expired/duplicate effects
- Outcomes of effects are calculated
- Stats are reset to base before reapplying effects
- Effects are applied (damage, healing, etc.)
- Add any queued effects to players (effects can add other effects)
- Remove any expired/duplicate effects
Luckily, the logic for calculating and applying effects and skills is very similar. They are even using the same base class internally.
The important takeaway here is that outcomes of skills and effects are calculated for both players, before being applied. This way, skills can be based on remaining health, mana, etc. and outcomes will still be consistent. An interesting consequence of this system is that no skills or effects can set a stat to a value, when applying they can only add or subtract as these are commutative operations.
Next week
As stated in the intro post I will be working on progression next week. The most important features would be to implement skill unlocks, and more interesting content after that.
Changelog
Just like last week here is a changelog generated from my git history:
- Burn now lasts for 3 turns
- Cleaned up skill and effect code to be more clear
- Effects are now removed after combat
- Adding effects are now appropriately delayed during speed ties
- Newline after same time message in combat
- Remove duplicate effects
- GUI: Added animation (typing) to combat text
- Renamed AnimatedLabel to MenuLabel for clarity
- Added requirements.txt and better instructions
- GUI: Always capitalize first letters in menus
- GUI: Mapped WASD to arrow keys
- New skill: Blood pact
- Added damage mitigation
- Reduce font sizes slightly
- GUI: Clean up Label code
- Skill/Effect code cleanup
- Added effects - Fireball now applies burn
- Cleaned up some skill/battle logging
- Whitespace
- Added module for effects
- Restructured skills to be more clear and flexible
- Added functions for printable and internal versions of names
- Made Skill objects determine hint internally
- Moved skill collections code to separate module
- GUI: Fixed a bug causing negative menu index
- Added installer.cfg for generating windows installer
- Added build folder to .gitignore
- GUI is now the default version(–terminal for shell only)