Add Scene 7 claim report workflow
This commit is contained in:
@@ -24,7 +24,7 @@ export type PlaythroughAdvanceResult = {
|
||||
ok: boolean
|
||||
state?: PlaythroughState
|
||||
error?: string
|
||||
errorCode?: 'goals_incomplete'
|
||||
errorCode?: 'goals_incomplete' | 'report_incomplete'
|
||||
pendingGoals?: { key: string; title: string }[]
|
||||
}
|
||||
|
||||
@@ -317,6 +317,15 @@ export function createNarrativeRepository(pool: Pool, objectStorage: ObjectStora
|
||||
return { ok:false,error:'Complete the level objective before continuing',errorCode:'goals_incomplete',
|
||||
pendingGoals:pendingGoals.map(goal => ({ key:goal.goal_key,title:goal.title })) }
|
||||
}
|
||||
const reportIncomplete = (await client.query<{ required:boolean;accepted:boolean }>(`SELECT report.required_for_completion AS required,
|
||||
EXISTS (SELECT 1 FROM osint.case_report_submissions submission
|
||||
WHERE submission.level_id=level.id AND submission.status='accepted') AS accepted
|
||||
FROM osint.levels level JOIN osint.case_reports report ON report.board_id=level.board_id
|
||||
WHERE level.id=$1`,[playthrough.current_level_id])).rows[0]
|
||||
if (reportIncomplete?.required && !reportIncomplete.accepted) {
|
||||
await client.query('ROLLBACK')
|
||||
return { ok:false,error:'Submit an accepted case report before continuing',errorCode:'report_incomplete' }
|
||||
}
|
||||
await client.query(`INSERT INTO osint.achievements (playthrough_id,flag_key,awarded_by_node_id)
|
||||
SELECT $1,requirement.flag_key,$3 FROM osint.levels level
|
||||
JOIN osint.level_goals goal ON goal.board_id=level.board_id AND goal.enabled
|
||||
|
||||
Reference in New Issue
Block a user