Skip to content

Reject work intents without energy#158

Draft
junaga wants to merge 1 commit into
screeps:masterfrom
junaga:agent/reject-empty-energy-intents
Draft

Reject work intents without energy#158
junaga wants to merge 1 commit into
screeps:masterfrom
junaga:agent/reject-empty-energy-intents

Conversation

@junaga

@junaga junaga commented Jul 20, 2026

Copy link
Copy Markdown

Fixes #151.

What changed

  • Require a strictly positive energy amount before processing build, repair, or controller-upgrade intents.
  • Add regression coverage for an empty creep store in all three work-intent handlers.

Why

undefined <= 0 is false in JavaScript. When a creep's store lacks an energy property, the existing guards therefore let the intent continue and arithmetic propagates NaN into creep, target, stats, and event data.

The positive-value check rejects zero, missing, and invalid energy values before any state is changed.

Validation

  • Full Jasmine suite: 111 specs, 0 failures
  • Gulp build completed successfully

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.

upgradeController bypasses validation when creep store is empty object {}

2 participants