@jetthai/cuora 1.1.468-dev.1 → 1.1.468
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/commands/sync-ai-prompts.md +1 -88
- package/.claude/settings.local.json +1 -3
- package/.github/copilot-instructions.md +57 -64
- package/.husky/post-checkout +3 -3
- package/.husky/pre-push +1 -1
- package/.prettierignore +1 -2
- package/AGENTS.md +57 -64
- package/AI_PROMPT_SOURCE.md +57 -64
- package/CHANGELOG.md +2 -184
- package/CLAUDE.md +57 -64
- package/GEMINI.md +57 -64
- package/README.md +12 -11
- package/package.json +1 -1
- package/scripts/auto-version.js +0 -1
- package/scripts/branch-auto-npm-publish.js +2 -9
- package/src/api/account.js +1 -0
- package/src/api/activity.js +37 -0
- package/src/api/auth.js +31 -0
- package/src/api/game.js +10 -0
- package/src/api/payment.js +52 -0
- package/src/api/user.js +22 -4
- package/src/index.js +2 -2
- package/src/machine/activity/activity.js +209 -0
- package/src/machine/activity/activity_cash.js +15 -23
- package/src/machine/activity/diamond_shop_activity_cash.js +1 -0
- package/src/machine/activity/diamond_shop_activity_fc.js +196 -0
- package/src/machine/activity/diamond_shop_activity_vn.js +178 -0
- package/src/machine/activity/fafafa_activity.js +10 -0
- package/src/machine/activity/index.js +12 -0
- package/src/machine/activity/invite_friends_activity.js +114 -0
- package/src/machine/activity/mini_game_activity.js +68 -0
- package/src/machine/activity/return_bonus_activity.js +153 -0
- package/src/machine/auth.js +69 -37
- package/src/machine/auth_otp_v2.js +177 -0
- package/src/machine/auth_otp_v3.js +3 -0
- package/src/machine/bank_binding_amb.js +146 -0
- package/src/machine/bonus.js +76 -0
- package/src/machine/common.js +55 -0
- package/src/machine/deposit/amb.js +93 -0
- package/src/machine/deposit/crypto_bank.js +330 -0
- package/src/machine/deposit/crypto_qrcode.js +148 -0
- package/src/machine/deposit/crypto_way.js +252 -0
- package/src/machine/deposit/deposit_fc.js +272 -0
- package/src/machine/deposit/direct.js +310 -0
- package/src/machine/deposit/float.js +375 -0
- package/src/machine/deposit/index.js +28 -0
- package/src/machine/deposit/krway.js +151 -0
- package/src/machine/deposit/loadcard_vn.js +351 -0
- package/src/machine/deposit/manual_cash.js +8 -0
- package/src/machine/deposit/manual_vn.js +458 -0
- package/src/machine/deposit/qrcode_v2.js +338 -0
- package/src/machine/deposit/usdt.js +144 -0
- package/src/machine/deposit/virtual_bank_vn.js +269 -0
- package/src/machine/deposit/vpay.js +368 -0
- package/src/machine/game_hot_new.js +79 -0
- package/src/machine/game_info.js +12 -1
- package/src/machine/game_replay.js +46 -0
- package/src/machine/game_search_v2.js +401 -0
- package/src/machine/game_v2_1.js +89 -1
- package/src/machine/honor_board.js +132 -0
- package/src/machine/inbox.js +12 -0
- package/src/machine/index.js +32 -0
- package/src/machine/merge.js +57 -0
- package/src/machine/payment_data.js +86 -0
- package/src/machine/promotions.js +170 -0
- package/src/machine/reward.js +255 -0
- package/src/machine/reward_cash.js +39 -0
- package/src/machine/reward_fc.js +98 -0
- package/src/machine/side.js +154 -0
- package/src/machine/side_v2.js +211 -0
- package/src/machine/user_reset_password.js +13 -0
- package/src/machine/user_sign_up.js +1 -6
- package/src/machine/vip_table.js +57 -0
- package/src/machine/websocket.js +4 -0
- package/src/machine/welcome.js +110 -0
- package/src/machine/withdraw/index.js +6 -0
- package/src/machine/withdraw/withdraw_crypto_cash.js +327 -0
- package/src/machine/withdraw/withdraw_krway.js +223 -0
- package/src/machine/withdraw/withdraw_manual.js +536 -0
- package/src/request/request.js +28 -0
- package/src/util/constant.js +1 -0
- package/src/util/index.js +4 -1
- package/src/util/math.js +4 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { createMachine, assign, send } from 'xstate'
|
|
2
|
+
import activity from '../api/activity.js'
|
|
3
|
+
import payment from '../api/payment.js'
|
|
4
|
+
|
|
5
|
+
export default function (request, context) {
|
|
6
|
+
const { appSecret } = request.config
|
|
7
|
+
return createMachine(
|
|
8
|
+
{
|
|
9
|
+
id: 'reward',
|
|
10
|
+
type: 'parallel',
|
|
11
|
+
context: {
|
|
12
|
+
otherRewardList: [],
|
|
13
|
+
pointsRewardList: [],
|
|
14
|
+
rewardList: [],
|
|
15
|
+
activityNo: null,
|
|
16
|
+
receiveNo: null,
|
|
17
|
+
withdrawRule: {},
|
|
18
|
+
rewardType: null,
|
|
19
|
+
isPlaying: false,
|
|
20
|
+
callback: () => {},
|
|
21
|
+
orderColumn: 'createTime',
|
|
22
|
+
lang: context?.locale,
|
|
23
|
+
},
|
|
24
|
+
states: {
|
|
25
|
+
timer: {
|
|
26
|
+
initial: 'loading',
|
|
27
|
+
states: {
|
|
28
|
+
loading: {
|
|
29
|
+
invoke: {
|
|
30
|
+
src: 'fetchRewardList',
|
|
31
|
+
onDone: {
|
|
32
|
+
target: 'pending',
|
|
33
|
+
actions: 'setRewardList',
|
|
34
|
+
},
|
|
35
|
+
onError: {
|
|
36
|
+
target: 'pending',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
pending: {
|
|
41
|
+
after: {
|
|
42
|
+
20000: [{ target: 'loading', cond: 'isNotInGame' }, { target: 'pending' }],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
on: {
|
|
47
|
+
REFRESH: {
|
|
48
|
+
target: '.loading',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
reward: {
|
|
53
|
+
initial: 'idle',
|
|
54
|
+
states: {
|
|
55
|
+
idle: {
|
|
56
|
+
on: {
|
|
57
|
+
FETCH_WITHDRAW_RULE: {
|
|
58
|
+
target: 'fetching',
|
|
59
|
+
actions: 'setRewardData',
|
|
60
|
+
},
|
|
61
|
+
FETCH_OTHER_REWARD: {
|
|
62
|
+
target: 'fetchingOtherReward',
|
|
63
|
+
actions: 'setOrderColumn',
|
|
64
|
+
},
|
|
65
|
+
RECEIVE_REWARD: {
|
|
66
|
+
target: 'receiving',
|
|
67
|
+
actions: ['setCallback', 'setRewardType'],
|
|
68
|
+
},
|
|
69
|
+
RECEIVE_ALL_POINTS: {
|
|
70
|
+
target: 'allPointsReceiving',
|
|
71
|
+
actions: 'setCallback',
|
|
72
|
+
},
|
|
73
|
+
SET_IS_PLAYING: {
|
|
74
|
+
actions: 'setIsPlaying',
|
|
75
|
+
},
|
|
76
|
+
SET_LANG: {
|
|
77
|
+
actions: 'setLang',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
fetching: {
|
|
82
|
+
invoke: {
|
|
83
|
+
src: 'fetchWithdrawRulePreview',
|
|
84
|
+
onDone: {
|
|
85
|
+
target: 'pending',
|
|
86
|
+
actions: 'setWithdrawRulePreview',
|
|
87
|
+
},
|
|
88
|
+
onError: {
|
|
89
|
+
target: 'idle',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
fetchingOtherReward: {
|
|
94
|
+
invoke: {
|
|
95
|
+
src: 'fetchOtherRewardList',
|
|
96
|
+
onDone: {
|
|
97
|
+
target: 'idle',
|
|
98
|
+
actions: 'setOtherRewardList',
|
|
99
|
+
},
|
|
100
|
+
onError: {
|
|
101
|
+
target: 'idle',
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
pending: {
|
|
106
|
+
on: {
|
|
107
|
+
RECEIVE_REWARD: {
|
|
108
|
+
target: 'receiving',
|
|
109
|
+
actions: 'setCallback',
|
|
110
|
+
},
|
|
111
|
+
BACK: {
|
|
112
|
+
target: 'idle',
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
receiving: {
|
|
117
|
+
invoke: {
|
|
118
|
+
src: 'receiveReward',
|
|
119
|
+
onDone: [
|
|
120
|
+
{ target: 'received', cond: 'isPrize', actions: send({ type: 'REFRESH' }) },
|
|
121
|
+
{ target: 'received', actions: [send({ type: 'REFRESH' }), 'doCallback'] },
|
|
122
|
+
],
|
|
123
|
+
onError: {
|
|
124
|
+
target: 'idle',
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
received: {
|
|
129
|
+
after: {
|
|
130
|
+
0: {
|
|
131
|
+
target: 'idle',
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
allPointsReceiving: {
|
|
136
|
+
invoke: {
|
|
137
|
+
src: 'receiveAllPoints',
|
|
138
|
+
onDone: {
|
|
139
|
+
target: 'idle',
|
|
140
|
+
actions: [send({ type: 'REFRESH' }), 'doCallback'],
|
|
141
|
+
},
|
|
142
|
+
onError: {
|
|
143
|
+
target: 'idle',
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
actions: {
|
|
153
|
+
setRewardList: assign((context, event) => {
|
|
154
|
+
return {
|
|
155
|
+
otherRewardList: event.data[0]?.data || [],
|
|
156
|
+
pointsRewardList: event.data[1]?.data || [],
|
|
157
|
+
rewardList: event.data[2]?.data || [],
|
|
158
|
+
}
|
|
159
|
+
}),
|
|
160
|
+
setOtherRewardList: assign((context, event) => {
|
|
161
|
+
return {
|
|
162
|
+
otherRewardList: event.data[0]?.data,
|
|
163
|
+
}
|
|
164
|
+
}),
|
|
165
|
+
setRewardData: assign((context, event) => {
|
|
166
|
+
const { activityNo, receiveNo } = event.data
|
|
167
|
+
return {
|
|
168
|
+
activityNo,
|
|
169
|
+
receiveNo,
|
|
170
|
+
}
|
|
171
|
+
}),
|
|
172
|
+
setCallback: assign((context, event) => {
|
|
173
|
+
return {
|
|
174
|
+
callback: event.data?.callback || (() => {}),
|
|
175
|
+
}
|
|
176
|
+
}),
|
|
177
|
+
setOrderColumn: assign((context, event) => {
|
|
178
|
+
return {
|
|
179
|
+
orderColumn: event.data?.orderColumn || 'createTime',
|
|
180
|
+
}
|
|
181
|
+
}),
|
|
182
|
+
setRewardType: assign((context, event) => {
|
|
183
|
+
return {
|
|
184
|
+
rewardType: event.data?.rewardType,
|
|
185
|
+
}
|
|
186
|
+
}),
|
|
187
|
+
doCallback: (context, event) => {
|
|
188
|
+
context.callback()
|
|
189
|
+
},
|
|
190
|
+
setWithdrawRulePreview: assign((context, event) => {
|
|
191
|
+
return {
|
|
192
|
+
withdrawRule: event.data,
|
|
193
|
+
}
|
|
194
|
+
}),
|
|
195
|
+
setIsPlaying: assign((context, event) => {
|
|
196
|
+
return {
|
|
197
|
+
isPlaying: event.data,
|
|
198
|
+
}
|
|
199
|
+
}),
|
|
200
|
+
setLang: assign((context, event) => {
|
|
201
|
+
const lang = event.data.locale || context.lang || 'en-US'
|
|
202
|
+
return { lang }
|
|
203
|
+
}),
|
|
204
|
+
},
|
|
205
|
+
guards: {
|
|
206
|
+
isPrize: (context, event) => {
|
|
207
|
+
const { rewardType } = context
|
|
208
|
+
return rewardType === 'PRIZE'
|
|
209
|
+
},
|
|
210
|
+
isNotInGame: (context, event) => {
|
|
211
|
+
return !context.isPlaying
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
services: {
|
|
215
|
+
fetchRewardList: async (context, event) => {
|
|
216
|
+
const lang = context.lang
|
|
217
|
+
const orderColumn = context.orderColumn
|
|
218
|
+
const getRewardAPI = request.send(activity.getRewardList({ count: 30, appSecret, lang }))
|
|
219
|
+
const getPointsRewardAPI = request.send(activity.getRewardList({ rewardType: 'POINTS', count: 30, appSecret, lang }))
|
|
220
|
+
const getOtherRewardAPI = request.send(activity.getRewardList({ rewardType: 'CASH,FREE,PRIZE', count: 30, appSecret, orderColumn, lang }))
|
|
221
|
+
const [otherRewardList, pointsRewardList, rewardList] = await Promise.all([getOtherRewardAPI, getPointsRewardAPI, getRewardAPI])
|
|
222
|
+
return [otherRewardList, pointsRewardList, rewardList]
|
|
223
|
+
},
|
|
224
|
+
fetchOtherRewardList: async (context, event) => {
|
|
225
|
+
const orderColumn = context.orderColumn
|
|
226
|
+
const lang = context.lang
|
|
227
|
+
const getOtherRewardAPI = request.send(
|
|
228
|
+
activity.getRewardList({
|
|
229
|
+
rewardType: 'CASH,FREE,PRIZE',
|
|
230
|
+
count: 30,
|
|
231
|
+
appSecret,
|
|
232
|
+
orderColumn,
|
|
233
|
+
lang,
|
|
234
|
+
})
|
|
235
|
+
)
|
|
236
|
+
const [otherRewardList] = await Promise.all([getOtherRewardAPI])
|
|
237
|
+
return [otherRewardList]
|
|
238
|
+
},
|
|
239
|
+
fetchWithdrawRulePreview: async (context, event) => {
|
|
240
|
+
const { receiveNo } = context
|
|
241
|
+
const data = await request.send(payment.getWithdrawRulePreview({ applyType: 'activity', applyNo: receiveNo, amount: null }))
|
|
242
|
+
return data
|
|
243
|
+
},
|
|
244
|
+
receiveReward: async (context, event) => {
|
|
245
|
+
const { activityNo, receiveNo, attended } = event.data
|
|
246
|
+
const validateReceiveNo = Number(receiveNo) > 0 ? Number(receiveNo) : undefined
|
|
247
|
+
return await request.send(activity.getReward({ activityNo, receiveNo: validateReceiveNo, appSecret, attended }))
|
|
248
|
+
},
|
|
249
|
+
receiveAllPoints: async (context, event) => {
|
|
250
|
+
return await request.send(activity.collect({ collectType: 'collectPoints', appSecret }))
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
}
|
|
254
|
+
)
|
|
255
|
+
}
|
|
@@ -63,6 +63,10 @@ export default function (request, context) {
|
|
|
63
63
|
states: {
|
|
64
64
|
idle: {
|
|
65
65
|
on: {
|
|
66
|
+
FETCH_WITHDRAW_RULE: {
|
|
67
|
+
target: 'fetching',
|
|
68
|
+
actions: 'setRewardData',
|
|
69
|
+
},
|
|
66
70
|
FETCH_OTHER_REWARD: {
|
|
67
71
|
target: 'fetchingOtherReward',
|
|
68
72
|
actions: 'setOrderColumn',
|
|
@@ -80,6 +84,18 @@ export default function (request, context) {
|
|
|
80
84
|
},
|
|
81
85
|
},
|
|
82
86
|
},
|
|
87
|
+
fetching: {
|
|
88
|
+
invoke: {
|
|
89
|
+
src: 'fetchWithdrawRulePreview',
|
|
90
|
+
onDone: {
|
|
91
|
+
target: 'pending',
|
|
92
|
+
actions: 'setWithdrawRulePreview',
|
|
93
|
+
},
|
|
94
|
+
onError: {
|
|
95
|
+
target: 'idle',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
83
99
|
fetchingOtherReward: {
|
|
84
100
|
invoke: {
|
|
85
101
|
src: 'fetchOtherRewardList',
|
|
@@ -164,6 +180,13 @@ export default function (request, context) {
|
|
|
164
180
|
otherRewardList: event.data[0]?.data,
|
|
165
181
|
}
|
|
166
182
|
}),
|
|
183
|
+
setRewardData: assign((context, event) => {
|
|
184
|
+
const { activityNo, receiveNo } = event.data
|
|
185
|
+
return {
|
|
186
|
+
activityNo,
|
|
187
|
+
receiveNo,
|
|
188
|
+
}
|
|
189
|
+
}),
|
|
167
190
|
setCallback: assign((context, event) => {
|
|
168
191
|
return {
|
|
169
192
|
callback: event.data?.callback || (() => {}),
|
|
@@ -177,6 +200,11 @@ export default function (request, context) {
|
|
|
177
200
|
doCallback: (context, event) => {
|
|
178
201
|
context.callback()
|
|
179
202
|
},
|
|
203
|
+
setWithdrawRulePreview: assign((context, event) => {
|
|
204
|
+
return {
|
|
205
|
+
withdrawRule: event.data,
|
|
206
|
+
}
|
|
207
|
+
}),
|
|
180
208
|
setLang: assign((context, event) => {
|
|
181
209
|
const lang = event.data.locale || context.lang || 'en-US'
|
|
182
210
|
return { lang }
|
|
@@ -222,6 +250,17 @@ export default function (request, context) {
|
|
|
222
250
|
const [otherRewardList] = await Promise.all([getOtherRewardAPI])
|
|
223
251
|
return [otherRewardList]
|
|
224
252
|
},
|
|
253
|
+
fetchWithdrawRulePreview: async (context, event) => {
|
|
254
|
+
const { receiveNo } = context
|
|
255
|
+
const data = await request.send(
|
|
256
|
+
payment.getWithdrawRulePreview({
|
|
257
|
+
applyType: 'activity',
|
|
258
|
+
applyNo: receiveNo,
|
|
259
|
+
amount: null,
|
|
260
|
+
})
|
|
261
|
+
)
|
|
262
|
+
return data
|
|
263
|
+
},
|
|
225
264
|
receiveReward: async (context, event) => {
|
|
226
265
|
const { activityNo, receiveNo, attended } = event.data
|
|
227
266
|
// Number("")-> 0 / Number(" ") -> 0 需要收到實際的數字才傳給後端
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { createMachine, assign, send } from 'xstate'
|
|
2
|
+
import activity from '../api/activity.js'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
const { appSecret } = request.config
|
|
6
|
+
return createMachine(
|
|
7
|
+
{
|
|
8
|
+
id: 'reward',
|
|
9
|
+
type: 'parallel',
|
|
10
|
+
context: {
|
|
11
|
+
rewardList: [],
|
|
12
|
+
callback: () => {},
|
|
13
|
+
},
|
|
14
|
+
states: {
|
|
15
|
+
timer: {
|
|
16
|
+
initial: 'loading',
|
|
17
|
+
states: {
|
|
18
|
+
loading: {
|
|
19
|
+
invoke: {
|
|
20
|
+
src: 'fetchRewardList',
|
|
21
|
+
onDone: {
|
|
22
|
+
target: 'pending',
|
|
23
|
+
actions: 'setRewardList',
|
|
24
|
+
},
|
|
25
|
+
onError: {
|
|
26
|
+
target: 'pending',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
pending: {
|
|
31
|
+
after: {
|
|
32
|
+
20000: { target: 'loading' },
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
on: {
|
|
37
|
+
REFRESH: {
|
|
38
|
+
target: '.loading',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
reward: {
|
|
43
|
+
initial: 'idle',
|
|
44
|
+
states: {
|
|
45
|
+
idle: {
|
|
46
|
+
on: {
|
|
47
|
+
RECEIVE_REWARD: {
|
|
48
|
+
target: 'receiving',
|
|
49
|
+
actions: 'setCallback',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
receiving: {
|
|
54
|
+
invoke: {
|
|
55
|
+
src: 'receiveReward',
|
|
56
|
+
onDone: {
|
|
57
|
+
target: 'idle',
|
|
58
|
+
actions: [send({ type: 'REFRESH' }), 'doCallback'],
|
|
59
|
+
},
|
|
60
|
+
onError: {
|
|
61
|
+
target: 'idle',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
actions: {
|
|
71
|
+
setRewardList: assign((context, event) => {
|
|
72
|
+
return {
|
|
73
|
+
rewardList: event.data || [],
|
|
74
|
+
}
|
|
75
|
+
}),
|
|
76
|
+
setCallback: assign((context, event) => {
|
|
77
|
+
return {
|
|
78
|
+
callback: event.data?.callback || (() => {}),
|
|
79
|
+
}
|
|
80
|
+
}),
|
|
81
|
+
doCallback: (context, event) => {
|
|
82
|
+
context.callback()
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
services: {
|
|
86
|
+
fetchRewardList: async (context, event) => {
|
|
87
|
+
const { data } = await request.send(activity.getRewardList({ count: 30, appSecret }))
|
|
88
|
+
return data
|
|
89
|
+
},
|
|
90
|
+
receiveReward: async (context, event) => {
|
|
91
|
+
const { activityNo, receiveNo, attended } = event.data
|
|
92
|
+
const validateReceiveNo = Number(receiveNo) > 0 ? Number(receiveNo) : undefined
|
|
93
|
+
return await request.send(activity.getReward({ activityNo, receiveNo: validateReceiveNo, appSecret, attended }))
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import api from '../api/game.js'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
return createMachine(
|
|
6
|
+
{
|
|
7
|
+
id: 'side',
|
|
8
|
+
initial: 'preparing',
|
|
9
|
+
context: {
|
|
10
|
+
menu: {},
|
|
11
|
+
room: null,
|
|
12
|
+
roomHistory: [],
|
|
13
|
+
},
|
|
14
|
+
states: {
|
|
15
|
+
preparing: {
|
|
16
|
+
invoke: {
|
|
17
|
+
src: 'getRoomItems',
|
|
18
|
+
onDone: {
|
|
19
|
+
target: 'room',
|
|
20
|
+
actions: 'makeMenu',
|
|
21
|
+
},
|
|
22
|
+
onError: {
|
|
23
|
+
target: 'room',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
room: {
|
|
28
|
+
initial: 'home',
|
|
29
|
+
states: {
|
|
30
|
+
home: {
|
|
31
|
+
entry: createSideAction('home'),
|
|
32
|
+
},
|
|
33
|
+
favorite: {
|
|
34
|
+
entry: createSideAction('favorite'),
|
|
35
|
+
},
|
|
36
|
+
hot: {
|
|
37
|
+
entry: createSideAction('hot'),
|
|
38
|
+
},
|
|
39
|
+
new: {
|
|
40
|
+
entry: createSideAction('new'),
|
|
41
|
+
},
|
|
42
|
+
slot: {
|
|
43
|
+
entry: createSideAction('slot'),
|
|
44
|
+
},
|
|
45
|
+
fish: {
|
|
46
|
+
entry: createSideAction('fish'),
|
|
47
|
+
},
|
|
48
|
+
arcade: {
|
|
49
|
+
entry: createSideAction('arcade'),
|
|
50
|
+
},
|
|
51
|
+
table: {
|
|
52
|
+
entry: createSideAction('table'),
|
|
53
|
+
},
|
|
54
|
+
search: {},
|
|
55
|
+
history: {
|
|
56
|
+
type: 'history',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
feature: {
|
|
61
|
+
on: {
|
|
62
|
+
RETURN: { target: 'room.history' },
|
|
63
|
+
CLICK_HOT: { target: 'room.hot', actions: 'resetRoomHistory' },
|
|
64
|
+
CLICK_NEW: { target: 'room.new', actions: 'resetRoomHistory' },
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
category: {
|
|
68
|
+
on: {
|
|
69
|
+
RETURN: { target: 'room.history' },
|
|
70
|
+
CLICK_SLOT: { target: 'room.slot', actions: 'resetRoomHistory' },
|
|
71
|
+
CLICK_FISH: { target: 'room.fish', actions: 'resetRoomHistory' },
|
|
72
|
+
CLICK_ARCADE: { target: 'room.arcade', actions: 'resetRoomHistory' },
|
|
73
|
+
CLICK_TABLE: { target: 'room.table', actions: 'resetRoomHistory' },
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
on: {
|
|
78
|
+
CLICK_HOME: { target: 'room.home', actions: 'resetRoomHistory' },
|
|
79
|
+
CLICK_FAVORITE: { target: 'room.favorite', actions: 'resetRoomHistory' },
|
|
80
|
+
CLICK_FEATURE: { target: 'feature' },
|
|
81
|
+
CLICK_CATEGORY: { target: 'category' },
|
|
82
|
+
CLICK_SEARCH: { target: 'room.search' },
|
|
83
|
+
FORWARD_ROOM: { actions: 'forwardRoom' },
|
|
84
|
+
BACKWARD_ROOM: { actions: 'backwardRoom' },
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
actions: {
|
|
89
|
+
makeMenu: assign((context, event) => {
|
|
90
|
+
const { list = [] } = event.data
|
|
91
|
+
const map = {
|
|
92
|
+
home: ['SYSTEM_PERSONAL', 'SYSTEM_INDEX_LIST'],
|
|
93
|
+
favorite: 'SYSTEM_MY_FAVORITE',
|
|
94
|
+
hot: 'SYSTEM_TOP_GAME',
|
|
95
|
+
new: 'SYSTEM_NEW_GAME',
|
|
96
|
+
slot: 'SYSTEM_BIG_CATEGORY_SLOT',
|
|
97
|
+
fish: 'SYSTEM_BIG_CATEGORY_FISHING',
|
|
98
|
+
arcade: 'SYSTEM_BIG_CATEGORY_ARCADE',
|
|
99
|
+
table: 'SYSTEM_BIG_CATEGORY_TABLECARD',
|
|
100
|
+
}
|
|
101
|
+
const menu = {}
|
|
102
|
+
Object.keys(map).forEach((key) => {
|
|
103
|
+
if (Array.isArray(map[key])) {
|
|
104
|
+
// 若是陣列則依順序決定館別內容
|
|
105
|
+
map[key].some((val) => {
|
|
106
|
+
const category = list.find((item) => item.category === val)
|
|
107
|
+
if (category) {
|
|
108
|
+
menu[key] = category
|
|
109
|
+
return true
|
|
110
|
+
} else {
|
|
111
|
+
return false
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
} else {
|
|
115
|
+
menu[key] = list.find((item) => item.category === map[key])
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
return { menu }
|
|
119
|
+
}),
|
|
120
|
+
forwardRoom: assign((context, event) => {
|
|
121
|
+
return {
|
|
122
|
+
room: event.data,
|
|
123
|
+
roomHistory: [...context.roomHistory, context.room],
|
|
124
|
+
}
|
|
125
|
+
}),
|
|
126
|
+
backwardRoom: assign((context, event) => {
|
|
127
|
+
const { roomHistory } = context
|
|
128
|
+
return {
|
|
129
|
+
room: roomHistory.slice(-1)[0],
|
|
130
|
+
roomHistory: roomHistory.slice(0, -1),
|
|
131
|
+
}
|
|
132
|
+
}),
|
|
133
|
+
resetRoomHistory: assign((context, event) => {
|
|
134
|
+
return {
|
|
135
|
+
roomHistory: [],
|
|
136
|
+
}
|
|
137
|
+
}),
|
|
138
|
+
},
|
|
139
|
+
services: {
|
|
140
|
+
getRoomItems: async (context, event) => {
|
|
141
|
+
return await request.send(api.getGameCategory({ id: context.room?.id }))
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function createSideAction(name) {
|
|
149
|
+
return assign((context, event) => {
|
|
150
|
+
if (!context.roomHistory.some((item) => item.id === context.menu[name].id)) {
|
|
151
|
+
return { room: context.menu[name] }
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
}
|