Skip to content

Loads of fixes #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Dec 18, 2024
Merged

Loads of fixes #88

merged 30 commits into from
Dec 18, 2024

Conversation

miketwo
Copy link
Collaborator

@miketwo miketwo commented Dec 8, 2024

A Cornicopia of Fixes

This pull request introduces a large suite of improvements and refactorings aimed at making the combat flow more robust, the codebase more maintainable, and the gameplay more accurate. It also includes several bug fixes, performance optimizations, enhanced testing, and better handling of error conditions and edge cases. Below is a categorized summary of the major changes:

Combat Flow & Turn Management

  • Refactor Combat Loop: Centralized and clarified the turn-taking process, making it easier to follow. Each round now cleanly separates player turns from enemy turns and publishes an END_OF_TURN event before enemies act.
  • Move Turn-Taking Code into Methods (ec5c965): Isolated turn logic into dedicated methods, promoting cleaner structure and testability.
  • Check for Death States More Reliably (96dc170): Ensures that both player and enemies are evaluated for death consistently, even when no direct damage is dealt.
  • Fix Respect for Player’s Max Energy (d4bb436): Adjusted energy consumption logic so that it never exceeds the player’s intended maximum.
  • Ensure in_combat Attribute is Set (be020a9): Stabilizes state management by ensuring that the in_combat flag correctly reflects current gameplay conditions.

Card & Effect Mechanics

  • Improved Havoc Card Behavior (0dc0a9a, c090161): Streamlined logic so that Havoc correctly zeroes out energy costs and avoids infinite draw loops.
  • TrueGrit Fixes (e6e0502): Corrected the TrueGrit card’s behavior to ensure it functions as intended.
  • Draw Cards Without Clearing Hand (5496aca): Added functionality to allow new draws to occur without discarding the current hand, enabling richer strategic play.
  • Add ModeShift and SharpHide Effects (4c3ff43): Implemented new enemy mechanics (ModeShift, SharpHide) to match expected gameplay and improve variety.
  • Guardian Updates (4a358c9): Overhauled the Guardian enemy to utilize the new ModeShift logic and track turns more elegantly with modulus operations.
  • Fix DistilledChaos Logic (84531ea): Simplified DistilledChaos’s handling, making it more consistent and less error-prone.
  • Partial Invulnerability Added (3f0925b): Began implementing an Invulnerability mechanic to expand on defensive strategies.
  • Order of Parameters Fixed for Buffs/Debuffs (8f0e8a7): Corrected logic so that buffs and debuffs target the intended entities, preventing accidental buffs to the player and mismatched targets.

Performance & Resource Management

  • Enemy Creation Optimization (6d7fe34): Avoid unnecessarily creating all possible enemies upfront. Now, only the chosen enemy is instantiated, reducing computational overhead and improving performance.

Error Handling & Assertions

  • Improved Error Checking in Message Bus Tools (48c6677): Added better assertions and checks to catch misconfigurations early.
  • Handle “No Choice Available” Scenarios Gracefully (c79a430, 8f0e8a7): Ensures that when player input cannot yield a valid selection, the game handles it without crashing or introducing invalid states.
  • Assertions to Catch Bad Conditions (db413d7): Introduced assertions to detect logical inconsistencies, aiding faster debugging and more predictable error handling.

Message Bus Enhancements

  • Prioritized Callbacks (c94182c, d572b67): Implemented a priority system for callbacks (1 is highest), making the message bus more flexible and allowing for more nuanced execution order in complex scenarios.
  • Reset Bus at Game Start (2f53820): Ensures test isolation and prevents state leakage between games by resetting the message bus at the start of each game.

Testing Improvements

  • More End-to-End (e2e) Tests (6c370ed, e4ba377, db584df, db413d7): Enhanced the test suite with scenarios that better reflect real gameplay, removed redundant sleeps, and made logic more resilient.
  • Set Up Extended E2E Test (20 Rounds) (db584df): Introduced a long-running test scenario to validate stability and correctness over multiple rounds.

Miscellaneous

  • Typing Improvements (c8e3589): Incremental enhancements to typing and code clarity.
  • Notes and Documentation Updates (836fdfb): Added in-code notes for future improvements and clarifications.

This avoids tests polluting each other
Priority from 1 to 100, with 1 being highest
More end to end tests and avoid sleeps during rest site
Lots of errors when the user is given a choice of cards but has
no valid choice, so it returns None. That None then gets treated
like a card and throws errors or ends up in the player's hand.
Much simpler now
- When the player or enemy died, often the combat would continue,
sometimes crashing because the target has negative health.
- Slime splitting was also affected by this.
- Enemy buffs would accidentally buff the player
- Debuffs were not respecting the passed-in target
- we can collapse these cases into 1
- Bail if there's nothing in the draw pile
This cleans up the combat loop to be easier to understand. We take a turn,
then publish the END_OF_TURN, which causes enemies to take their turn.

I think it would be better to make it more symmetrical -- like have each
entity take a turn, but this works for now.
Priority from 1 to 100, with 1 being highest
- Use the new ModeShift
- Use modulus to determine what turn we're on
- Moved the creation to the outside of the random choice. So instead
of creating 3 enemies and then picking one, we pick one of the 3
classes and just create that one enemy. This avoids all the creation
logic of the other (unused) bosses.
This avoids Havoc drawing Havoc from the draw pile infinitely.
Copy link
Owner

@vesper-arch vesper-arch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i really have to start working on this again

@vesper-arch vesper-arch merged commit f4f879d into vesper-arch:main Dec 18, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants