Skip to content

refactor: migrate states#1289

Closed
SheepFromHeaven wants to merge 2 commits into
Azgaar:masterfrom
SheepFromHeaven:refactor/migrate-states
Closed

refactor: migrate states#1289
SheepFromHeaven wants to merge 2 commits into
Azgaar:masterfrom
SheepFromHeaven:refactor/migrate-states

Conversation

@SheepFromHeaven

Copy link
Copy Markdown
Collaborator

Description

Type of change

  • Bug fix
  • New feature
  • Refactoring / style
  • Documentation update / chore
  • Other (please describe)

Versioning

  • Version is updated
  • Changed files hash is updated

@netlify

netlify Bot commented Jan 27, 2026

Copy link
Copy Markdown

Deploy Preview for afmg ready!

Name Link
🔨 Latest commit e05f6fc
🔍 Latest deploy log https://app.netlify.com/projects/afmg/deploys/6978e2a7a8882a0009e5240f
😎 Deploy Preview https://deploy-preview-1289--afmg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Migrates the legacy States generator from public/modules JavaScript into the TypeScript/Vite module pipeline, aligning runtime loading with the ongoing TS migration and updating shared type definitions.

Changes:

  • Added a new src/modules/states-generator.ts and wired it into src/modules/index.ts
  • Removed the legacy public/modules/states-generator.js and stopped loading it from src/index.html
  • Extended global / packed-graph TypeScript types to include state-related data and globals used by the migrated module

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/types/global.ts Adds missing global declarations (COA, options) used by the migrated TS module
src/types/PackedGraph.ts Extends packed graph typing to include states and additional cell fields used by states logic
src/modules/states-generator.ts New TypeScript implementation of the States generator (ported from the removed JS module)
src/modules/index.ts Ensures the new TS States module is loaded via side-effect import
src/index.html Removes loading of the legacy modules/states-generator.js script
public/modules/states-generator.js Deleted legacy JS implementation now replaced by the TS module

.filter((d) => d)
.forEach((v) => {
attackers.push(v);
dp += states[v].area! * states[v].expansionism!;

Copilot AI Jan 27, 2026

Copy link

Choose a reason for hiding this comment

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

In the attacker-allies section, when an ally’s vassals join the attackers, their power is currently added to dp (defenders power). This should increase ap (attackers power); otherwise subsequent balance checks and diplomacy outcomes are skewed.

Suggested change
dp += states[v].area! * states[v].expansionism!;
ap += states[v].area! * states[v].expansionism!;

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

this review makes me cautious. I will check again tomorrow that i did not do any error here.

Comment on lines +520 to +523
: states[f]
.neighbors!.map((n) => states[n].neighbors)
.join("")
.includes(String(t));

Copilot AI Jan 27, 2026

Copy link

Choose a reason for hiding this comment

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

neibOfNeib detection uses .map(...).join("").includes(String(t)), which can produce false positives (e.g., neighbor list [11] makes includes("1") true). Consider using a proper nested membership check (e.g., some + includes) or a Set of second-degree neighbors.

Suggested change
: states[f]
.neighbors!.map((n) => states[n].neighbors)
.join("")
.includes(String(t));
: states[f].neighbors!.some((n) => states[n].neighbors!.includes(t));

Copilot uses AI. Check for mistakes.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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