1
1
import { createMemo } from 'solid-js' ;
2
+
3
+ import Cards from '../Cards.js' ;
2
4
import * as Quest from '../Quest.js' ;
5
+ import CardImage from '../Components/CardImage.jsx' ;
3
6
import ExitBtn from '../Components/ExitBtn.jsx' ;
4
7
import Text from '../Components/Text.jsx' ;
5
8
import * as store from '../store.jsx' ;
9
+ import { decodedeck } from '../etgutil.js' ;
6
10
7
- function QuestButton ( props ) {
11
+ export function QuestRewards ( props ) {
12
+ const quest = createMemo ( ( ) => {
13
+ let quest = props . quest ;
14
+ if ( ! quest ) return null ;
15
+ while ( quest . autonext ) quest = quest . autonext ;
16
+ return quest ;
17
+ } ) ;
8
18
return (
9
19
< >
10
- < span
11
- style = { {
12
- position : 'absolute' ,
13
- left : `${ props . x } px` ,
14
- top : `${ props . y } px` ,
15
- color : `#${
16
- typeof props . area === 'string' && ! props . user . quests [ props . area ] ?
17
- 'f'
18
- : 'a'
19
- } ${ props . sel ? 'ff' : 'aa' } `,
20
- } }
21
- onClick = { props . onClick } >
22
- { typeof props . area === 'string' ?
23
- Quest . quarks [ props . area ] . name
24
- : props . area . name }
25
- </ span >
26
- { Quest . extractRewards ( Quest . quarks [ props . area ] ) && ! props . user . quests [ props . area ] && (
27
- < span
28
- style = { {
29
- position : 'absolute' ,
30
- left : `${ props . x + 200 } px` ,
31
- top : `${ props . y } px` ,
32
- } } >
33
- { Quest . extractRewards ( Quest . quarks [ props . area ] ) }
34
- { Quest . extractRewards ( Quest . quarks [ props . area ] ) !== '+Card' && (
35
- < span className = "ico gold" />
20
+ { quest ( ) ?. choicerewards && (
21
+ < div style = "position:absolute;left:750px;top:156px;display:flex;height:200px;flex-direction:column" >
22
+ < div > Choice</ div >
23
+ { Array . isArray ( quest ( ) ?. choicerewards ) && (
24
+ < Index each = { quest ( ) ?. choicerewards } >
25
+ { ( reward , i ) => (
26
+ < CardImage
27
+ style = { { position : 'absolute' , top : i * 20 + 'px' } }
28
+ card = { Cards . Codes [ reward ( ) ] }
29
+ />
30
+ ) }
31
+ </ Index >
36
32
) }
37
- </ span >
33
+ { ! Array . isArray ( quest ( ) ?. choicerewards ) && quest ( ) ?. choicerewards }
34
+ </ div >
35
+ ) }
36
+ { quest ( ) ?. cardreward && (
37
+ < div style = "position:absolute;left:750px;top:156px;display:flex;height:200px;flex-direction:column" >
38
+ < div > Cards</ div >
39
+ < Index each = { decodedeck ( quest ( ) ?. cardreward ) } >
40
+ { ( code , i ) => (
41
+ < CardImage
42
+ style = { { position : 'absolute' , top : i * 20 + 'px' } }
43
+ card = { Cards . Codes [ code ( ) ] }
44
+ />
45
+ ) }
46
+ </ Index >
47
+ </ div >
48
+ ) }
49
+ { quest ( ) ?. goldreward && (
50
+ < div style = "position:absolute;left:750px;top:156px" >
51
+ { quest ( ) ?. goldreward }
52
+ < span class = "ico gold" />
53
+ </ div >
38
54
) }
39
55
</ >
40
56
) ;
41
57
}
42
58
43
- export default function QuestView ( props ) {
59
+ function QuestButton ( props ) {
60
+ return (
61
+ < span
62
+ style = { {
63
+ position : 'absolute' ,
64
+ left : `${ props . x } px` ,
65
+ top : `${ props . y } px` ,
66
+ color : `#${
67
+ typeof props . area === 'string' && ! props . quests [ props . area ] ?
68
+ 'f'
69
+ : 'a'
70
+ } ${ props . sel ? 'ff' : 'aa' } `,
71
+ } }
72
+ onClick = { props . onClick } >
73
+ { typeof props . area === 'string' ?
74
+ Quest . quarks [ props . area ] . name
75
+ : props . area . name }
76
+ </ span >
77
+ ) ;
78
+ }
79
+
80
+ export default function QuestView ( ) {
44
81
const rx = store . useRx ( ) ;
45
82
const questInfo = createMemo ( ( ) => {
46
83
const questAreas = [ ] ,
@@ -50,16 +87,18 @@ export default function QuestView(props) {
50
87
let y = 162 ;
51
88
for ( let i = 0 ; i < qbag . children . length ; i ++ ) {
52
89
const area = qbag . children [ i ] ;
53
- if ( typeof area === 'string' ) {
54
- const quark = Quest . quarks [ area ] ;
55
- if ( ! Quest . requireQuest ( quark , rx . user ) ) continue ;
90
+ if (
91
+ typeof area === 'string' &&
92
+ ! Quest . requireQuest ( Quest . quarks [ area ] , rx . user )
93
+ ) {
94
+ continue ;
56
95
}
57
96
questAreas . push (
58
97
< QuestButton
59
- x = { 8 + qi * 177 }
98
+ x = { 8 + qi * 180 }
60
99
y = { y }
61
100
area = { area }
62
- user = { rx . user }
101
+ quests = { rx . user . quests }
63
102
onClick = { ( ) => {
64
103
const newquest = quest . slice ( 0 , qi ) ;
65
104
newquest [ qi ] = i ;
@@ -82,26 +121,27 @@ export default function QuestView(props) {
82
121
< >
83
122
< div
84
123
class = "bgbox"
85
- style = "position:absolute;left:8px;top:8px;width:880px;height:108px"
86
- />
87
- < ExitBtn x = { 750 } y = { 120 } />
88
- < div style = "position:absolute;left:26px;top:26px;max-width:850px" >
124
+ style = "position:absolute;left:8px;top:8px;width:880px;height:108px;padding-left:15px;padding-top:15px" >
89
125
< Text
90
126
text = {
91
127
questInfo ( ) . selectedQuest ?. info ??
92
128
"Click list items to see quest lines, & FIGHT button to challenge them!\nNames in red are quests you haven't completed."
93
129
}
94
130
/>
95
131
</ div >
132
+ < ExitBtn x = { 750 } y = { 120 } />
96
133
{ questInfo ( ) . selectedQuest ?. key && (
97
- < input
98
- type = "button"
99
- value = "Fight!"
100
- style = "position:absolute;left:8px;top:120px"
101
- onClick = { ( ) =>
102
- store . navGame ( Quest . mkQuestAi ( questInfo ( ) . selectedQuest ) )
103
- }
104
- />
134
+ < >
135
+ < input
136
+ type = "button"
137
+ value = "Fight!"
138
+ style = "position:absolute;left:8px;top:120px"
139
+ onClick = { ( ) =>
140
+ store . navGame ( Quest . mkQuestAi ( questInfo ( ) . selectedQuest ) )
141
+ }
142
+ />
143
+ < QuestRewards quest = { Quest . quarks [ questInfo ( ) . selectedQuest . key ] } />
144
+ </ >
105
145
) }
106
146
{ questInfo ( ) . questAreas }
107
147
</ >
0 commit comments