From 13ffd6c4a68b0adc02579e400f692c8af2a11566 Mon Sep 17 00:00:00 2001 From: Demur Rumed Date: Wed, 31 Jan 2024 13:42:16 +0000 Subject: [PATCH] render selected quest rewards --- src/Quest.js | 43 +++++---------- src/views/Quest.jsx | 132 +++++++++++++++++++++++++++++--------------- 2 files changed, 100 insertions(+), 75 deletions(-) diff --git a/src/Quest.js b/src/Quest.js index 0c7ca2e1..1b808425 100644 --- a/src/Quest.js +++ b/src/Quest.js @@ -401,19 +401,19 @@ export const quarks = { 'You have proved your worth for the Master of Arms, and he gives you one of his rare weapons.', /* prettier-ignore */ choicerewards: [ - 5109, 5124, - 5210, 5222, - 5308, 5324, - 5407, 5423, - 5509, 5523, - 5607, 5621, - 5708, 5723, - 5809, 5822, - 5909, 5924, - 6008, 6025, - 6107, 6126, - 6206, 6223, - ], + 5109, 5124, + 5210, 5222, + 5308, 5324, + 5407, 5423, + 5509, 5523, + 5607, 5621, + 5708, 5723, + 5809, 5822, + 5909, 5924, + 6008, 6025, + 6107, 6126, + 6206, 6223, + ], info: 'Fight the Master of Arms at the Proving Grounds!', }, pgshard: { @@ -638,7 +638,7 @@ export const quarks = { hp: 400, markpower: 3, drawpower: 2, - cardreward: '0171r01785017bf017ea017hj017nm017qv01813018pi', + cardreward: '0171r01785017bf017ea017hj017nm017qv01813', info: 'The AI has taken control of Serprex’s account and gone berserk. It has a power beyond a demigod!', wintext: 'You defeat the AI menace and restore Serprex’s account to their rightful place. Phew!', @@ -728,21 +728,6 @@ export const root = { ], }; -export function extractRewards(obj) { - for (const key in obj) { - console.log(typeof obj[key]) - if (typeof obj[key] === 'object' && obj[key] !== null) { - extractRewards(obj[key]); - } else if (key === 'cardreward' || key === 'choicerewards') { - return '+Card' - //TODO: break down card reward options into onHover - // obj[key].cardreward ? '+Cards' : '+'+obj[key].goldreward+'$'; - } else if (key === 'goldreward') { - return '+'+obj[key]; - } - } -} - export function mkQuestAi(quest, datafn) { const markpower = quest.markpower ?? 1; const drawpower = quest.drawpower ?? 1; diff --git a/src/views/Quest.jsx b/src/views/Quest.jsx index 04794392..85246a6b 100644 --- a/src/views/Quest.jsx +++ b/src/views/Quest.jsx @@ -1,46 +1,83 @@ import { createMemo } from 'solid-js'; + +import Cards from '../Cards.js'; import * as Quest from '../Quest.js'; +import CardImage from '../Components/CardImage.jsx'; import ExitBtn from '../Components/ExitBtn.jsx'; import Text from '../Components/Text.jsx'; import * as store from '../store.jsx'; +import { decodedeck } from '../etgutil.js'; -function QuestButton(props) { +export function QuestRewards(props) { + const quest = createMemo(() => { + let quest = props.quest; + if (!quest) return null; + while (quest.autonext) quest = quest.autonext; + return quest; + }); return ( <> - - {typeof props.area === 'string' ? - Quest.quarks[props.area].name - : props.area.name} - - {Quest.extractRewards(Quest.quarks[props.area]) && !props.user.quests[props.area] && ( - - {Quest.extractRewards(Quest.quarks[props.area])} - {Quest.extractRewards(Quest.quarks[props.area]) !== '+Card' && ( - + {quest()?.choicerewards && ( +
+
Choice
+ {Array.isArray(quest()?.choicerewards) && ( + + {(reward, i) => ( + + )} + )} - + {!Array.isArray(quest()?.choicerewards) && quest()?.choicerewards} +
+ )} + {quest()?.cardreward && ( +
+
Cards
+ + {(code, i) => ( + + )} + +
+ )} + {quest()?.goldreward && ( +
+ {quest()?.goldreward} + +
)} ); } -export default function QuestView(props) { +function QuestButton(props) { + return ( + + {typeof props.area === 'string' ? + Quest.quarks[props.area].name + : props.area.name} + + ); +} + +export default function QuestView() { const rx = store.useRx(); const questInfo = createMemo(() => { const questAreas = [], @@ -50,16 +87,18 @@ export default function QuestView(props) { let y = 162; for (let i = 0; i < qbag.children.length; i++) { const area = qbag.children[i]; - if (typeof area === 'string') { - const quark = Quest.quarks[area]; - if (!Quest.requireQuest(quark, rx.user)) continue; + if ( + typeof area === 'string' && + !Quest.requireQuest(Quest.quarks[area], rx.user) + ) { + continue; } questAreas.push( { const newquest = quest.slice(0, qi); newquest[qi] = i; @@ -82,10 +121,7 @@ export default function QuestView(props) { <>
- -
+ style="position:absolute;left:8px;top:8px;width:880px;height:108px;padding-left:15px;padding-top:15px">
+ {questInfo().selectedQuest?.key && ( - - store.navGame(Quest.mkQuestAi(questInfo().selectedQuest)) - } - /> + <> + + store.navGame(Quest.mkQuestAi(questInfo().selectedQuest)) + } + /> + + )} {questInfo().questAreas}