Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 18, 2025

Extends system statistics with planet/moon management, enhanced population display showing numeric values, and a character-limited lore text field.

Data Model

  • Added PlanetData and MoonData dataclasses with UUID-based IDs
  • Extended SystemData with planets: list[PlanetData] and fluff_text: str fields
  • Backward compatible: missing fields default to [] and "" respectively

Population Display

Population combo now shows both category and approximate numeric value:

# In DataLoader
def get_population_value(population_id: str | None) -> int | None:
    """Returns average of min/max for population level."""
    
def format_population(value: int | None) -> str:
    """Formats as 1.5T, 500M, 50K, etc."""

UI displays: "Megacity-Planet" dropdown with "≈ 550B inhabitants" label below.

Planets & Moons UI

Added to StatsWidget:

  • Planet list with Add/Rename/Delete operations
  • Moon list (for selected planet) with Add/Rename/Delete operations
  • Names user-defined via QInputDialog

Lore Text

  • QPlainTextEdit with 500-character hard limit
  • Live counter: "123 / 500"
  • Text truncated on overflow, cursor repositioned to end

Persistence

save_project() and load_project() serialize planets/moons as nested JSON:

{
  "systems": [{
    "planets": [{
      "id": "uuid",
      "name": "Coruscant Prime",
      "moons": [{"id": "uuid", "name": "Hesperidium"}]
    }],
    "fluff_text": "Galactic capital..."
  }]
}

Old project files load without modification—new fields use defaults.

Testing

  • 7 feature tests (planet/moon CRUD, population formatting, save/load roundtrip, backward compat)
  • 2 integration tests (complete backward compatibility, mixed old/new data)
  • All existing tests pass (6/7 files, 1 pre-existing failure in route control points)
  • CodeQL: zero vulnerabilities

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

AGENT PROMPT — System Stats Expansion (Planets, Population, Fluff)
Branch

Create a new branch from current main:

feature/system-stats-planets-population-fluff

Context

This is the SW-Mercs Star Map Editor (PySide6).

Your task is a contained feature expansion of System Stats.
All existing features must remain fully functional:

Routes

Route stats & calculator

Facilities / imports / exports

Save / load compatibility with existing .swmproj files

UI layout & modes

⚠️ Do not remove or refactor unrelated logic.

🎯 Goals
1️⃣ Population: show label and numeric value

In System Stats → Population

Currently only the population label is shown.

Extend this to also display the numeric population value.

Requirements

Population data is still stored via population_id in SystemData.

Numeric value comes from population_levels.json via DataLoader.

UI display example:

Urban Megacity — 1,200,000,000

or Urban Megacity (1.2B)

(No population) remains supported.

2️⃣ Add Planets to Systems

Extend system stats to allow planet management.

Data model

Extend SystemData:

planets: list[PlanetData]

Add PlanetData dataclass:

id

name

moons: list[MoonData]

UI (Stats → System tab)

New section: Planets

List of planets

Buttons:

Add Planet

Rename

Delete

Planet names are user-defined (via input dialog).

3️⃣ Add Moons per Planet

Each planet can have named moons.

Data model

Add MoonData dataclass:

id

name

UI

When a planet is selected:

Show Moons for selected planet

List of moons

Buttons:

Add Moon

Rename

Delete

4️⃣ Fluff / Lore Text

Add a lore field to systems.

Requirements

Add fluff_text: str to SystemData

UI:

Textbox at the bottom of System Stats

QPlainTextEdit preferred

Character limit:

500 characters

Show live counter (123 / 500)

Hard-limit input (no overflow)

5️⃣ Persistence (Critical)

Update save/load logic so that:

Systems store and restore:

population_id

planets (incl. moons)

fluff_text

Backward compatibility:

Old project files load without errors

Missing fields default to empty values

🧪 Testing (Mandatory)
Automated / Scripted

Add or extend tests to cover:

Save → Load roundtrip for:

systems with planets & moons

fluff_text

Population display does not break existing logic

Manual verification checklist

Existing projects load without crashes

Routes and route stats still work

Facilities / imports / exports unchanged

Stats sidebar layout remains intact

No console errors in normal usage

📄 Documentation

Update README.md (root folder):

Describe new System Stats features:

Population numeric display

Planets & moons

Fluff text

Include a short example (e.g. Coruscant-style multi-planet system).

🚫 Non-Goals (Do NOT do)

No galaxy zones

No route logic changes

No visual changes to system icons

No schema migrations beyond backward-compatible defaults

✅ Done Criteria

All new features work as described

All old features still work

No regression in tests or UI

Code is clean, readable, and localized to:

systems.py

gui.py

project_io.py

related tests

Branch is ready for review & merge


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Dec 18, 2025
Copilot AI changed the title [WIP] Add numeric population display to system stats Add planets, moons, population numeric display, and lore text to system stats Dec 18, 2025
Copilot AI requested a review from Krabbenjack December 18, 2025 17:59
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