Separate looted currency and preserve growing realm state in atomic chunks
Core tests / core (push) Successful in 49s
Core tests / core (push) Successful in 49s
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import type {State} from './types';
|
||||
import {activityReason,type Evidence} from './realm-insights';
|
||||
export const counterKeys=['quests','abandoned','lootEvents','lootItems','partyKills','rewarded'] as const;
|
||||
export const counterKeys=['quests','abandoned','lootEvents','lootItems','partyKills','rewarded','lootedCopper'] as const;
|
||||
export type NativeOutcome={guid:number;name:string}&Record<typeof counterKeys[number],number>;
|
||||
export type OutcomeBaseline={at:number;startedAt:number;rows:NativeOutcome[]};
|
||||
export function outcomeChanges(rows:NativeOutcome[],previous:OutcomeBaseline|undefined,now:number){
|
||||
const events:Evidence[]=[];
|
||||
for(const r of rows){const old=previous?.rows.find(b=>b.guid===r.guid);if(!old)continue;
|
||||
for(const key of counterKeys){const amount=r[key]-old[key];if(amount>0)events.push({id:`outcome:${r.guid}:${key}:${now}:${r[key]}`,at:now,kind:key,name:r.name,amount,detail:({quests:'Quest objectives completed',abandoned:'Quests abandoned',lootEvents:'Loot collections',lootItems:'Items collected',partyKills:'Kills with a nearby bot attacking the same target',rewarded:'New rewarded quest records'})[key]});}
|
||||
for(const key of counterKeys){const amount=r[key]-old[key];if(amount>0)events.push({id:`outcome:${r.guid}:${key}:${now}:${r[key]}`,at:now,kind:key,name:r.name,amount,detail:({lootedCopper:'Currency looted',quests:'Quest objectives completed',abandoned:'Quests abandoned',lootEvents:'Loot collections',lootItems:'Items collected',partyKills:'Kills with a nearby bot attacking the same target',rewarded:'New rewarded quest records'})[key]});}
|
||||
}
|
||||
return {baseline:{at:now,startedAt:previous?.startedAt??now,rows},events};
|
||||
}
|
||||
@@ -35,3 +35,5 @@ export function attentionItems(s:State,now:number,collectedAt:number|null,outcom
|
||||
for(const r of latest.values())if(r.status==='no_progress'&&now-r.at<3600&&online.some(b=>b.autonomy?.characterGuid===r.guid&&activityReason(b,now).label==='Possible stall'))add('recovery:'+r.id,'warning',r.name+' · recovery needs follow-up','No native movement or level progress was observed within three minutes.','Recovery Results',r.name);
|
||||
return items.sort((a,b)=>Number(b.severity==='critical')-Number(a.severity==='critical'));
|
||||
}
|
||||
|
||||
export function formatCopper(amount:number){const n=Math.max(0,Math.floor(Number.isFinite(amount)?amount:0));return `${Math.floor(n/10000)}g ${Math.floor(n%10000/100)}s ${n%100}c`;}
|
||||
|
||||
Reference in New Issue
Block a user