Connect Ordos acquisition to native Exchange and verify genuine settled payment
This commit is contained in:
parent
80d0e717b9
commit
2a5fca0583
4 changed files with 27 additions and 2 deletions
|
|
@ -108,6 +108,7 @@ final class QuestMenus implements Listener {
|
|||
if(kind.equals("pol")&&Set.of("POL-ELYTRA-REFINE","POL-ELYTRA-CONTAMINATE","POL-SPICE-UPGRADE-REFINE","POL-SPICE-UPGRADE-CONTAMINATE").contains(text(row,"id",""))&&(yes(row,"canStart")||Set.of("active","completed","claimed").contains(state)))put(screen,33,"Refine at NPC","Stand near an Arrakis Smuggler.\nTurn in the ingredients shown in this quest.",Material.ORANGE_DYE,()->refine(p,kind,data,branch,page,row));
|
||||
if(kind.equals("pol")&&text(row,"id","").equals("POL-SMUGGLERS-01")&&!state.equals("claimed")&&(yes(row,"canStart")||state.equals("active")))put(screen,33,"Meet the underground network","Stand near an Arrakis Smuggler.\nAccept Esmar Tuek’s introduction, then claim the quest.",Material.ORANGE_DYE,()->{try{bridge.smugglerIntroduction(p);p.sendMessage("Introduction recorded. Refresh this quest in a few seconds.");}catch(Exception failure){p.sendMessage(failure.getMessage()==null?"Visit an Arrakis Smuggler first.":failure.getMessage());}});
|
||||
if(kind.equals("pol")&&Set.of("POL-BOUNTY-01","POL-BOUNTY-02").contains(text(row,"id",""))&&!state.equals("claimed"))put(screen,33,"View active bounty jobs","On Arrakis, use the native bounty list and accept a target.",Material.MAP,()->{p.closeInventory();p.performCommand("dune bounty");});
|
||||
if(kind.equals("pol")&&text(row,"id","").equals("POL-ORDOS-03")&&state.equals("active")&&!yes(row,"canClaim"))put(screen,33,"Open Exchange","Buy one item from another seller. The actual settled central payment will verify this mission.",Material.GOLD_INGOT,()->{p.closeInventory();p.performCommand("exchange");});
|
||||
if(kind.equals("pol")&&row.has("research")&&!state.equals("claimed")&&(yes(row,"canStart")||state.equals("active")||state.equals("completed")))put(screen,33,"Submit research samples","Stand near Gurney Halleck.\nSurrender the materials shown in this quest.",Material.SMITHING_TABLE,()->research(p,kind,branch,page,row));
|
||||
if(kind.equals("pol")&&Set.of("pol-jerboa-meat-25","pol-jerboa-meat-50").contains(text(row,"metric",""))&&!state.equals("claimed")&&!yes(row,"canClaim")&&(yes(row,"canStart")||state.equals("active")))put(screen,33,"Surrender cooked Jerboa meat","Stand near Shadout Mapes on Arrakis.\nSurrender the required genuine cooked Jerboa meat; no reuse of previous turn-ins.",Material.COOKED_RABBIT,()->meatTurnin(p,kind,branch,page,row));
|
||||
if(kind.equals("pol")&&row.has("supply")&&!row.get("supply").isJsonNull()&&!state.equals("claimed")&&!yes(row,"canClaim")&&(yes(row,"canStart")||state.equals("active"))){var supply=row.getAsJsonObject("supply");put(screen,33,"Surrender mission supplies","Stand near "+text(supply,"contact","the mission contact")+".\nSurrender "+supply.get("quantity").getAsInt()+" genuine "+text(supply,"label","supplies")+".",Material.CHEST,()->supplyTurnin(p,kind,branch,page,row));}
|
||||
|
|
|
|||
|
|
@ -1111,7 +1111,7 @@ export const POL_QUEST_BRANCHES=freeze([
|
|||
ELYTRA_BRANCH,
|
||||
WAR_QUEST_BRANCH
|
||||
]);
|
||||
const gameplayMetrics=new Set(['pol-verified-report','pol-counterintelligence','pol-evidence-dossier','pol-covert-intelligence','pol-beneficiary-investigation','pol-diplomatic-dispatch','pol-diplomatic-agreement','pol-imperial-intelligence','pol-trade-intelligence','pol-confidential-diplomacy','pol-political-intelligence','pol-confidential-agreement','pol-smuggler-introduction','pol-sabotage','pol-water-supply','pol-procurement','pol-strategic-procurement','pol-spice-transport','pol-sietch-service','pol-verified-route','pol-verified-manifest','pol-route-service','pol-sealed-cargo','pol-restricted-delivery','pol-alternate-route','pol-opposed-delivery','pol-ghost-cargo','pol-escort','pol-interdiction','pol-cargo-recovery','pol-protection','pol-commissioned-recovery','pol-discreet-logistics','pol-protected-delivery']);
|
||||
const gameplayMetrics=new Set(['pol-verified-report','pol-counterintelligence','pol-evidence-dossier','pol-covert-intelligence','pol-beneficiary-investigation','pol-diplomatic-dispatch','pol-diplomatic-agreement','pol-imperial-intelligence','pol-trade-intelligence','pol-confidential-diplomacy','pol-political-intelligence','pol-confidential-agreement','pol-smuggler-introduction','pol-sabotage','pol-water-supply','pol-procurement','pol-strategic-procurement','pol-settled-acquisition','pol-spice-transport','pol-sietch-service','pol-verified-route','pol-verified-manifest','pol-route-service','pol-sealed-cargo','pol-restricted-delivery','pol-alternate-route','pol-opposed-delivery','pol-ghost-cargo','pol-escort','pol-interdiction','pol-cargo-recovery','pol-protection','pol-commissioned-recovery','pol-discreet-logistics','pol-protected-delivery']);
|
||||
const withDialogue=d=>Object.freeze({...d,npcRole:polQuestContact(d),dialogue:polQuestDialogue(d)});
|
||||
export const POL_QUEST_DEFINITIONS=Object.freeze(POL_QUEST_BRANCHES.flatMap(b=>b.quests.map((q,index)=>withDialogue({...q,issuer:q.issuer||b.issuer||({smugglers:"esmar_tuek",clan:"gurney_halleck",company:"roma_atani"})[b.id],issuerName:q.issuerName||b.issuerName||({smugglers:"Esmar Tuek",clan:"Gurney Halleck",company:"Roma Atani"})[b.id],objective:q.objective,xp:q.xp??150+index*50,executionRequirements:Object.freeze({website:true,minecraft:gameplayMetrics.has(q.metric)||['elytra','war-service','fremen-husbandry','bounty-jobs','spice-upgrading'].includes(q.branch)})}))));
|
||||
export function polBranch(id){return POL_QUEST_BRANCHES.find(b=>b.id===id||b.office===id)||null;}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import {starterIdentity} from './starter-kit-native-design.mjs';
|
|||
// Reuses the same posted Exchange payment proof as the existing personal quest.
|
||||
// Only a purchase after accepting the named Ordos mission is eligible.
|
||||
export async function collectPOLAcquisition(central,bank,keys,actor,{clock=Date.now}={}){
|
||||
if(!bank||!keys)return;const now=clock();const rows=await central.query("SELECT s.started_at,s.key_id,s.season_id,l.minecraft_uuid FROM jarvis_pol_quest_states s JOIN organisation_keys k ON k.id=s.key_id AND k.revoked_at IS NULL AND k.used_at IS NULL JOIN site_game_links l ON l.user_id=s.account_id JOIN site_character_choices c ON c.user_id=s.account_id AND c.minecraft_uuid=l.minecraft_uuid AND c.faction='ordos' JOIN jarvis_pol_progression_seasons season ON season.season_id=s.season_id AND season.state='active' AND season.starts_at<=? AND season.ends_at>? WHERE s.account_id=? AND s.definition_id='POL-ORDOS-03' AND s.state='active'",[now,now,actor.id]);if(rows.length!==1)return;const quest=rows[0];
|
||||
if(!bank||!keys)return;const now=clock();const rows=await central.query("SELECT s.started_at,s.key_id,s.season_id,l.minecraft_uuid FROM jarvis_pol_quest_states s JOIN organisation_keys k ON k.id=s.key_id AND k.account_id=s.account_id AND k.revoked_at IS NULL AND k.used_at IS NULL JOIN site_game_links l ON l.user_id=s.account_id JOIN site_character_choices c ON c.user_id=s.account_id AND c.minecraft_uuid=l.minecraft_uuid AND c.faction='ordos' JOIN jarvis_pol_progression_seasons season ON season.season_id=s.season_id AND season.state='active' AND season.starts_at<=? AND season.ends_at>? WHERE s.account_id=? AND s.definition_id='POL-ORDOS-03' AND s.state='active'",[now,now,actor.id]);if(rows.length!==1)return;const quest=rows[0];
|
||||
const candidates=await bank.query(verifiedExchangePurchases+' ORDER BY o.posted_at,o.id LIMIT 1',[actor.id,actor.id,Number(quest.started_at),now+1]);if(candidates.length!==1)return;const order=candidates[0],eventId=starterIdentity('pol-ordos-acquisition:'+quest.key_id+':'+order.id),producer=Object.freeze({source:'posted-exchange-mission'});
|
||||
const events=createPOLActivityEvents(central,keys,{clock,authorizeProducer:async(source,input)=>source===producer&&input.metric==='pol-settled-acquisition'&&input.eventId===eventId&&input.reference==='bank-exchange:'+order.id});await events.record(producer,{eventId,accountId:actor.id,minecraftUuid:quest.minecraft_uuid.toLowerCase(),seasonId:quest.season_id,metric:'pol-settled-acquisition',quantity:1,occurredAt:Number(order.posted_at),reference:'bank-exchange:'+order.id});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import {DatabaseSync} from 'node:sqlite';
|
||||
import {collectPOLAcquisition} from '../node/pol-acquisition-evidence.mjs';
|
||||
import test from 'node:test';import assert from 'node:assert/strict';import {randomUUID} from 'node:crypto';
|
||||
import {systemCharacterFixture} from './system-character-fixture.mjs';
|
||||
import {initializeProgression} from '../node/progression-schema.mjs';
|
||||
|
|
@ -201,4 +203,26 @@ test('company recovery escrows actual cargo for the assigned clan carrier, requi
|
|||
await service.record(receipt);await service.record(receipt);
|
||||
for(const [person,q] of [[f.actor,companyQuest],[f.other,clanQuest]]){await f.runtime.collect(person);assert.equal((await f.runtime.quests.list(person)).quests.find(x=>x.id===q.id).canClaim,true);}
|
||||
}finally{f.db.close();}
|
||||
});
|
||||
test('Ordos acquisition is available in Minecraft and counts only one settled Exchange purchase after mission acceptance',async()=>{
|
||||
const f=await setup(),sql=new DatabaseSync(':memory:');try{
|
||||
await f.characters.provision(f.people.Owner,'roma_atani');await f.db.query("UPDATE site_character_choices SET faction='ordos' WHERE user_id=?",[f.actor.id]);
|
||||
const clock=()=>f.base().occurredAt,producer={},activity=createPOLActivityEvents(f.db,f.keys,{clock,authorizeProducer:async who=>who===producer});
|
||||
for(const [id,metric] of [['POL-ORDOS-01','pol-trade-intelligence'],['POL-ORDOS-02','pol-strategic-procurement']]){
|
||||
await f.runtime.quests.start(f.actor,{definitionId:id});
|
||||
await activity.record(producer,{eventId:randomUUID(),accountId:f.actor.id,minecraftUuid:f.uuid,seasonId:'S01',metric,quantity:1,occurredAt:clock(),reference:'fixture-prerequisite'});
|
||||
await f.runtime.collect(f.actor);await f.runtime.quests.claim(f.actor,{definitionId:id,revision:1,requestId:randomUUID()});
|
||||
}
|
||||
const id='POL-ORDOS-03';await f.runtime.quests.start(f.actor,{definitionId:id});
|
||||
sql.exec("CREATE TABLE pb_orders(id TEXT,actor_id TEXT,source_id INT,target_id INT,state TEXT,mode TEXT,posted_at INT);CREATE TABLE pb_accounts(id INT,client_number INT);CREATE TABLE pb_clients(client_number INT,entity_id TEXT);CREATE TABLE pb_entities(id TEXT,kind TEXT,external_key TEXT);CREATE TABLE pb_exchange_levies(payment_id TEXT);INSERT INTO pb_accounts VALUES(1,1),(2,1),(3,2);INSERT INTO pb_clients VALUES(1,'p'),(2,'other');");
|
||||
sql.prepare("INSERT INTO pb_entities VALUES('p','person',?)").run(f.actor.id);
|
||||
const insert=(state,mode,to,at)=>{const order=randomUUID();sql.prepare('INSERT INTO pb_orders VALUES(?,?,1,?,?,?,?)').run(order,f.actor.id,to,state,mode,at);return order;};
|
||||
insert('posted','exchange',3,clock()-1);insert('pending','exchange',3,clock());insert('posted','exchange',2,clock());insert('posted','instant',3,clock());
|
||||
const levy=insert('posted','exchange',3,clock());sql.prepare('INSERT INTO pb_exchange_levies VALUES(?)').run(levy);
|
||||
const bank={query:async(text,args)=>sql.prepare(text).all(...args)},collect=()=>collectPOLAcquisition(f.db,bank,f.keys,f.actor,{clock});
|
||||
await collect();assert.equal((await f.db.first("SELECT COUNT(*) n FROM jarvis_pol_activity_events WHERE metric='pol-settled-acquisition'")).n,0);
|
||||
const order=insert('posted','exchange',3,clock());await collect();await collect();await f.runtime.collect(f.actor);
|
||||
const q=(await f.runtime.quests.list(f.actor)).quests.find(q=>q.id===id);assert.equal(q.executionRequirements.minecraft,true);assert.equal(q.canClaim,true);
|
||||
const evidence=await f.db.query("SELECT * FROM jarvis_pol_activity_events WHERE metric='pol-settled-acquisition'");assert.equal(evidence.length,1);assert.equal(evidence[0].source_reference,'bank-exchange:'+order);
|
||||
}finally{sql.close();f.db.close();}
|
||||
});
|
||||
Loading…
Reference in a new issue

Staff