Skip to content

Comments

Remove Diplomacy Tab and Add Map-Based Diplomacy Icons#161

Merged
1brucben merged 21 commits intov0.2.0from
diplomacy-removal-magic
Dec 19, 2025
Merged

Remove Diplomacy Tab and Add Map-Based Diplomacy Icons#161
1brucben merged 21 commits intov0.2.0from
diplomacy-removal-magic

Conversation

@El-Magico777
Copy link
Collaborator

Build on top of #158, #159 and #160!

Description:

This PR removes the Diplomacy tab from ControlPanel2 and replaces it with visual diplomacy indicators directly on the map via NameLayer icons.

image image image

Changes

1. Add Diplomacy Relation Icons to Map (571bf4c)

  • Added war (sword) and neutral (dove) icons above player names in NameLayer
  • War icon uses CSS mask with SwordIcon.svg rendered in exact #8B0000 (matches radial menu)
  • Neutral uses existing dove.png asset
  • Alliance icon remains using AllianceIcon.svg
  • Icons are hidden for the local player's own name
  • PlayerInfoOverlay simplified to show text-only relation (Allied/Neutral/Hostile)

2. Remove Diplomacy Tab UI (7e80e55)

  • Removed 'Diplomacy' from ControlPanel2 tab list and type definitions
  • Stubbed out renderDiplomacyTab method (returns empty template)
  • Removed 180+ lines of diplomacy tab render logic and event handlers
  • Method signature kept for compatibility

3. Improve Diplomacy Icon Display (925f5da)

  • War icon sized at 0.8x for better visual balance
  • Filter diplomacy icons to show only for Human/FakeHuman players (not regular bots)
  • Import PlayerType from Game.ts for type checking
  • Removed icon resize loop that caused flickering
  • Stable icon sizing without constant updates
image

Rationale

Diplomacy relations are now clearly visible via NameLayer icons on the map itself, eliminating the need for a separate tab UI. This reduces control panel clutter and provides instant visual feedback about player relations without requiring tab navigation.

Assets Used

  • resources/images/SwordIcon.svg (masked to #8B0000)
  • proprietary/images/dove.png
  • resources/images/AllianceIcon.svg

Impact

Client-only UI changes. No server or core logic modifications.

Please complete the following:

  • I have added screenshots for all UI updates
  • I process any text displayed to the user through translateText() and I've added it to the en.json file
  • I have added relevant tests to the test directory
  • I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced
  • I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors

Please put your Discord username so you can be contacted if a bug or regression is found:

el_magico777

- Tweaked research tree UI text and tooltip content (short vs detailed)
- Updated tech tooltips with clearer unlock summaries and numbers
- Refactored tech effects unlock logic and cleaned definitions
Adds a complete structure stacking system that allows players to build
multiple instances of structures in a single tile. Stacking provides:
- Increased HP (bonus per stacked instance)
- Multiplied functionality (e.g., ×2 city = 2× population cap)

STACKING MECHANICS:
- Stack count is user-controlled (1-99) via +/- buttons in build menu
- Each game starts fresh with stack count reset to 1
- Uses localStorage for in-game UI communication only (cleared on game start)
- Stack count shown as ×N prefix in build menu display

STACKABLE STRUCTURES (9 total):
- City: ×N population cap increase
- Port: ×N trade ship supply
- Airfield: spawns N bombers
- Hospital: ×N healing effect
- Academy: ×N combat bonus
- Research Lab: ×N research boost
- Factory: ×N gold production bonus
- Missile Silo: can launch N nukes before cooldown
- SAM Launcher: fires N missiles per interception

DEFENSE POST: Stacking intentionally disabled (single instance only)

IMPLEMENTATION DETAILS:

Core data model:
- Added _stackCount field to UnitImpl for tracking stacked instances
- Added _launchesRemaining field for missile silo multi-launch tracking
- Added stackCount() and launchesRemaining() to Unit interface
- Added fields to GameUpdates and GameView for client sync

Stackable structure definitions (Upgradeables.ts):
- Added STACKABLE_STRUCTURES set (9 structure types)
- Added TECH_UPGRADEABLE_STRUCTURES set (SAM, Airfield only)
- Added helper functions: isStackableStructure(), maxStackCount(),
  isTechUpgradeableStructure(), maxStructureTechLevel()

Construction execution:
- ConstructionExecution now separates stackCount from techLevel
- Added computeStackCount() and computeTechLevel() methods
- Added applyStackingIfNeeded() to set stack count and HP bonuses

Structure-specific execution updates:
- AirfieldExecution: spawns stackCount bombers, tracks upgrades
- SAMLauncherExecution: fires stackCount missiles per interception
- MissileSiloExecution: accepts stackCount param, allows N launches
  before cooldown via launchesRemaining tracking
- DefensePostExecution: removed stacking support

Client UI:
- BuildMenu: shows ×N prefix for stacked structures
- ControlPanel2: Stack ×N UI with +/- adjustment buttons
- Transport: reads stack count and sends with build intent
- LocalPersistantStats: clears stack count settings on game start
…ited SAM/Silo stacking

- Fix structure stacking system to properly increment stackCount via setStackCount()
- Update playerMaxStructureLevel() to return 99 for all stackable structures (SAM, Silo, Airfield)
- Remove legacy cap of 3 from maxStructureLevel() for SAM and Silo
- Implement launchesRemaining system for SAM (fire stackCount times before cooldown)
- Fix SAM/Silo cooldown calculation to use effectiveMaxHealth() instead of base health
- SAM range now uses playerMaxStructureTechLevel() (tech tier 1-3), not stack count
- Display stack count instead of level for structure badges
- Add SAM tech level as secondary indicator (similar to Airfield bomber level)
- PlayerInfoOverlay and BuildMenu now show correct counts including stacked structures
- Update unitsOwned() to use stackCount() for all stackable structures
- Rename 'Upgrade Structures' button to 'Stack Structures'
…STACK_COUNT=25 and clamp in helpers (maxStackCount, maxStructureLevel, playerMaxStructureLevel)\n- Clamp ConstructionExecution desired stack, UnitImpl.setStackCount\n- Limit client intent payload and schema to 25 (Transport, Schemas)\n- Keeps UI controls honoring cap via shared helpers
- Support multiple simultaneous research priorities (Set-based)
- Add category 'Prioritize' button to set all techs in category
- Cross-category prioritization: selecting individual tech clears same-level techs from other categories
- Category prioritization clears other categories but preserves existing priorities in selected category
- Locked prioritized techs show gold background with lock icon
- Research allocation: 60% split among available priorities, 40% to others
- Priority prerequisites get 60% when priorities locked
- Update PlayerView to expose full priorities Set
- Remove ScorchedEarth upgrade and all related code
  - Delete ScorchedEarthExecution and integration tests
  - Remove SCORCHED_EARTH from UpgradeType enum
  - Remove scorchedEarthActivationCost from Config

- Remove Insurance system
  - Remove INSURANCE_REFUND message type
  - Remove insurance refund logic from UnitImpl
  - Remove structureInsuranceRefundNum/Den from Config
  - Remove ECONOMY_INSURANCE tech ID

- Remove policy directive system (referenced non-existent Economy-3 tech)
  - Delete PolicyDirectiveSelectExecution, MarkPolicyDirectivesSeenExecution
  - Delete PolicyDirectives.ts definition file
  - Remove policy schemas, intents, handlers from Transport/ExecutionManager
  - Remove policy methods from Player interface and PlayerImpl
  - Remove policy logic from all TechEffects modifier functions
  - Remove policy notification from ResearchToggleButton

- Move InternationalTrade upgrade to Land-1 tech (Road Network)

- Remove unused tech IDs: ECONOMY_INTERNATIONAL_TRADE, ECONOMY_TBD_LEVEL4, TRADE_POLICY_FRAMEWORK

- Remove unused upgrade types: WaterUpgrade1/2/3, AirUpgrade3, EconomyUpgrade1/2/3

All tests passing (46 suites, 276 tests)
The paratrooper option was not appearing in the radial menu even when Air-1 tech was researched and airfield was in range.

Root cause: Both RadialMenu.shouldShowAirAttack() and ParatrooperAttackExecution.init() were checking for obsolete UpgradeType.AirUpgrade1 instead of UpgradeType.JetEngines.

The Air-1 Early Air Power tech grants UpgradeType.JetEngines, not AirUpgrade1, so the check was always failing.

Changed both files to check for JetEngines upgrade, which is the correct requirement for paratroopers.

All tests pass (46 suites, 276 tests).
…mbing by default

BREAKING CHANGE: Auto-bombing is now enabled by default for all players

Changes:
- PlayerImpl: Changed _autoBombingEnabled default from false to true
  * All players now have auto-bombing active by default
  * Can still be overridden via radial menu manual targeting

- RadialMenu: Added bomber targeting action (Slot.Bomber)
  * Shows airfield icon when right-clicking enemy land tiles
  * Gating: requires airfield, land tile, enemy ownership, war status
  * Range validation: checks bomber level and config range from all airfields
  * Targets all structure types (City, DefensePost, SAMLauncher, etc.)
  * Uses preferClosest=true for optimal targeting priority
  * Icon: airfield icon (matches build menu consistency)

- BomberExecution: Fixed manual to auto fallback logic
  * When manual targets exhausted, now clears bomberIntent via setBomberIntent(null)
  * Ensures seamless switch back to auto-bombing mode
  * Previously would get stuck when findTargetFromQueue returned null

- ControlPanel2: Completely removed Bombers tab
  * Deleted tab UI rendering (button and content panel ~200 lines)
  * Removed all bomber-specific state variables
  * Removed bomber methods: _startAutoBombing, _stopAutoBombing,
    _handleBomberTargetChange, populateBomberForm, _refreshBomberPlayerLists,
    _getPlayersInAirfieldRange
  * Removed bomber-related updated() hook logic
  * Removed Bombers from activeTab type union and _changeTab signature
  * Cleaned up residual references (comments, dead code)
  * Kept sendBomberIntent() for radial integration

- UI/UX Improvements:
  * Unified bomber control via radial menu (right-click context)
  * Removed toggle complexity from control panel
  * Airfield icon provides visual consistency with build menu
  * Auto-bombing ensures bombers always active when at war

All tests pass (46 suites, 276 tests). TypeScript and ESLint clean.
Previously, disabled radial menu options were completely greyed out with a generic disabled icon, making it impossible to understand what options were available or why they were unavailable.

Now there are three distinct visual states:
1. Active (unlocked and in range): Full color, full opacity, clickable
2. Out of range (unlocked but too far): Darkened version of the feature's color (preserves hue), 0.7 opacity
3. Not unlocked (feature not researched): Black and white (no color set), 0.7 opacity

Changes:
- Replaced swap-to-grey-icon with darkenColor() helper that preserves original hue when a color is set
- When no color is set (not unlocked), uses dark grey fallback for black-and-white appearance
- Increased disabled opacity from 0.5 to 0.7 for better icon visibility
- Icons always remain visible (boat, airAttack, bomber, info, ally, peace icons set as defaults)
- Removed unused disabledIcon import

Result: Players can now see all radial menu options and understand their status at a glance - full color means ready to use, colored but dark means out of range, black and white means not yet unlocked.
- NameLayer: add war (sword) and neutral (dove) icons above player names, reusing diplomacy assets
- Color: render war icon via CSS mask using SwordIcon.svg with exact warColor (#8B0000) to match radial menu; neutral uses existing dove image
- Self-filter: hide alliance/war/neutral icons for the local player’s own name
- Overlay: remove relation icons from PlayerInfoOverlay; show text-only relation (Allied/Neutral/Hostile) for clarity

Rationale:
- Provide consistent visual indicators for neutral and at-war states where only allied icon existed
- Ensure color parity with radial menu (darker red for war) and avoid yellow tint
- Reduce clutter by not showing diplomacy icons for self and keeping the overlay textual

Notes:
- Assets used: resources/images/SwordIcon.svg (masked to #8B0000), proprietary/images/dove.png; alliance remains resources/images/AllianceIcon.svg
- No server or core changes; client-only UI update
- Remove Diplomacy from tab list and type definitions
- Stub out renderDiplomacyTab method (now returns empty template)
- Remove all Diplomacy tab UI code and event handlers

Rationale:
- Diplomacy relations are now displayed via NameLayer icons (allied/war/neutral)
- No need for separate tab UI when visual indicators are on the map
- Simplifies control panel and reduces clutter

Changes:
- Removed 'Diplomacy' from activeTab type union
- Removed Diplomacy tab button from UI
- Removed 180+ lines of diplomacy tab render logic
- Kept method signature for compatibility but returns empty html
- War icon now 20% smaller for better visual balance
- Use exact #8B0000 color via CSS mask (matches radial menu war button)
- Only show diplomacy icons for Human/FakeHuman players (not regular bots)
- Removed icon resize loop that caused flickering

Changes:
- NameLayer: war icon sized at 0.8x, uses CSS mask with #8B0000
- Added PlayerType check: isHumanOrFakeHuman filter for alliance/war/neutral icons
- Import PlayerType from Game.ts for type checking
- Simplified icon creation - stable sizing without constant updates
@1brucben 1brucben merged commit 272b5ca into v0.2.0 Dec 19, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants