Skip to content

feat(diplomacy): Sprint 3.2 – Diplomatic Plays 4-Phase Escalation System#104

Merged
makr-code merged 2 commits into
mainfrom
copilot/implement-escalation-model
Apr 12, 2026
Merged

feat(diplomacy): Sprint 3.2 – Diplomatic Plays 4-Phase Escalation System#104
makr-code merged 2 commits into
mainfrom
copilot/implement-escalation-model

Conversation

Copilot AI commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

The game had a basic treaty system but no escalation model. This implements the full Cooperation → Threat → Ultimatum → War pipeline with Trust/Threat as independent bilateral axes, per the design doc (GAMEPLAY_DATA_MODEL.md §6.4).

Data Layer

  • sql/migrate_diplomatic_plays_v1.sql — adds trust_level, threat_level, trust_decay_rate to diplomacy table; creates diplomatic_plays table tracking phase, timestamps, demands, outcome, and trust/threat snapshots

Backend (api/diplomatic_plays.php)

Six actions: propose_play (opens Cooperation phase, +3 trust), counter_play (→ Threat, −5 trust, +10 threat), mobilize (→ Ultimatum, −10 trust, +10 threat), resolve (deal/war/withdrawal with standing + trust/threat deltas), trust_threat, list. AI acceptance probability factors in current trust, threat, faction aggression, and current phase:

function dp_ai_accept_pct(float $trust, float $threat, int $aggression, string $phase): int {
    $base = 50 + (int)($trust * 0.3);
    $base -= (int)($threat * 0.25);
    $base -= match($phase) { 'cooperation'=>0, 'threat'=>15, 'ultimatum'=>30, default=>50 };
    $base -= (int)(($aggression / 100) * 20);
    return max(5, min(95, (int)$base));
}

War resolution attempts to insert into a wars table if it exists (graceful no-op otherwise).

Frontend

  • RuntimeDiplomaticPlaysDataModel.js — pure data model: phase/goal/outcome metadata, trustBarHTML() (−100..+100 normalised), threatBarHTML() (0..100), phaseStepperHTML() (done/active/pending steps), playCardHTML() (contextual action buttons per phase)
  • RuntimeDiplomaticPlaysPanel.js — renders Trust/Threat bars, active/historical play cards, new-play form; handles all phase transitions with confirmation guards on destructive actions

Wiring

  • api.js — 6 new methods (diplomaticPlaysList, diplomaticPlaysTrustThreat, diplomaticPlaysPropose, diplomaticPlaysCounter, diplomaticPlaysMobilize, diplomaticPlaysResolve)
  • RuntimeFactionsController.js — adds 🎭 Plays tab button + plays mode handler alongside existing treaties mode
  • RuntimeSocialControllersBootstrap.js + game.js — instantiate and wire both new runtime modules

Tests

38 unit tests in tests/js/diplomatic-plays.test.js covering phase ordering, index lookups, trust/threat bar clamping/coloring, phase stepper done/active/pending counts, play card action button variants, and panel render/interaction flows.

Copilot AI linked an issue Apr 12, 2026 that may be closed by this pull request
…tion system

- SQL migration: trust/threat columns + diplomatic_plays table
- Backend API: api/diplomatic_plays.php (propose_play, counter_play, mobilize, resolve, trust_threat, list)
- Frontend: RuntimeDiplomaticPlaysDataModel.js + RuntimeDiplomaticPlaysPanel.js
- Network: add diplomatic plays methods to api.js
- Wiring: game.js + SocialControllersBootstrap + FactionsController
- Tests: 38 unit tests in tests/js/diplomatic-plays.test.js
- Docs: update ROADMAP.md and IMPLEMENTATION_AUDIT.md

Agent-Logs-Url: https://github.com/makr-code/GalaxyQuest/sessions/1bcb83de-f4cb-4f24-8bc5-b7844a738ce9

Co-authored-by: makr-code <150588092+makr-code@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement escalation model for diplomacy phases feat(diplomacy): Sprint 3.2 – Diplomatic Plays 4-Phase Escalation System Apr 12, 2026
Copilot AI requested a review from makr-code April 12, 2026 06:47
@makr-code
makr-code marked this pull request as ready for review April 12, 2026 06:49
@makr-code
makr-code merged commit f63f6a2 into main Apr 12, 2026
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.

Sprint 3.2: Diplomatic Plays: 4-Phasen-System

2 participants