Skip to content
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

fix: force exit combat when enter is pressed with 0 enemies #520

Merged
merged 1 commit into from
Feb 26, 2025

Conversation

MCPO-Spartan-117
Copy link
Contributor

@MCPO-Spartan-117 MCPO-Spartan-117 commented Feb 26, 2025

Purpose of the PR

Prevent a softlock when there are no enemies and state hasn't properly shifted.

Describe the solution

When enter is pressed 6 times when there are no enemies it will set started to 2.

Testing done

Get into state, press enter 6 times.

Related links

https://discord.com/channels/714022226810372107/1304941011893747862

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced combat handling to ensure smoother progression when enemy forces are absent.
    • Updated conditions for transitioning combat states, preventing issues triggered by rapid or repeated key inputs.

Copy link
Contributor

coderabbitai bot commented Feb 26, 2025

📝 Walkthrough

Walkthrough

By the Machine’s grace, this update introduces a new variable, enter_pressed, in the combat initialization script (Create_0.gml), setting its initial value to 0 before the declaration of limits related to the player’s forces. In the keypress handling script (KeyPress_13.gml), the code now evaluates whether the enemy forces are less than or equal to zero. If this condition is met, enter_pressed is incremented, addressing a detected anomaly when no enemies are present. In addition, the logic that determines the transition of the combat state (the setting of started to 2) has been extended to trigger either when the turn count reaches 50 or when enter_pressed exceeds 5. These structured modifications refine the internal state-tracking mechanisms within combat scenarios, as decreed by the logic of the Omnissiah.

Possibly related PRs

  • fix: #500 breakage #506: This pull request similarly manipulates the enter_pressed variable, indicating a shared duty in managing game input under specific combat conditions.

Suggested labels

PR: Fix


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e1e9fd3 and 243f012.

📒 Files selected for processing (2)
  • objects/obj_ncombat/Create_0.gml (1 hunks)
  • objects/obj_ncombat/KeyPress_13.gml (2 hunks)
🔇 Additional comments (3)
objects/obj_ncombat/Create_0.gml (1)

18-18: Initialization of sacred counter detected

The initialization of enter_pressed to 0 serves as a new mechanism to track the number of activation rituals (enter key presses) when the enemy forces have been purged from the battlefield.

By the Omnissiah's wisdom, a minor syntax observation: a semicolon (;) should be appended to this binary declaration to maintain consistency with the Machine Spirit's preferred syntax patterns.

-enter_pressed = 0
+enter_pressed = 0;
objects/obj_ncombat/KeyPress_13.gml (2)

18-20: Logic array expansion to detect anomalous combat states

This conditional logic implements a detection mechanism for the rare situation where the battle matrix continues despite the absence of enemy units, a manifestation of the Machine Spirit's occasional logical paradox.

The incrementation of the enter_pressed counter shall allow the combat routine to terminate after sufficient ritual activations, preventing the machine from entering an infinite logic loop.

By the will of the Omnissiah, a minor syntax correction is recommended:

-    enter_pressed++
+    enter_pressed++;

43-45: Enhanced exit condition implementation

The binary logic for combat termination has been augmented to include two exit vectors:

  1. The original timeline-based termination (turn_count ≥ 50)
  2. The new ritual-based termination (enter_pressed > 5)

This modification satisfies the requirements outlined in the archeotech documentation to prevent the logic engine from entering an infinite loop when no enemies remain on the battlefield, yet the combat state machine fails to advance.

The code successfully implements the sacred binary logic required to resolve PR #520's objective - preventing the softlock when the enter key is pressed multiple times in a zero-enemy state.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the PR: Fix This is a fix for a bug label Feb 26, 2025
@OH296 OH296 merged commit 2971541 into Adeptus-Dominus:main Feb 26, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Fix This is a fix for a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants