Record physical chestplate and elytra merges in the flight quest
This commit is contained in:
parent
490a4c95b2
commit
9854418920
10 changed files with 82 additions and 11 deletions
|
|
@ -10,7 +10,8 @@ const rows=[
|
|||
['IRON','Imperial Iron','On Kaitain, smelt raw iron and take at least 2 iron ingots from a furnace or blast furnace.','flight-iron',2,50,[]],
|
||||
['DIAMOND','Under the Ice','Obtain a diamond on Ordos.','flight-diamond',1,100,[]],
|
||||
['CRAFT','Wings over the Desert','Return to Arrakis. Complete the preparation quests to reveal the elytra recipe. Craft the elytra there.','flight-crafted',1,250,['NETHERITE','CONTAMINATE','MEMBRANES','IRON','DIAMOND']],
|
||||
['ACQUIRE','Another Way to Fly','Alternatively, buy and receive an elytra through the Exchange, or obtain an elytra from an End ship. This completes this entire branch and grants every unclaimed branch reward once.','flight-elytra-acquired',1,0,[]]
|
||||
['ACQUIRE','Another Way to Fly','Alternatively, buy and receive an elytra through the Exchange, or obtain an elytra from an End ship. This completes the elytra preparation and acquisition quests and grants their unclaimed rewards once. The armour merge still requires a real physical merge.','flight-elytra-acquired',1,0,[]]
|
||||
];
|
||||
rows.push(['MERGE','Wings and Armour','Merge one elytra with a chestplate at an anvil. Keep the chestplate’s existing protection, enchantments, durability, grade and Origin World; one elytra is consumed. No additional currency fee.','flight-merged',1,0,[]]);
|
||||
export const ELYTRA_QUESTS=Object.freeze(rows.map(([suffix,title,objective,metric,target,xp,requires])=>Object.freeze({id:'POL-ELYTRA-'+suffix,title,objective,metric,target,xp,requires:requires.map(v=>'POL-ELYTRA-'+v),requiresAny:[],branch:'elytra',season:'S01',revision:1,optional:true,verifiedOnly:true,xpType:'pol'})));
|
||||
export const ELYTRA_BRANCH=Object.freeze({id:'elytra',office:null,title:'Wings across the Realms',issuer:'esmar_tuek',issuerName:'Esmar Tuek',theme:'Five worlds, two material chains, one elytra · Reputation XP',xpType:'pol',quests:ELYTRA_QUESTS,decisions:[]});
|
||||
|
|
|
|||
|
|
@ -62,7 +62,8 @@ export const MASTER_KEY_TEMPLATES=[
|
|||
action('progression.mentor-policy','Scoped Mentat reward bonus','progression-policy',[field('season','Season'),field('policyVersion','Policy version','number',{min:3})],{webIssue:false,recordOnly:true,domainAdapter:'ensurePOLMentorPolicy',executionStatus:'recorded-system-policy',effect:'Record the bounded 10% eligible Mentat bonus through the existing POL award engine. Preserve Personal XP and earlier claims; no default DM reward.'}),
|
||||
action('progression.pol-funded-rewards','Funded Reputation reward delivery','quest',[],{webIssue:false,recordOnly:true,domainAdapter:'createPOLFundedRewards',executionStatus:'consumed-quest-outbox-only',effect:'Pay only explicitly configured and verified claim rewards from existing website treasury funds to the bound ordinary player bank account. Original QST identity prevents duplicate ledger entries; unfunded or invalid rewards remain queued.'}),
|
||||
action('progression.flight-policy','Elytra Reputation quest policy','progression-policy',[],{version:4,webIssue:false,recordOnly:true,domainAdapter:'ensureElytraQuestPolicy',executionStatus:'recorded-system-policy',effect:'Install the twelve Elytra quest reward configurations through their own policy:POL:S01:v4 instrument. Preserve existing quest settings, season dates and the separate v3 Mentat bonus instrument.'}),
|
||||
action('progression.game-observation','Native quest observation','quest-milestone',[field('eventId','Original native event UUID'),field('uuid','Linked Minecraft UUID'),field('kind','Fixed observation kind'),field('server','Native server'),field('occurredAt','Original event time','number',{min:1}),field('quantity','Native produced quantity','number',{min:1,max:64,required:false}),field('dimension','Native dimension','text',{required:false}),field('source','Fixed Elytra acquisition source','text',{required:false})],{version:4,webIssue:false,recordOnly:true,domainAdapter:'createGameQuestEventsAPI',executionStatus:'authenticated-game-service',effect:'Record confirmed Citizen briefing acknowledgements, real Arrakis visits, active survival minutes, durability-consuming equipment use and native spice drops from successful mining. Spice feeds the existing Personal and repeatable Reputation QSM adapters. Fixed world/dimension flight observations feed the Reputation Elytra branch. A committed paid delivery or natural End-ship acquisition completes only this branch, awarding its remaining rewards once. Preserve source UUID on retries. Creative/spectator gameplay and AFK/lobby movement supply no progress. A deliberate Citizen briefing acknowledgement is allowed in the lobby; other menu clicks never assert gameplay completion.'}),
|
||||
action('progression.flight-merge-policy','Armoured flight quest policy','progression-policy',[],{version:10,webIssue:false,recordOnly:true,domainAdapter:'ensureElytraMergePolicy/createGameQuestEventsAPI',executionStatus:'authenticated-native-physical-merge-consumer',effect:'Add POL-ELYTRA-MERGE through policy:POL:S01:v10 without changing existing rewards or season dates. A physical native chestplate-and-elytra merge consumes one elytra, preserves armour properties and records one receipt-bound flight_merged observation on a shared-profile planet. No currency charge or XP award. Acquiring an ordinary elytra cannot complete this separate step; web/menu clicks never assert physical completion.'}),
|
||||
action('progression.game-observation','Native quest observation','quest-milestone',[field('eventId','Original native event UUID'),field('uuid','Linked Minecraft UUID'),field('kind','Fixed observation kind'),field('server','Native server'),field('occurredAt','Original event time','number',{min:1}),field('quantity','Native produced quantity','number',{min:1,max:64,required:false}),field('dimension','Native dimension','text',{required:false}),field('source','Fixed Elytra acquisition source','text',{required:false})],{version:4,webIssue:false,recordOnly:true,domainAdapter:'createGameQuestEventsAPI',executionStatus:'authenticated-game-service',effect:'Record confirmed Citizen briefing acknowledgements, real Arrakis visits, active survival minutes, durability-consuming equipment use and native spice drops from successful mining. Spice feeds the existing Personal and repeatable Reputation QSM adapters. Fixed world/dimension flight observations feed the Reputation Elytra branch. A committed paid delivery or natural End-ship acquisition completes only the flight preparation/acquisition quests, awarding their remaining rewards once. Armour merging needs its separate physical receipt. Preserve source UUID on retries. Creative/spectator gameplay and AFK/lobby movement supply no progress. A deliberate Citizen briefing acknowledgement is allowed in the lobby; other menu clicks never assert gameplay completion.'}),
|
||||
action('commerce.spice-sale','Arrakis spice sale','entity-state',[field('uuid','Linked Minecraft UUID'),field('requestId','Original sale UUID'),field('channel','Buyer','select',{options:['guild','smuggler']}),field('amount','Surrendered spice','number',{min:1,max:21312})],{version:3,webIssue:false,recordOnly:true,domainAdapter:'createGameSpiceAPI + ExchangeInventory.sellSpice + createSpiceQuestReceipts',executionStatus:'authenticated-arrakis-inventory-receipt',effect:'Arrakis only. Guild and Smuggler have separate server prices; Smuggler requires an active Smuggler quest. Native Core checkpoints all surrendered raw Melange Spice and compressed blocks (nine raw units each), retaining Guild versus contraband identity before the central bank pays its personal recipient from fixed P&O, with the existing Trust levy. Original request UUID binds quote, inventory receipt and balanced bank entries. Retry and reconnect recover an unpaid receipt without taking spice or paying twice. Paid Guild sales supply Personal harvest and Reputation spice evidence; paid contraband sales supply separate Reputation smuggling evidence through existing ordinary quest-milestone keys. Pending quest reporting retries from the same stored sale without taking items or paying again. No Vault wallet or Exchange listing.'}),
|
||||
action('progression.spice-refining','NPC spice refinement','quest-milestone',[field('uuid','Linked player UUID'),field('requestId','Original turn-in UUID'),field('definitionId','Fixed refining quest'),field('npcUuid','Nearby Arrakis Smuggler UUID')],{version:1,webIssue:false,recordOnly:true,domainAdapter:'createGameQuestsAPI.prepare_refine + SpiceRefiner + ExchangeInventory.refine',executionStatus:'authenticated-native-npc-turn-in',effect:'Revalidate the current player and quest prerequisites, then require the physical Arrakis NPC again before consuming two real raw spice, or two refined spice and two scraps. Core checkpoints inputs, two EI outputs and a recoverable receipt atomically. Existing QSM observations award no reward until verified by the Reputation quest engine.'}),
|
||||
action('progression.earned-dm','Verified earned DM','quest-milestone',[],{version:2,webIssue:false,recordOnly:true,domainAdapter:'bankQuestIncome + progressionRuntime.collect',executionStatus:'committed-central-bank-source',effect:'Count posted wages, fixed-P&O spice-sale payouts, Exchange sale income, incoming bank transfers and verified quest treasury credits across the player’s personal central-bank accounts during the active season. Count each bank order once and preserve cumulative earnings after spending. Exclude own-account transfers, refunds, pending payments, unrelated system grants and organisation income; never use a legacy game wallet or current balance as an earnings counter.'}),
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,5 +1,5 @@
|
|||
import {ELYTRA_QUESTS} from '../control-panel/public/cp-v2/cp-v2-elytra-quests.mjs';
|
||||
export const ELYTRA_RECIPE=Object.freeze({world:'Arrakis',quality:'very_rare',equipmentMark:11,result:'Elytra',grid:[['Netherite ingot','Phantom membrane','Netherite ingot'],['Iron ingot','Diamond','Iron ingot'],['Contaminated spice','Phantom membrane','Contaminated spice']]});
|
||||
export const FLIGHT_METRICS=Object.freeze(Object.fromEntries(ELYTRA_QUESTS.map(d=>[d.metric,d.target])));
|
||||
export const FLIGHT_METRICS=Object.freeze(Object.fromEntries(ELYTRA_QUESTS.filter(d=>d.id!=='POL-ELYTRA-MERGE').map(d=>[d.metric,d.target])));
|
||||
export function applyElytraAlternative(totals){if((totals.get('flight-elytra-acquired')||0)>0)for(const [metric,target]of Object.entries(FLIGHT_METRICS))totals.set(metric,Math.max(target,totals.get(metric)||0));return totals;}
|
||||
export function flightDossier(quest){if(quest.id!=='POL-ELYTRA-CRAFT')return quest;if(!quest.canStart&&!['active','completed','claimed'].includes(quest.state))return {...quest,objective:'Complete the preparation quests to reveal the elytra recipe.'};return {...quest,objective:'Craft this elytra on Arrakis using the revealed recipe.',recipe:ELYTRA_RECIPE};}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ const husbandry=Object.freeze(Object.fromEntries([...FREMEN_HUSBANDRY_TASKS,...F
|
|||
metrics.smuggler_delivery=SMUGGLER_DELIVERY_METRIC;
|
||||
for(const task of POL_SUPPLY_TASKS)metrics[task.kind]=task.metric;
|
||||
metrics.bounty_accept='pol-bounty-accepted';metrics.bounty_complete='pol-bounty-completed';
|
||||
const flight={flight_spice:['arrakis','NORMAL'],flight_refined:['arrakis','NORMAL'],flight_contaminated:['arrakis','NORMAL'],flight_debris:['giedi-prime','NETHER'],flight_scrap:['giedi-prime','NETHER'],flight_gold:['giedi-prime','NETHER'],flight_netherite:['giedi-prime','NETHER'],flight_membrane:['caladan','NORMAL'],flight_iron:['kaitain','NORMAL'],flight_diamond:['sigma-draconis-iv','NORMAL'],flight_crafted:['arrakis','NORMAL'],flight_elytra_acquired:null};
|
||||
const flight={flight_spice:['arrakis','NORMAL'],flight_refined:['arrakis','NORMAL'],flight_contaminated:['arrakis','NORMAL'],flight_debris:['giedi-prime','NETHER'],flight_scrap:['giedi-prime','NETHER'],flight_gold:['giedi-prime','NETHER'],flight_netherite:['giedi-prime','NETHER'],flight_membrane:['caladan','NORMAL'],flight_iron:['kaitain','NORMAL'],flight_diamond:['sigma-draconis-iv','NORMAL'],flight_crafted:['arrakis','NORMAL'],flight_elytra_acquired:null,flight_merged:null};
|
||||
for(const kind of Object.keys(flight))metrics[kind]=kind.replaceAll('_','-');
|
||||
export function createGameQuestEventsAPI(db,keys,settings,{clock=Date.now,events:provided=null,starter=null,research=null,cargo=null}={}){
|
||||
const producer=Object.freeze({source:'native-quest-observation'});
|
||||
|
|
@ -45,6 +45,7 @@ export function createGameQuestEventsAPI(db,keys,settings,{clock=Date.now,events
|
|||
if(!input||Array.isArray(input)||Object.keys(input).length!==fields.length||fields.some(f=>!Object.hasOwn(input,f))||!validUuid(input.eventId)||!validUuid(input.uuid)||!Object.hasOwn(metrics,input.kind)||!servers.has(input.server)||!isFlight&&!supply&&input.kind!=='citizen_introduction'&&input.kind!=='house_mentor_intro'&&!(input.kind==='smuggler_introduction'&&input.server==='lobby')&&(input.server==='lobby'||input.kind!=='equipment_use'&&input.server!=='arrakis')||!Number.isSafeInteger(input.occurredAt)||input.occurredAt<=0||input.occurredAt>clock()+30000)return json({message:'Invalid observation fields'},400);
|
||||
if(input.kind==='house_mentor_intro'&&(input.server!=='lobby'||!Object.values(HOUSE_MENTOR_CONTACTS).includes(input.npcRole)))return json({message:'Meet your matching House Mentat in the Guild lobby.'},400);
|
||||
if(isFlight&&(!Number.isSafeInteger(input.quantity)||input.quantity<1||input.quantity>64||!['NORMAL','NETHER','THE_END'].includes(input.dimension)||flight[input.kind]&&(flight[input.kind][0]!==input.server||flight[input.kind][1]!==input.dimension)||input.kind==='flight_elytra_acquired'&&(!['end','exchange'].includes(input.source)||input.source==='end'&&input.dimension!=='THE_END')))return json({message:'Invalid flight objective location'},400);
|
||||
if(input.kind==='flight_merged'&&(input.quantity!==1||input.dimension!=='NORMAL'||input.server==='lobby'))return json({message:'A single completed physical armour merge on a shared-profile planet is required.'},400);
|
||||
if(input.kind==='spice_harvest'&&(!Number.isSafeInteger(input.quantity)||input.quantity<1||input.quantity>64))return json({message:'Invalid harvest quantity'},400);
|
||||
const turnin=FREMEN_TURNIN_TRACKS.find(t=>t.kind===input.kind);
|
||||
if(isHusbandry&&(!Number.isSafeInteger(input.quantity)||input.quantity<1||(turnin?input.quantity!==turnin.units:input.quantity>(['husbandry_leather','husbandry_collect_egg','husbandry_collect_hide','husbandry_hide_paste','husbandry_spice_paste','husbandry_spice_bread','husbandry_spice_cake'].includes(input.kind)?64:1))))return json({message:'Invalid husbandry observation quantity'},400);
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ export function createPOLProgressionRuntime(central,keys,{clock=Date.now,verifyO
|
|||
if(!await authorizePlayer(actor,central))throw Error('Current player identity required');if(raidQuests)await raidQuests.collect(actor);let acquisitionAvailable=true;if(bank)try{await collectPOLAcquisition(central,bank,keys,actor,{clock});}catch{acquisitionAvailable=false;}const proof=await evidence(actor);if(!proof)return {state:'verified-key-sources',sources:[{source:'pol-activity-keys',available:false,reason:'pending-verified-producer'}]};
|
||||
const digest=createHash('sha256').update(JSON.stringify(proof.proofIds)).digest('hex');
|
||||
const current=await engineFor(actor),metrics=new Set(current.definitions.map(d=>d.metric));for(const [metric,value]of proof.totals)if(metrics.has(metric))await current.engine.observe(observer,{accountId:actor.id,seasonId:proof.season.season_id,metric,value,eventId:'pol-activity:'+actor.id+':'+metric+':'+digest.slice(0,32),source:'verified-activity-key'});
|
||||
if((proof.totals.get('flight-elytra-acquired')||0)>0)await current.engine.completeVerifiedBranch(actor,'elytra');
|
||||
if((proof.totals.get('flight-elytra-acquired')||0)>0)await current.engine.completeVerifiedBranch(actor,'elytra',{exclude:['POL-ELYTRA-MERGE']});
|
||||
return {state:'verified-key-sources',sources:[{source:'pol-activity-keys',available:true,verifiedEvents:proof.proofIds.length},...(bank?[{source:'posted-exchange-mission',available:acquisitionAvailable}]:[])]};
|
||||
}
|
||||
return Object.freeze({quests,collect});
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ export const ensurePOLProgressionPolicy=(db,keys,options={})=>ensureProgressionP
|
|||
|
||||
export const ensurePOLRepeatablePolicy=(db,keys,options={})=>ensureProgressionPolicy(polProgressionStore(db),polPolicyKeys(keys),{...options,policy:{...POL_XP_POLICY,version:2},definitions:repeatablePolicyDefinitions()});
|
||||
|
||||
export const ensureElytraQuestPolicy=(db,keys,options={})=>ensureProgressionPolicy(polProgressionStore(db),polPolicyKeys(keys),{...options,policy:{...POL_XP_POLICY,version:4},definitions:POL_QUEST_DEFINITIONS.filter(d=>d.branch==='elytra')});
|
||||
export const ensureElytraQuestPolicy=(db,keys,options={})=>ensureProgressionPolicy(polProgressionStore(db),polPolicyKeys(keys),{...options,policy:{...POL_XP_POLICY,version:4},definitions:POL_QUEST_DEFINITIONS.filter(d=>d.branch==='elytra'&&d.id!=='POL-ELYTRA-MERGE')});
|
||||
|
||||
export const ensureWarQuestPolicy=(db,keys,options={})=>ensureProgressionPolicy(polProgressionStore(db),polPolicyKeys(keys),{...options,policy:{...POL_XP_POLICY,version:5},definitions:POL_QUEST_DEFINITIONS.filter(d=>d.branch==='war-service')});
|
||||
|
||||
|
|
@ -59,3 +59,6 @@ export const ensureFaithQuestPolicy=(db,keys,options={})=>ensureProgressionPolic
|
|||
export const ensureFaunaQuestPolicy=(db,keys,options={})=>ensureProgressionPolicy(polProgressionStore(db),polPolicyKeys(keys),{...options,policy:{...POL_XP_POLICY,version:7},definitions:[...POL_QUEST_DEFINITIONS.filter(d=>d.faction==='fremen'),...repeatablePolicyDefinitions({faction:'fremen'})],rewardForDefinition:fremenInitialReward});
|
||||
export const ensureBountyQuestPolicy=(db,keys,options={})=>ensureProgressionPolicy(polProgressionStore(db),polPolicyKeys(keys),{...options,policy:{...POL_XP_POLICY,version:8},definitions:POL_QUEST_DEFINITIONS.filter(d=>d.branch==='bounty-jobs')});
|
||||
export const ensureSpiceUpgradeQuestPolicy=(db,keys,options={})=>ensureProgressionPolicy(polProgressionStore(db),polPolicyKeys(keys),{...options,policy:{...POL_XP_POLICY,version:9},definitions:POL_QUEST_DEFINITIONS.filter(d=>d.branch==='spice-upgrading')});
|
||||
|
||||
// Add the physical merge without replaying v4 or overwriting existing flight rewards.
|
||||
export const ensureElytraMergePolicy=(db,keys,options={})=>ensureProgressionPolicy(polProgressionStore(db),polPolicyKeys(keys),{...options,policy:{...POL_XP_POLICY,version:10},definitions:POL_QUEST_DEFINITIONS.filter(d=>d.id==='POL-ELYTRA-MERGE')});
|
||||
|
|
|
|||
|
|
@ -147,9 +147,10 @@ export function createQuestProgression(db,keys,{definitions=QUEST_DEFINITIONS,au
|
|||
}
|
||||
return {completed};
|
||||
},
|
||||
async completeVerifiedBranch(actor,branch){
|
||||
async completeVerifiedBranch(actor,branch,{exclude=[]}={}){
|
||||
if(!Array.isArray(exclude)||exclude.some(id=>typeof id!=='string'||!definitions.some(d=>d.id===id&&d.branch===branch)))throw TypeError('Registered branch exclusions required');
|
||||
await player(actor);let completed=0;
|
||||
for(const d of definitions.filter(d=>d.branch===branch&&!d.repeatable)){
|
||||
for(const d of definitions.filter(d=>d.branch===branch&&!d.repeatable&&!exclude.includes(d.id))){
|
||||
const view=await service.list(actor),q=view.quests.find(q=>q.id===d.id);if(!q||q.state==='claimed')continue;
|
||||
if(!q.canClaim||!q.rewardConfigured)throw Error('Verified branch completion is not ready');
|
||||
await service.claim(actor,{definitionId:q.id,revision:q.revision,requestId:deterministicId('branch:'+actor.id+':'+view.season.id+':'+q.id)});completed++;
|
||||
|
|
|
|||
64
website/tests/elytra-merge.test.mjs
Normal file
64
website/tests/elytra-merge.test.mjs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {randomUUID} from 'node:crypto';
|
||||
import {systemCharacterFixture} from './system-character-fixture.mjs';
|
||||
import {initializePOLProgression,ensurePOLProgressionPolicy,ensureElytraQuestPolicy,ensureElytraMergePolicy} from '../node/progression-pol.mjs';
|
||||
import {initializePOLActivityEvents} from '../node/pol-activity-events.mjs';
|
||||
import {createGameQuestEventsAPI} from '../node/game-quest-events.mjs';
|
||||
import {createPOLProgressionRuntime} from '../node/progression-pol-runtime.mjs';
|
||||
import {applyElytraAlternative} from '../node/elytra-quest-policy.mjs';
|
||||
|
||||
const secret='elytra-merge-fixture-secret-at-least-32-characters';
|
||||
|
||||
test('ordinary elytra acquisition never fabricates a physical armour merge',()=>{
|
||||
const facts=new Map([['flight-elytra-acquired',1]]);
|
||||
applyElytraAlternative(facts);
|
||||
assert.equal(facts.get('flight-crafted'),1);
|
||||
assert.equal(facts.has('flight-merged'),false);
|
||||
facts.set('flight-merged',1);applyElytraAlternative(facts);
|
||||
assert.equal(facts.get('flight-merged'),1);
|
||||
});
|
||||
|
||||
test('v10 installs only the merge configuration and preserves existing season and custom rewards',async()=>{
|
||||
const f=await systemCharacterFixture();try{
|
||||
await initializePOLProgression(f.db);
|
||||
await ensureElytraQuestPolicy(f.db,f.keys,{clock:()=>1000});
|
||||
await f.db.query("UPDATE jarvis_pol_quest_config SET xp=321 WHERE definition_id='POL-ELYTRA-CRAFT'");
|
||||
const before=await f.db.query('SELECT * FROM jarvis_pol_quest_config ORDER BY definition_id');
|
||||
const season=await f.db.first('SELECT * FROM jarvis_pol_progression_seasons');
|
||||
await ensureElytraMergePolicy(f.db,f.keys,{clock:()=>2000});
|
||||
await ensureElytraMergePolicy(f.db,f.keys,{clock:()=>3000});
|
||||
assert.deepEqual(await f.db.query("SELECT * FROM jarvis_pol_quest_config WHERE definition_id<>'POL-ELYTRA-MERGE' ORDER BY definition_id"),before);
|
||||
assert.deepEqual(await f.db.first('SELECT * FROM jarvis_pol_progression_seasons'),season);
|
||||
assert.equal((await f.db.first("SELECT xp FROM jarvis_pol_quest_config WHERE definition_id='POL-ELYTRA-MERGE'")).xp,0);
|
||||
assert.equal((await f.db.first("SELECT COUNT(*) n FROM organisation_keys WHERE scope_id='policy:POL:S01:v10'")).n,1);
|
||||
}finally{f.db.close();}
|
||||
});
|
||||
|
||||
test('one authenticated native merge receipt completes only the merge, replays once and cannot assert a bulk or wrong-dimension merge',async()=>{
|
||||
const f=await systemCharacterFixture();try{
|
||||
const clock=()=>2000;
|
||||
await f.characters.provision(f.people.Owner,'esmar_tuek');
|
||||
await initializePOLProgression(f.db);await ensurePOLProgressionPolicy(f.db,f.keys,{clock:()=>1000});
|
||||
await ensureElytraMergePolicy(f.db,f.keys,{clock:()=>1000});
|
||||
await initializePOLActivityEvents(f.db);f.db.polActivityEventsEnabled=true;
|
||||
const uuid=randomUUID();await f.db.query('UPDATE site_game_links SET minecraft_uuid=? WHERE user_id=?',[uuid,f.people.Member.id]);
|
||||
const api=createGameQuestEventsAPI(f.db,f.keys,{GAME_LINK_SECRET:secret},{clock});
|
||||
const input={eventId:randomUUID(),uuid,kind:'flight_merged',server:'sigma-draconis-iv',occurredAt:2000,quantity:1,dimension:'NORMAL'};
|
||||
const send=(body,authenticated=true)=>api(new Request('https://cp.dunerealms.com/internal/game/quest-events',{method:'POST',headers:{...(authenticated?{authorization:'Bearer '+secret}:{}),'content-type':'application/json'},body:JSON.stringify(body)}));
|
||||
assert.equal((await send(input,false)).status,401);
|
||||
for(const bad of [{quantity:2},{quantity:0},{dimension:'NETHER'},{dimension:'THE_END'},{server:'lobby'},{source:'web'},{accountId:f.people.Owner.id}])assert.equal((await send({...input,...bad})).status,400);
|
||||
assert.equal((await send({...input,uuid:randomUUID()})).status,403);
|
||||
assert.equal((await send(input)).status,200);
|
||||
const replay=await (await send(input)).json();assert.equal(replay.replayed,true);
|
||||
assert.equal((await f.db.first('SELECT COUNT(*) n FROM jarvis_pol_activity_events')).n,1);
|
||||
const runtime=createPOLProgressionRuntime(f.db,f.keys,{clock});await runtime.collect(f.people.Member);
|
||||
const view=await runtime.quests.list(f.people.Member),merge=view.quests.find(q=>q.id==='POL-ELYTRA-MERGE');
|
||||
assert.equal(merge.progress,1);assert.equal(merge.canClaim,true);assert.equal(merge.xp,0);
|
||||
assert.equal(view.quests.find(q=>q.id==='POL-ELYTRA-CRAFT').progress,0);
|
||||
await runtime.quests.claim(f.people.Member,{definitionId:merge.id,revision:merge.revision,requestId:randomUUID()});
|
||||
const after=await runtime.quests.list(f.people.Member);
|
||||
assert.equal(after.profile.totalXP,view.profile.totalXP);
|
||||
assert.equal(after.quests.find(q=>q.id===merge.id).state,'claimed');
|
||||
}finally{f.db.close();}
|
||||
});
|
||||
|
|
@ -4,4 +4,4 @@ import {defaultItemDesign,validateItemDesign} from '../control-panel/public/item
|
|||
test('new crafted Elytra grade preserves already published original Elytra definitions',()=>{for(const template of [elytraTemplate('basic'),CRAFTED_ELYTRA_TEMPLATE]){const design=defaultItemDesign(template.id);assert.equal(validateItemDesign(design).equipmentMark,template.equipmentMark);}assert.equal(elytraTemplate('basic').equipmentMark,13);assert.equal(CRAFTED_ELYTRA_TEMPLATE.equipmentMark,11);assert.equal(CRAFTED_ELYTRA_TEMPLATE.quality,'very_rare');});
|
||||
import {questAwardXP} from '../node/progression-definitions.mjs';import {systemCharacterFixture} from './system-character-fixture.mjs';import {initializePOLProgression,ensurePOLProgressionPolicy} from '../node/progression-pol.mjs';import {initializePOLActivityEvents,createPOLActivityEvents} from '../node/pol-activity-events.mjs';import {createPOLProgressionRuntime} from '../node/progression-pol-runtime.mjs';import {ELYTRA_QUESTS} from '../control-panel/public/cp-v2/cp-v2-elytra-quests.mjs';import {flightDossier} from '../node/elytra-quest-policy.mjs';
|
||||
test('elytra recipe remains outside the locked final dossier',()=>{const q={id:'POL-ELYTRA-CRAFT',state:'not-started',canStart:false};assert.equal(flightDossier(q).recipe,undefined);assert.equal(flightDossier({...q,canStart:true}).recipe.grid.length,3);assert.equal(flightDossier({...q,state:'active'}).recipe.grid.length,3);});
|
||||
test('one verified acquired Elytra completes only its Reputation branch and pays every remaining reward once',async()=>{const f=await systemCharacterFixture();try{const clock=()=>2000;await f.characters.provision(f.people.Owner,'esmar_tuek');await initializePOLProgression(f.db);await ensurePOLProgressionPolicy(f.db,f.keys,{clock});await initializePOLActivityEvents(f.db);f.db.polActivityEventsEnabled=true;const minecraftUuid=randomUUID();await f.db.query('UPDATE site_game_links SET minecraft_uuid=? WHERE user_id=?',[minecraftUuid,f.people.Member.id]);const producer={},events=createPOLActivityEvents(f.db,f.keys,{clock,authorizeProducer:async p=>p===producer}),runtime=createPOLProgressionRuntime(f.db,f.keys,{clock});await events.record(producer,{eventId:randomUUID(),accountId:f.people.Member.id,minecraftUuid,seasonId:'S01',metric:'flight-elytra-acquired',quantity:1,occurredAt:2000,reference:'verified-paid-delivery'});await runtime.collect(f.people.Member);let view=await runtime.quests.list(f.people.Member);assert.equal(view.quests.filter(q=>q.branch==='elytra'&&q.state==='claimed').length,ELYTRA_QUESTS.length);assert.equal(view.profile.totalXP,ELYTRA_QUESTS.reduce((sum,q)=>sum+questAwardXP(q,q.xp),0));assert.equal(view.quests.filter(q=>q.branch!=='elytra'&&q.state==='claimed').length,0);await runtime.collect(f.people.Member);assert.equal((await runtime.quests.list(f.people.Member)).profile.totalXP,2250);assert.equal((await f.db.first('SELECT COUNT(*) n FROM jarvis_pol_quest_claims')).n,12);}finally{f.db.close();}});
|
||||
test('one verified acquired Elytra completes only its Reputation branch and pays every remaining reward once',async()=>{const f=await systemCharacterFixture();try{const clock=()=>2000;await f.characters.provision(f.people.Owner,'esmar_tuek');await initializePOLProgression(f.db);await ensurePOLProgressionPolicy(f.db,f.keys,{clock});await initializePOLActivityEvents(f.db);f.db.polActivityEventsEnabled=true;const minecraftUuid=randomUUID();await f.db.query('UPDATE site_game_links SET minecraft_uuid=? WHERE user_id=?',[minecraftUuid,f.people.Member.id]);const producer={},events=createPOLActivityEvents(f.db,f.keys,{clock,authorizeProducer:async p=>p===producer}),runtime=createPOLProgressionRuntime(f.db,f.keys,{clock});await events.record(producer,{eventId:randomUUID(),accountId:f.people.Member.id,minecraftUuid,seasonId:'S01',metric:'flight-elytra-acquired',quantity:1,occurredAt:2000,reference:'verified-paid-delivery'});await runtime.collect(f.people.Member);let view=await runtime.quests.list(f.people.Member);assert.equal(view.quests.filter(q=>q.branch==='elytra'&&q.state==='claimed').length,ELYTRA_QUESTS.filter(q=>q.id!=='POL-ELYTRA-MERGE').length);assert.equal(view.profile.totalXP,ELYTRA_QUESTS.reduce((sum,q)=>sum+questAwardXP(q,q.xp),0));assert.equal(view.quests.filter(q=>q.branch!=='elytra'&&q.state==='claimed').length,0);await runtime.collect(f.people.Member);assert.equal((await runtime.quests.list(f.people.Member)).profile.totalXP,2250);assert.equal((await f.db.first('SELECT COUNT(*) n FROM jarvis_pol_quest_claims')).n,12);}finally{f.db.close();}});
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff