Skip to content

Sprint 3.5: Alliance Wars N-vs-M — backend, API client, UI controller, tests - #105

Merged
makr-code merged 2 commits into
mainfrom
copilot/develop-alliance-wars-ui-backend
Apr 12, 2026
Merged

Sprint 3.5: Alliance Wars N-vs-M — backend, API client, UI controller, tests#105
makr-code merged 2 commits into
mainfrom
copilot/develop-alliance-wars-ui-backend

Conversation

Copilot AI commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

The existing war system only supported 1v1 player wars. This adds full N-vs-M alliance war support (2v2, 3v4, etc.) with declare/list/status/peace-offer endpoints, an API client layer, and a new UI controller.

Backend — api/alliance_wars.php (new)

Three new tables auto-created via aw_ensure_schema():

  • alliance_wars — war metadata (name, status, scores, exhaustion, casus belli)
  • alliance_war_sides — maps any number of alliance IDs to side 'a' or 'b'
  • alliance_war_peace_offers — tracks offers between parties

Five actions:

Action Method Key behaviour
declare POST side_a/side_b arrays; validates no overlap, ≤8/side, leader/diplomat auth, no duplicate active wars
list GET returns all wars where user's alliance participates
get_status GET full war detail incl. sides, scores, peace offers
offer_peace POST from a specific alliance on your side
respond_peace POST accept (ends war) or reject

Example declare payload:

{
  "side_a": [1, 3],
  "side_b": [2, 4, 5],
  "casus_belli": "Territorial aggression"
}

War name is auto-generated as [IF]+[VP] vs [SE]+[DN]+[AL] when omitted.

API client — js/network/api.js

Five new methods: allianceWars(), allianceWarStatus(warId), declareAllianceWar(), offerAlliancePeace(), respondAlliancePeaceOffer(). Added cache TTL entries and POST-invalidation pattern for api/alliance_wars.php.

UI — RuntimeWarController.js

New createAllianceWarController() factory (existing createWarController() untouched):

  • List view: table with side A / side B alliance tag lists, score bar, "Your Side" column
  • Declare form: comma-separated alliance ID inputs per side + optional war name / casus belli
  • Detail view: side panels showing all participating alliances, score/exhaustion cards, peace offer section with accept/reject
  • Peace offer sender's own offer shows "Awaiting response"; incoming offers show Accept / Reject buttons

Tests

  • tests/js/alliance-wars.test.js — 25 unit tests (factory, rendering, declare interaction, detail view, peace offer incoming vs outgoing)
  • tests/Unit/AllianceWarsTest.php — 26 PHPUnit tests (term normalization, war summary, alliance queries, load_sides including 3v4 config, expired offer marking, overlap detection, auto-name generation)

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:

  • https://api.github.com/repos/sebastianbergmann/exporter/zipball/70a298763b40b213ec087c51c739efcaa90bcd74
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/gnkcOf /usr/bin/composer install (http block)
  • https://api.github.com/repos/sebastianbergmann/global-state/zipball/3be331570a721f9a4b5917f4209773de17f747d7
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/gnkcOf /usr/bin/composer install (http block)
  • https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/f5b498e631a74204185071eb41f33f38d64608aa
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/gnkcOf /usr/bin/composer install (http block)
  • https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/6e1a43b411b2ad34146dee7524cb13a068bb35f9
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/gnkcOf /usr/bin/composer install (http block)
  • https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/f6458abbf32a6c8174f8f26261475dc133b3d9dc
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/gnkcOf /usr/bin/composer install (http block)
  • https://api.github.com/repos/sebastianbergmann/type/zipball/f77d2d4e78738c98d9a68d2596fe5e8fa380f449
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/gnkcOf /usr/bin/composer install (http block)
  • https://api.github.com/repos/sebastianbergmann/version/zipball/c687e3387b99f5b03b6caa64c74b63e2936ff874
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/gnkcOf /usr/bin/composer install (http block)
  • https://api.github.com/repos/staabm/side-effects-detector/zipball/d8334211a140ce329c13726d4a715adbddd0a163
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/gnkcOf /usr/bin/composer install (http block)

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

Copilot AI linked an issue Apr 12, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Develop backend and UI for multi-alliance wars Sprint 3.5: Alliance Wars N-vs-M — backend, API client, UI controller, tests Apr 12, 2026
Copilot AI requested a review from makr-code April 12, 2026 06:53
@makr-code
makr-code marked this pull request as ready for review April 12, 2026 06:55
@makr-code
makr-code merged commit 76c4a2d 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.5: Alliance Wars N-vs-M Szenarien

2 participants