Skip to content

Fix: Military regiment notes not updated on regeneration with new era/year#1329

Merged
Azgaar merged 4 commits into
masterfrom
copilot/fix-military-notes-update
Feb 19, 2026
Merged

Fix: Military regiment notes not updated on regeneration with new era/year#1329
Azgaar merged 4 commits into
masterfrom
copilot/fix-military-notes-update

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 19, 2026

Regiment notes retained stale era/year text after changing Options and recalculating military, because generateNote() always appended to notes[] without removing the prior entry — and notes.find() returns the first match.

Description

Changes in public/modules/military-generator.js:

  • generateNote(): If a note with the matching ID already exists, update it in-place (name and legend fields). Only push a new entry when no existing note is found. The update-in-place path is intentionally kept since generateNote is also called from outside this module.
  • generate(): Before regenerating regiments for any state, remove all existing regiment notes in a single upfront pass (notes whose ID starts with "regiment"). This is simpler and more correct than removing per-state, since all regiments are always fully regenerated together.
// generateNote — update in-place if note already exists
const existing = notes.find(n => n.id === id);
if (existing) {
  existing.name = r.name;
  existing.legend = legend;
} else {
  notes.push({id, name: r.name, legend});
}

// generate — remove all regiment notes in one pass before rebuild
for (let i = notes.length - 1; i >= 0; i--) {
  if (notes[i].id.startsWith("regiment")) notes.splice(i, 1);
}

Type of change

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

Versioning

  • Version is updated
  • Changed files hash is updated
Original prompt

This section details on the original issue you should resolve

<issue_title>Military notes are not updated on regiment or Era data change</issue_title>
<issue_description>I'm regenerating my military/regiment layer, but it's regenerating the numbers but not the write-ups. It's keeping the old Year and Era info that I've since changed in the Options tab. Is there a way to update this?

My military regiments aren't updating their descriptions and are still using the old era that was randomly generated, even when I regen military. </issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 19, 2026

Deploy Preview for afmg ready!

Name Link
🔨 Latest commit ccdbeb7
🔍 Latest deploy log https://app.netlify.com/projects/afmg/deploys/699740ca143d6e0008bdc3af
😎 Deploy Preview https://deploy-preview-1329--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.

Co-authored-by: Azgaar <26469650+Azgaar@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix military notes not updating on regiment or era data change Fix: Military regiment notes not updated on regeneration with new era/year Feb 19, 2026
Copilot AI requested a review from Azgaar February 19, 2026 14:19
Comment thread public/modules/military-generator.js Outdated
Comment thread public/modules/military-generator.js Outdated
… notes in one pass

Co-authored-by: Azgaar <26469650+Azgaar@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 fixes a bug where military regiment notes retained stale era/year information after changing Options and regenerating military forces. The issue occurred because generateNote() always appended new notes without removing prior entries, and notes.find() would return the first (stale) match.

Changes:

  • Modified generate() to remove all existing regiment notes upfront before regeneration
  • Updated generateNote() to support updating existing notes in-place (though this becomes dead code given the upfront removal)

Comment thread public/modules/military-generator.js
@Azgaar Azgaar marked this pull request as ready for review February 19, 2026 15:59
@Azgaar
Copy link
Copy Markdown
Owner

Azgaar commented Feb 19, 2026

@copilot, please update the version.

Co-authored-by: Azgaar <26469650+Azgaar@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 19, 2026

@copilot, please update the version.

Done in ccdbeb7 — bumped VERSION to 1.112.3 in public/versioning.js and updated the military-generator.js cache-buster query string in src/index.html to match.

@Azgaar Azgaar merged commit b872256 into master Feb 19, 2026
8 checks 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.

Military notes are not updated on regiment or Era data change

3 participants