27 lines
605 B
Text
27 lines
605 B
Text
|
|
---
|
||
|
|
import { Quest } from '../../../lib/Quest';
|
||
|
|
import { squish } from '../../../lib/tags';
|
||
|
|
|
||
|
|
import QuestRow from '../../QuestRow.astro';
|
||
|
|
|
||
|
|
export const prerender = false;
|
||
|
|
export const partial = true;
|
||
|
|
|
||
|
|
const id = Astro.url.searchParams.get('id') || '';
|
||
|
|
const quest = Quest.load(id);
|
||
|
|
if (!quest.claimed) {
|
||
|
|
quest.claimed = true;
|
||
|
|
quest.save();
|
||
|
|
|
||
|
|
Quest.db.prepare(squish`
|
||
|
|
insert into events(
|
||
|
|
kind, quest_id, coins_claimed
|
||
|
|
) values ("claim_quest", ?, ?)
|
||
|
|
`).values(id, quest.coinsReward);
|
||
|
|
|
||
|
|
Astro.response.headers.set('HX-Trigger', 'questClaimed, bankUpdate');
|
||
|
|
}
|
||
|
|
---
|
||
|
|
|
||
|
|
<QuestRow id={id} />
|