From ee1be06d484de439df89557e59d43330b95699d2 Mon Sep 17 00:00:00 2001 From: unimatrixgit <95320811+unimatrixgit@users.noreply.github.com> Date: Fri, 20 Nov 2026 19:37:23 +0100 Subject: [PATCH] Isolate POL quest progression using the existing JARVIS engine --- .../cp-v2/cp-v2-pol-quest-catalogue.mjs | 1102 +++++++++++++++++ website/node/progression-pol.mjs | 28 + website/tests/progression-pol.test.mjs | 30 + 3 files changed, 1160 insertions(+) create mode 100644 website/control-panel/public/cp-v2/cp-v2-pol-quest-catalogue.mjs create mode 100644 website/node/progression-pol.mjs create mode 100644 website/tests/progression-pol.test.mjs diff --git a/website/control-panel/public/cp-v2/cp-v2-pol-quest-catalogue.mjs b/website/control-panel/public/cp-v2/cp-v2-pol-quest-catalogue.mjs new file mode 100644 index 00000000..2f955996 --- /dev/null +++ b/website/control-panel/public/cp-v2/cp-v2-pol-quest-catalogue.mjs @@ -0,0 +1,1102 @@ +// Server-owned content shared with the existing quest and POL Decision interfaces. +// Reward amounts, decision costs and timings require explicit configuration. +const freeze=v=>{if(v&&typeof v==='object'){Object.values(v).forEach(freeze);Object.freeze(v);}return v;}; +export const POL_QUEST_BRANCHES=freeze([ + { + "id": "atreides", + "office": "ATR", + "title": "House Aerdrecht", + "issuer": "thufir_hawat", + "issuerName": "Thufir Hawat", + "theme": "Intelligence, counterespionage and House loyalty", + "xpType": "pol", + "quests": [ + { + "id": "POL-ATREIDES-01", + "title": "Verify the Report", + "objective": "Verify an intelligence report against its authoritative sources.", + "metric": "pol-verified-report", + "target": 1, + "requires": [], + "requiresAny": [], + "branch": "atreides", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + }, + { + "id": "POL-ATREIDES-02", + "title": "A House Without Leaks", + "objective": "Complete a counterintelligence contract.", + "metric": "pol-counterintelligence", + "target": 1, + "requires": [ + "POL-ATREIDES-01" + ], + "requiresAny": [], + "branch": "atreides", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + }, + { + "id": "POL-ATREIDES-03", + "title": "The Reliable Witness", + "objective": "Complete a verified evidence dossier.", + "metric": "pol-evidence-dossier", + "target": 1, + "requires": [ + "POL-ATREIDES-02" + ], + "requiresAny": [], + "branch": "atreides", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + } + ], + "decisions": [ + { + "id": "POL-ATREIDES-D01", + "office": "ATR", + "category": "political", + "kind": "Decision", + "title": "Expand the Intelligence Network", + "effect": "Support intelligence quest rewards through a disclosed funded budget.", + "rewardScope": "intelligence", + "authority": "current-political-office-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + }, + { + "id": "POL-ATREIDES-D02", + "office": "ATR", + "category": "communal", + "kind": "Decision", + "title": "Strengthen House Loyalty", + "effect": "Support House-service quest rewards without granting political office.", + "rewardScope": "house-service", + "authority": "current-political-office-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + }, + { + "id": "POL-ATREIDES-D03", + "office": "ATR", + "category": "political", + "kind": "Decision", + "title": "Counterintelligence Sweep", + "effect": "Commission counterintelligence against eligible operations.", + "rewardScope": "counterintelligence", + "authority": "current-political-office-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + } + ] + }, + { + "id": "harkonnen", + "office": "HAR", + "title": "House Harkveen", + "issuer": "piter_de_vries", + "issuerName": "Piter de Vries", + "theme": "Sabotage, manipulation and covert operations", + "xpType": "pol", + "quests": [ + { + "id": "POL-HARKONNEN-01", + "title": "Pressure Points", + "objective": "Complete an eligible covert intelligence contract.", + "metric": "pol-covert-intelligence", + "target": 1, + "requires": [], + "requiresAny": [], + "branch": "harkonnen", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + }, + { + "id": "POL-HARKONNEN-02", + "title": "A Compromised Shipment", + "objective": "Complete an eligible sabotage or interdiction contract.", + "metric": "pol-sabotage", + "target": 1, + "requires": [ + "POL-HARKONNEN-01" + ], + "requiresAny": [], + "branch": "harkonnen", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + }, + { + "id": "POL-HARKONNEN-03", + "title": "The Hidden Beneficiary", + "objective": "Trace a contract beneficiary using verified evidence.", + "metric": "pol-beneficiary-investigation", + "target": 1, + "requires": [ + "POL-HARKONNEN-02" + ], + "requiresAny": [], + "branch": "harkonnen", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + } + ], + "decisions": [ + { + "id": "POL-HARKONNEN-D01", + "office": "HAR", + "category": "political", + "kind": "Decision", + "title": "Coordinate Covert Operations", + "effect": "Support verified covert-operation rewards from the authorised budget.", + "rewardScope": "covert", + "authority": "current-political-office-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + }, + { + "id": "POL-HARKONNEN-D02", + "office": "HAR", + "category": "economic", + "kind": "Decision", + "title": "Disrupt Rival Logistics", + "effect": "Commission eligible sabotage and interdiction contracts.", + "rewardScope": "interdiction", + "authority": "current-political-office-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + }, + { + "id": "POL-HARKONNEN-D03", + "office": "HAR", + "category": "communal", + "kind": "Decision", + "title": "Consolidate Internal Security", + "effect": "Support protection and counterintelligence contracts.", + "rewardScope": "protection", + "authority": "current-political-office-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + } + ] + }, + { + "id": "corrino", + "office": "COR", + "title": "House Korenholt", + "issuer": "hasimir_fenring", + "issuerName": "Count Hasimir Fenring", + "theme": "Imperial intelligence, diplomacy and covert work", + "xpType": "pol", + "quests": [ + { + "id": "POL-CORRINO-01", + "title": "The Emperor’s Dispatch", + "objective": "Deliver a verified confidential diplomatic dispatch.", + "metric": "pol-diplomatic-dispatch", + "target": 1, + "requires": [], + "requiresAny": [], + "branch": "corrino", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + }, + { + "id": "POL-CORRINO-02", + "title": "An Uncomfortable Agreement", + "objective": "Complete an authorised diplomatic agreement.", + "metric": "pol-diplomatic-agreement", + "target": 1, + "requires": [ + "POL-CORRINO-01" + ], + "requiresAny": [], + "branch": "corrino", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + }, + { + "id": "POL-CORRINO-03", + "title": "The Invisible Hand", + "objective": "Complete an eligible Imperial intelligence contract.", + "metric": "pol-imperial-intelligence", + "target": 1, + "requires": [ + "POL-CORRINO-02" + ], + "requiresAny": [], + "branch": "corrino", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + } + ], + "decisions": [ + { + "id": "POL-CORRINO-D01", + "office": "COR", + "category": "political", + "kind": "Decision", + "title": "Coordinate Imperial Intelligence", + "effect": "Support authorised Imperial intelligence quest rewards.", + "rewardScope": "intelligence", + "authority": "current-political-office-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + }, + { + "id": "POL-CORRINO-D02", + "office": "COR", + "category": "communal", + "kind": "Decision", + "title": "Secure Diplomatic Channels", + "effect": "Commission and support confidential diplomatic missions.", + "rewardScope": "diplomacy", + "authority": "current-political-office-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + }, + { + "id": "POL-CORRINO-D03", + "office": "COR", + "category": "economic", + "kind": "Decision", + "title": "Protect Imperial Supply", + "effect": "Support verified supply protection contracts.", + "rewardScope": "supply-protection", + "authority": "current-political-office-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + } + ] + }, + { + "id": "ordos", + "office": "ORD", + "title": "House Oordwijk", + "issuer": "roma_atani", + "issuerName": "Roma Atani", + "theme": "Economic espionage and strategic trade", + "xpType": "pol", + "quests": [ + { + "id": "POL-ORDOS-01", + "title": "Follow the Ledger", + "objective": "Verify a trade intelligence dossier.", + "metric": "pol-trade-intelligence", + "target": 1, + "requires": [], + "requiresAny": [], + "branch": "ordos", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + }, + { + "id": "POL-ORDOS-02", + "title": "A Market Opportunity", + "objective": "Complete a strategic procurement contract.", + "metric": "pol-strategic-procurement", + "target": 1, + "requires": [ + "POL-ORDOS-01" + ], + "requiresAny": [], + "branch": "ordos", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + }, + { + "id": "POL-ORDOS-03", + "title": "The Quiet Acquisition", + "objective": "Verify an eligible settled acquisition.", + "metric": "pol-settled-acquisition", + "target": 1, + "requires": [ + "POL-ORDOS-02" + ], + "requiresAny": [], + "branch": "ordos", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + } + ], + "decisions": [ + { + "id": "POL-ORDOS-D01", + "office": "ORD", + "category": "economic", + "kind": "Decision", + "title": "Expand Commercial Intelligence", + "effect": "Support economic intelligence quests through a funded budget.", + "rewardScope": "trade-intelligence", + "authority": "current-political-office-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + }, + { + "id": "POL-ORDOS-D02", + "office": "ORD", + "category": "economic", + "kind": "Decision", + "title": "Secure Strategic Supplies", + "effect": "Commission procurement of eligible strategic goods.", + "rewardScope": "procurement", + "authority": "current-political-office-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + }, + { + "id": "POL-ORDOS-D03", + "office": "ORD", + "category": "political", + "kind": "Decision", + "title": "Deploy Trade Advisers", + "effect": "Support diplomatic trade quests without transferring office authority.", + "rewardScope": "trade-diplomacy", + "authority": "current-political-office-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + } + ] + }, + { + "id": "fremen", + "office": "FRE", + "title": "Fremen", + "issuer": "stilgar", + "issuerName": "Stilgar", + "theme": "Water, spice, survival and tribal politics", + "xpType": "pol", + "quests": [ + { + "id": "POL-FREMEN-01", + "title": "Water Accounted For", + "objective": "Complete a verified water supply contract.", + "metric": "pol-water-supply", + "target": 1, + "requires": [], + "requiresAny": [], + "branch": "fremen", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + }, + { + "id": "POL-FREMEN-02", + "title": "The Spice Trail", + "objective": "Complete a verified spice transport contract.", + "metric": "pol-spice-transport", + "target": 1, + "requires": [ + "POL-FREMEN-01" + ], + "requiresAny": [], + "branch": "fremen", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + }, + { + "id": "POL-FREMEN-03", + "title": "An Obligation to the Sietch", + "objective": "Complete a verified sietch service mission.", + "metric": "pol-sietch-service", + "target": 1, + "requires": [ + "POL-FREMEN-02" + ], + "requiresAny": [], + "branch": "fremen", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + } + ], + "decisions": [ + { + "id": "POL-FREMEN-D01", + "office": "FRE", + "category": "economic", + "kind": "Decision", + "title": "Conserve the Water Reserves", + "effect": "Prioritise and support verified water supply quests.", + "rewardScope": "water-supply", + "authority": "current-political-office-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + }, + { + "id": "POL-FREMEN-D02", + "office": "FRE", + "category": "political", + "kind": "Decision", + "title": "Guard the Spice Routes", + "effect": "Commission eligible spice-route protection.", + "rewardScope": "spice-protection", + "authority": "current-political-office-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + }, + { + "id": "POL-FREMEN-D03", + "office": "FRE", + "category": "communal", + "kind": "Decision", + "title": "Fulfil the Sietch Obligations", + "effect": "Support verified service missions for the sietch.", + "rewardScope": "sietch-service", + "authority": "current-political-office-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + } + ] + }, + { + "id": "bene", + "office": "BG", + "title": "Veiled Concord", + "issuer": "jessica_atreides", + "issuerName": "Lady Jessica", + "theme": "Political influence, information and confidential diplomacy", + "xpType": "pol", + "quests": [ + { + "id": "POL-BENE-01", + "title": "The Sisterhood’s Whisper", + "objective": "Complete a confidential diplomatic assignment.", + "metric": "pol-confidential-diplomacy", + "target": 1, + "requires": [], + "requiresAny": [], + "branch": "bene", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + }, + { + "id": "POL-BENE-02", + "title": "Observe the Great Houses", + "objective": "Verify a political intelligence dossier.", + "metric": "pol-political-intelligence", + "target": 1, + "requires": [ + "POL-BENE-01" + ], + "requiresAny": [], + "branch": "bene", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + }, + { + "id": "POL-BENE-03", + "title": "A Confidential Accord", + "objective": "Complete an authorised confidential agreement.", + "metric": "pol-confidential-agreement", + "target": 1, + "requires": [ + "POL-BENE-02" + ], + "requiresAny": [], + "branch": "bene", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + } + ], + "decisions": [ + { + "id": "POL-BENE-D01", + "office": "BG", + "category": "political", + "kind": "Decision", + "title": "Activate the Sisterhood’s Network", + "effect": "Support intelligence quests with an explicitly funded reward bonus.", + "rewardScope": "intelligence", + "authority": "current-political-office-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + }, + { + "id": "POL-BENE-D02", + "office": "BG", + "category": "political", + "kind": "Decision", + "title": "Place a Political Adviser", + "effect": "Support an eligible organisation’s diplomatic quests without governing rights.", + "rewardScope": "diplomacy", + "authority": "current-political-office-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + }, + { + "id": "POL-BENE-D03", + "office": "BG", + "category": "communal", + "kind": "Decision", + "title": "Invoke the Missionaria Protectiva", + "effect": "Open and support a reviewed influence and reputation quest branch.", + "rewardScope": "influence", + "authority": "current-political-office-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + } + ] + }, + { + "id": "guild", + "office": "SG", + "title": "Spacing Guild", + "issuer": "guild_navigator", + "issuerName": "Guild Navigator", + "theme": "Transport, logistics and trade routes", + "xpType": "pol", + "quests": [ + { + "id": "POL-GUILD-01", + "title": "Chart the Passage", + "objective": "Verify a permitted transport route.", + "metric": "pol-verified-route", + "target": 1, + "requires": [], + "requiresAny": [], + "branch": "guild", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + }, + { + "id": "POL-GUILD-02", + "title": "A Reliable Manifest", + "objective": "Complete a shipment with a verified manifest.", + "metric": "pol-verified-manifest", + "target": 1, + "requires": [ + "POL-GUILD-01" + ], + "requiresAny": [], + "branch": "guild", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + }, + { + "id": "POL-GUILD-03", + "title": "Keep the Routes Open", + "objective": "Complete an eligible route protection or supply contract.", + "metric": "pol-route-service", + "target": 1, + "requires": [ + "POL-GUILD-02" + ], + "requiresAny": [], + "branch": "guild", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + } + ], + "decisions": [ + { + "id": "POL-GUILD-D01", + "office": "SG", + "category": "economic", + "kind": "Decision", + "title": "Secure the Shipping Lanes", + "effect": "Commission and support eligible transport protection.", + "rewardScope": "transport-protection", + "authority": "current-political-office-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + }, + { + "id": "POL-GUILD-D02", + "office": "SG", + "category": "economic", + "kind": "Decision", + "title": "Coordinate Guild Logistics", + "effect": "Support verified transport quest rewards.", + "rewardScope": "transport", + "authority": "current-political-office-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + }, + { + "id": "POL-GUILD-D03", + "office": "SG", + "category": "political", + "kind": "Decision", + "title": "Negotiate Passage", + "effect": "Use existing transport authority to support permitted-route diplomacy.", + "rewardScope": "route-diplomacy", + "authority": "current-political-office-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + } + ] + }, + { + "id": "smugglers", + "office": null, + "title": "Smuggler Network", + "issuer": null, + "issuerName": null, + "theme": "Clandestine transport and opposing contracts", + "xpType": "pol", + "quests": [ + { + "id": "POL-SMUGGLERS-01", + "title": "A Quiet Introduction", + "objective": "Accept an authorised introduction to the underground network.", + "metric": "pol-smuggler-introduction", + "target": 1, + "requires": [], + "requiresAny": [], + "branch": "smugglers", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + }, + { + "id": "POL-SMUGGLERS-02", + "title": "Sealed Cargo", + "objective": "Deliver the exact contracted cargo and quantity.", + "metric": "pol-sealed-cargo", + "target": 1, + "requires": [ + "POL-SMUGGLERS-01" + ], + "requiresAny": [], + "branch": "smugglers", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + }, + { + "id": "POL-SMUGGLERS-03", + "title": "Beyond the Manifest", + "objective": "Complete a verified restricted-cargo delivery.", + "metric": "pol-restricted-delivery", + "target": 1, + "requires": [ + "POL-SMUGGLERS-02" + ], + "requiresAny": [], + "branch": "smugglers", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + }, + { + "id": "POL-SMUGGLERS-04", + "title": "The Alternate Route", + "objective": "Deliver through the contract’s selected eligible route.", + "metric": "pol-alternate-route", + "target": 1, + "requires": [ + "POL-SMUGGLERS-03" + ], + "requiresAny": [], + "branch": "smugglers", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + }, + { + "id": "POL-SMUGGLERS-05", + "title": "Eyes on the Shipment", + "objective": "Win a delivery contract opposed by eligible interdiction.", + "metric": "pol-opposed-delivery", + "target": 1, + "requires": [ + "POL-SMUGGLERS-04" + ], + "requiresAny": [], + "branch": "smugglers", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + }, + { + "id": "POL-SMUGGLERS-06", + "title": "Ghost Cargo", + "objective": "Complete distinct qualifying advanced deliveries.", + "metric": "pol-ghost-cargo", + "target": 1, + "requires": [ + "POL-SMUGGLERS-05" + ], + "requiresAny": [], + "branch": "smugglers", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + } + ], + "decisions": [ + { + "id": "POL-SMUGGLERS-D01", + "office": null, + "category": "economic", + "kind": "Decision", + "title": "Establish a Shadow Route", + "effect": "Support eligible clandestine deliveries on a scoped route.", + "rewardScope": "clandestine-transport", + "authority": "current-protected-organisation-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + }, + { + "id": "POL-SMUGGLERS-D02", + "office": null, + "category": "economic", + "kind": "Decision", + "title": "Finance Discreet Logistics", + "effect": "Reserve disclosed funding for clandestine transport contracts.", + "rewardScope": "clandestine-funding", + "authority": "current-protected-organisation-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + }, + { + "id": "POL-SMUGGLERS-D03", + "office": null, + "category": "political", + "kind": "Decision", + "title": "Protect the Network", + "effect": "Commission counterintelligence and protection for eligible operations.", + "rewardScope": "counterintelligence", + "authority": "current-protected-organisation-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + } + ] + }, + { + "id": "clan", + "office": null, + "title": "Clan contracts", + "issuer": null, + "issuerName": null, + "theme": "Escort, interdiction, protection and counterintelligence", + "xpType": "pol", + "quests": [ + { + "id": "POL-CLAN-01", + "title": "Escort the Caravan", + "objective": "Complete an eligible escort contract.", + "metric": "pol-escort", + "target": 1, + "requires": [], + "requiresAny": [], + "branch": "clan", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + }, + { + "id": "POL-CLAN-02", + "title": "Close the Passage", + "objective": "Complete an eligible interdiction contract.", + "metric": "pol-interdiction", + "target": 1, + "requires": [ + "POL-CLAN-01" + ], + "requiresAny": [], + "branch": "clan", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + }, + { + "id": "POL-CLAN-03", + "title": "Bring Them Home", + "objective": "Recover contracted cargo for its verified beneficiary.", + "metric": "pol-cargo-recovery", + "target": 1, + "requires": [ + "POL-CLAN-02" + ], + "requiresAny": [], + "branch": "clan", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + }, + { + "id": "POL-CLAN-04", + "title": "An Unbroken Watch", + "objective": "Complete a protection assignment.", + "metric": "pol-protection", + "target": 1, + "requires": [ + "POL-CLAN-03" + ], + "requiresAny": [], + "branch": "clan", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + } + ], + "decisions": [ + { + "id": "POL-CLAN-D01", + "office": null, + "category": "political", + "kind": "Decision", + "title": "Mobilise the Escorts", + "effect": "Fund a temporary quest-reward bonus for eligible escorts.", + "rewardScope": "escort", + "authority": "current-organisation-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + }, + { + "id": "POL-CLAN-D02", + "office": null, + "category": "political", + "kind": "Decision", + "title": "Counterintelligence Sweep", + "effect": "Commission eligible counterintelligence work.", + "rewardScope": "counterintelligence", + "authority": "current-organisation-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + }, + { + "id": "POL-CLAN-D03", + "office": null, + "category": "economic", + "kind": "Decision", + "title": "Secure the Passage", + "effect": "Commission eligible route protection.", + "rewardScope": "route-protection", + "authority": "current-organisation-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + } + ] + }, + { + "id": "company", + "office": null, + "title": "Company contracts", + "issuer": null, + "issuerName": null, + "theme": "Procurement, finance and non-PvP logistics", + "xpType": "pol", + "quests": [ + { + "id": "POL-COMPANY-01", + "title": "A Reliable Supplier", + "objective": "Complete a verified procurement delivery.", + "metric": "pol-procurement", + "target": 1, + "requires": [], + "requiresAny": [], + "branch": "company", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + }, + { + "id": "POL-COMPANY-02", + "title": "The Missing Consignment", + "objective": "Commission and verify recovery by an eligible clan.", + "metric": "pol-commissioned-recovery", + "target": 1, + "requires": [ + "POL-COMPANY-01" + ], + "requiresAny": [], + "branch": "company", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + }, + { + "id": "POL-COMPANY-03", + "title": "Discreet Logistics", + "objective": "Complete an eligible clandestine transport contract.", + "metric": "pol-discreet-logistics", + "target": 1, + "requires": [ + "POL-COMPANY-02" + ], + "requiresAny": [], + "branch": "company", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + }, + { + "id": "POL-COMPANY-04", + "title": "A Price for Protection", + "objective": "Complete a delivery protected by a contracted clan.", + "metric": "pol-protected-delivery", + "target": 1, + "requires": [ + "POL-COMPANY-03" + ], + "requiresAny": [], + "branch": "company", + "season": "S01", + "revision": 1, + "optional": false, + "verifiedOnly": true, + "xpType": "pol" + } + ], + "decisions": [ + { + "id": "POL-COMPANY-D01", + "office": null, + "category": "economic", + "kind": "Decision", + "title": "Secure the Supply Chain", + "effect": "Support verified procurement and recovery quests.", + "rewardScope": "supply", + "authority": "current-organisation-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + }, + { + "id": "POL-COMPANY-D02", + "office": null, + "category": "economic", + "kind": "Decision", + "title": "Finance Discreet Logistics", + "effect": "Fund eligible clandestine transport contracts.", + "rewardScope": "clandestine-funding", + "authority": "current-organisation-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + }, + { + "id": "POL-COMPANY-D03", + "office": null, + "category": "political", + "kind": "Decision", + "title": "Commission Caravan Protection", + "effect": "Hire eligible clan escorts; the company gains no PvP rights.", + "rewardScope": "escort", + "authority": "current-organisation-deed", + "requiresFunding": true, + "executionStatus": "requires-domain-configuration", + "xpType": "pol" + } + ] + } +]); +export const POL_QUEST_DEFINITIONS=Object.freeze(POL_QUEST_BRANCHES.flatMap(b=>b.quests)); +export function polBranch(id){return POL_QUEST_BRANCHES.find(b=>b.id===id||b.office===id)||null;} diff --git a/website/node/progression-pol.mjs b/website/node/progression-pol.mjs new file mode 100644 index 00000000..e08bd25c --- /dev/null +++ b/website/node/progression-pol.mjs @@ -0,0 +1,28 @@ +import {PROGRESSION_SCHEMA} from './progression-schema.mjs'; +import {createQuestProgression} from './progression-quests.mjs'; +import {POL_QUEST_DEFINITIONS} from '../control-panel/public/cp-v2/cp-v2-pol-quest-catalogue.mjs'; +// Reuse the quest engine with a fixed, server-owned storage namespace. Account +// identity, authority and organisation keys remain in their original stores. +const tables=new Map(PROGRESSION_SCHEMA.map(sql=>{const name=sql.match(/CREATE TABLE IF NOT EXISTS ([a-z_]+)/)[1];return[name,name.replace(/^jarvis_/,'jarvis_pol_')];})); +export const polProgressionSQL=sql=>sql.replace(/\bjarvis_[a-z_]+\b/g,name=>tables.get(name)||name); +export function polProgressionStore(db){ + const query=(sql,args=[])=>db.query(polProgressionSQL(sql),args); + const first=async(sql,args=[])=>{const rows=await query(sql,args);return rows[0]||null;}; + return {query,first,transaction:work=>db.transaction(tx=>work(polProgressionStore(tx)))}; +} +export async function initializePOLProgression(db){for(const sql of PROGRESSION_SCHEMA)await db.query(polProgressionSQL(sql));} +const scoped=scope=>{if(!/^S\d{2,4}:[A-Za-z0-9_-]+$/.test(scope))throw Error('Invalid POL quest scope');return scope.replace(':',':POL_');}; +const unscoped=scope=>{if(!/^S\d{2,4}:POL_/.test(scope))throw Error('POL quest scope mismatch');return scope.replace(':POL_',':');}; +export function polQuestKeys(keys){return Object.freeze({ + issue:input=>{if(input.keyType!=='quest')throw Error('Only POL quest instruments are supported');return keys.issue({...input,scopeId:scoped(input.scopeId),authorize:(tx,context)=>input.authorize(polProgressionStore(tx),{...context,scopeId:unscoped(context.scopeId)})});}, + list:async id=>(await keys.list(id)).filter(k=>k.keyType==='quest'&&/^S\d{2,4}:POL_/.test(k.scopeId)).map(k=>({...k,scopeId:unscoped(k.scopeId)})), + consume:async input=>{ + if(input.keyType!=='quest')throw Error('Only POL quest instruments are supported'); + const own=(await keys.list(input.accountId)).find(k=>k.code===input.code&&k.keyType==='quest'&&/^S\d{2,4}:POL_/.test(k.scopeId)); + if(!own)throw Error('POL quest instrument unavailable'); + return keys.consume({...input,apply:(tx,context)=>input.apply(polProgressionStore(tx),{...context,scopeId:unscoped(context.scopeId)})}); + } +});} +export function createPOLProgression(db,keys,adapters){ + return createQuestProgression(polProgressionStore(db),polQuestKeys(keys),{...adapters,definitions:POL_QUEST_DEFINITIONS}); +} diff --git a/website/tests/progression-pol.test.mjs b/website/tests/progression-pol.test.mjs new file mode 100644 index 00000000..ad85ad97 --- /dev/null +++ b/website/tests/progression-pol.test.mjs @@ -0,0 +1,30 @@ +import test from 'node:test';import assert from 'node:assert/strict';import {randomUUID} from 'node:crypto'; +import {companyFixture} from './company-deed-fixture.mjs'; +import {initializeProgression} from '../node/progression-schema.mjs'; +import {createQuestProgression} from '../node/progression-quests.mjs'; +import {createPOLProgression,initializePOLProgression,polQuestKeys,polProgressionSQL} from '../node/progression-pol.mjs'; +import {POL_QUEST_DEFINITIONS} from '../control-panel/public/cp-v2/cp-v2-pol-quest-catalogue.mjs'; +async function fixture(){const f=await companyFixture();await initializeProgression(f.db);await initializePOLProgression(f.db);const d=POL_QUEST_DEFINITIONS[0]; + for(const prefix of ['jarvis_','jarvis_pol_']){ + await f.db.query(`INSERT INTO ${prefix}progression_seasons(season_id,starts_at,ends_at,level_cap,curve_base,state) VALUES('S01',0,5000,70,25,'active')`); + await f.db.query(`INSERT INTO ${prefix}quest_config(definition_id,revision,xp,reward_json,updated_by,updated_at) VALUES(?,1,150,NULL,?,0)`,[d.id,f.people.Owner.id]); + } + const observer={},adapters={clock:()=>2000,authorizePlayer:async actor=>actor.id===f.people.Member.id,authorizeObservation:async actor=>actor===observer,verifyAcquisition:async()=>false,resolvePlayer:async id=>id===f.people.Member.id?f.people.Member:null}; + return {...f,d,observer,personal:createQuestProgression(f.db,f.keys,{...adapters,definitions:[d]}),pol:createPOLProgression(f.db,f.keys,adapters)}; +} +test('POL reuses the quest engine while preserving personal XP, observations and QST identities',async()=>{const f=await fixture();try{ + const personal=await f.personal.start(f.people.Member,{definitionId:f.d.id}),pol=await f.pol.start(f.people.Member,{definitionId:f.d.id});assert.notEqual(personal.id,pol.id); + await f.pol.observe(f.observer,{accountId:f.people.Member.id,seasonId:'S01',metric:f.d.metric,value:1,eventId:randomUUID(),source:'verified-test'}); + const request={definitionId:f.d.id,revision:1,requestId:randomUUID()};await f.pol.claim(f.people.Member,request);assert.equal((await f.pol.claim(f.people.Member,request)).replayed,true); + assert.equal((await f.db.first('SELECT total_xp FROM jarvis_pol_progression_accounts WHERE account_id=?',[f.people.Member.id])).total_xp,150); + assert.equal((await f.db.first('SELECT total_xp FROM jarvis_progression_accounts WHERE account_id=?',[f.people.Member.id])).total_xp,0); + assert.equal((await f.db.query('SELECT * FROM jarvis_progression_observations')).length,0); + assert.equal((await f.db.query('SELECT * FROM jarvis_pol_quest_claims')).length,1); + await assert.rejects(f.personal.claim(f.people.Member,{...request,requestId:randomUUID()}),/not complete/); + const raw=(await f.keys.list(f.people.Member.id)).find(k=>k.id===personal.id); + await assert.rejects(polQuestKeys(f.keys).consume({accountId:f.people.Member.id,keyType:'quest',code:raw.code,targetId:f.people.Member.id,requestId:randomUUID(),apply:async()=>{throw Error('must not execute');}}),/unavailable/); + }finally{f.db.close();}}); +test('namespace mapping is restricted to known progression tables and leaves identity/key stores intact',()=>{ + assert.equal(polProgressionSQL('SELECT * FROM jarvis_progression_accounts JOIN organisation_keys JOIN site_accounts JOIN jarvis_entity_state_events'),'SELECT * FROM jarvis_pol_progression_accounts JOIN organisation_keys JOIN site_accounts JOIN jarvis_entity_state_events'); + assert.ok(POL_QUEST_DEFINITIONS.every(d=>d.verifiedOnly&&d.xpType==='pol')); +});