Skip to content

refactor: migrate states generator#1291

Merged
Azgaar merged 3 commits into
Azgaar:masterfrom
SheepFromHeaven:refactor/migrate-states-generator
Jan 30, 2026
Merged

refactor: migrate states generator#1291
Azgaar merged 3 commits into
Azgaar:masterfrom
SheepFromHeaven:refactor/migrate-states-generator

Conversation

@SheepFromHeaven

Copy link
Copy Markdown
Collaborator

Description

Had to redo the states migration. Here we go now

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 28, 2026

Copy link
Copy Markdown

Deploy Preview for afmg ready!

Name Link
🔨 Latest commit 6a13f70
🔍 Latest deploy log https://app.netlify.com/projects/afmg/deploys/697ccec0671f0c00083b2b96
😎 Deploy Preview https://deploy-preview-1291--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

This PR migrates the states generator from legacy JavaScript to a TypeScript module, wires it into the module bootstrap flow, and tightens type information around pack.states and related data.

Changes:

  • Introduces StatesModule in src/modules/states-generator.ts as a TypeScript port of the old public/modules/states-generator.js, preserving the public window.States API and internal behavior (generation, expansion, diplomacy, forms, statistics).
  • Updates PackedGraph typing to use the new State interface and adds an explicit religions array, improving type safety of the global pack.
  • Adjusts Names.getState to accept an optional base parameter, hooks the new states module into src/modules/index.ts, and removes the old script tag for modules/states-generator.js from src/index.html.

Reviewed changes

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

Show a summary per file
File Description
src/types/PackedGraph.ts Replaces states: any[] with states: State[] and adds a typed religions array to PackedGraph, aligning the global pack structure with the new TypeScript states module.
src/modules/states-generator.ts New TypeScript implementation of the states generator (creation, expansion, normalization, poles, neighbors, colors, statistics, campaigns, diplomacy, forms, full names) exposing the same window.States API, with small logic cleanups (e.g., using d3 helpers, fixing the valid filter) but still containing an existing bug in war power accumulation noted by a TODO.
src/modules/names-generator.ts Makes the base argument to getState optional and derives it from culture when omitted, which supports the new call sites that only pass a name and culture.
src/modules/index.ts Registers the new states-generator TypeScript module in the shared modules bootstrap so window.States is constructed before legacy JS consumers use it.
src/index.html Removes the now‑redundant <script> tag for modules/states-generator.js, ensuring only the TypeScript module defines window.States.
public/modules/states-generator.js Deletes the legacy JavaScript implementation that has been superseded by the new TypeScript module.

Comment thread src/modules/states-generator.ts Outdated
Comment thread src/modules/states-generator.ts Outdated
SheepFromHeaven and others added 2 commits January 29, 2026 08:14
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@SheepFromHeaven

Copy link
Copy Markdown
Collaborator Author

done

@Azgaar Azgaar merged commit 88c70b9 into Azgaar:master Jan 30, 2026
7 checks passed
@SheepFromHeaven SheepFromHeaven deleted the refactor/migrate-states-generator branch January 30, 2026 15:48
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.

3 participants