@jetthai/cuora 1.1.470 → 1.1.471-dev.0
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 +88 -1
- package/.claude/settings.local.json +3 -1
- package/.github/copilot-instructions.md +65 -58
- package/.husky/post-checkout +3 -3
- package/.husky/pre-push +1 -1
- package/.prettierignore +2 -1
- package/AGENTS.md +65 -58
- package/AI_PROMPT_SOURCE.md +65 -58
- package/CHANGELOG.md +191 -5
- package/CLAUDE.md +65 -58
- package/GEMINI.md +65 -58
- package/README.md +11 -12
- package/package.json +1 -1
- package/scripts/auto-version.js +1 -0
- package/scripts/branch-auto-npm-publish.js +9 -2
- package/src/api/account.js +0 -1
- package/src/api/activity.js +2 -38
- package/src/api/auth.js +0 -31
- package/src/api/game.js +0 -10
- package/src/api/payment.js +1 -52
- package/src/api/user.js +4 -22
- package/src/index.js +2 -2
- package/src/machine/activity/activity_cash.js +50 -23
- package/src/machine/activity/diamond_shop_activity_cash.js +0 -1
- package/src/machine/activity/fafafa_activity.js +0 -10
- package/src/machine/activity/index.js +0 -12
- package/src/machine/auth.js +16 -68
- package/src/machine/auth_otp_v3.js +0 -3
- package/src/machine/common.js +0 -55
- package/src/machine/deposit/index.js +0 -28
- package/src/machine/deposit/manual_cash.js +0 -8
- package/src/machine/game_info.js +1 -12
- package/src/machine/game_v2_1.js +1 -89
- package/src/machine/inbox.js +0 -12
- package/src/machine/index.js +0 -32
- package/src/machine/reward_cash.js +0 -39
- package/src/machine/user_reset_password.js +0 -13
- package/src/machine/user_sign_up.js +3 -0
- package/src/machine/websocket.js +0 -4
- package/src/machine/withdraw/index.js +0 -6
- package/src/request/request.js +1 -29
- package/src/util/constant.js +0 -1
- package/src/util/index.js +1 -4
- package/src/machine/activity/activity.js +0 -209
- package/src/machine/activity/diamond_shop_activity_fc.js +0 -196
- package/src/machine/activity/diamond_shop_activity_vn.js +0 -178
- package/src/machine/activity/invite_friends_activity.js +0 -114
- package/src/machine/activity/mini_game_activity.js +0 -68
- package/src/machine/activity/return_bonus_activity.js +0 -153
- package/src/machine/auth_otp_v2.js +0 -177
- package/src/machine/bank_binding_amb.js +0 -146
- package/src/machine/bonus.js +0 -76
- package/src/machine/deposit/amb.js +0 -93
- package/src/machine/deposit/crypto_bank.js +0 -330
- package/src/machine/deposit/crypto_qrcode.js +0 -148
- package/src/machine/deposit/crypto_way.js +0 -252
- package/src/machine/deposit/deposit_fc.js +0 -272
- package/src/machine/deposit/direct.js +0 -310
- package/src/machine/deposit/float.js +0 -375
- package/src/machine/deposit/krway.js +0 -151
- package/src/machine/deposit/loadcard_vn.js +0 -351
- package/src/machine/deposit/manual_vn.js +0 -458
- package/src/machine/deposit/qrcode_v2.js +0 -338
- package/src/machine/deposit/usdt.js +0 -144
- package/src/machine/deposit/virtual_bank_vn.js +0 -269
- package/src/machine/deposit/vpay.js +0 -368
- package/src/machine/game_hot_new.js +0 -79
- package/src/machine/game_replay.js +0 -46
- package/src/machine/game_search_v2.js +0 -401
- package/src/machine/honor_board.js +0 -132
- package/src/machine/merge.js +0 -57
- package/src/machine/payment_data.js +0 -86
- package/src/machine/promotions.js +0 -170
- package/src/machine/reward.js +0 -255
- package/src/machine/reward_fc.js +0 -98
- package/src/machine/side.js +0 -154
- package/src/machine/side_v2.js +0 -211
- package/src/machine/vip_table.js +0 -57
- package/src/machine/welcome.js +0 -110
- package/src/machine/withdraw/withdraw_crypto_cash.js +0 -327
- package/src/machine/withdraw/withdraw_krway.js +0 -223
- package/src/machine/withdraw/withdraw_manual.js +0 -536
- package/src/util/math.js +0 -4
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import game from '../api/game.js'
|
|
3
|
-
|
|
4
|
-
export default function (request, context) {
|
|
5
|
-
const { appSecret } = request.config
|
|
6
|
-
const { providerId, seqNo, lang } = context
|
|
7
|
-
return createMachine(
|
|
8
|
-
{
|
|
9
|
-
id: 'game_replay',
|
|
10
|
-
initial: 'fetching',
|
|
11
|
-
context: {
|
|
12
|
-
gameReplayInfo: {},
|
|
13
|
-
},
|
|
14
|
-
states: {
|
|
15
|
-
fetching: {
|
|
16
|
-
invoke: {
|
|
17
|
-
src: 'fetchGameReplayInfo',
|
|
18
|
-
onDone: {
|
|
19
|
-
target: 'idle',
|
|
20
|
-
actions: 'setGameReplayInfo',
|
|
21
|
-
},
|
|
22
|
-
onError: {
|
|
23
|
-
target: 'idle',
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
idle: {},
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
actions: {
|
|
32
|
-
setGameReplayInfo: assign((context, event) => {
|
|
33
|
-
return {
|
|
34
|
-
gameReplayInfo: event.data.data,
|
|
35
|
-
}
|
|
36
|
-
}),
|
|
37
|
-
},
|
|
38
|
-
services: {
|
|
39
|
-
// 取得遊戲重播資訊
|
|
40
|
-
fetchGameReplayInfo: async (context, event) => {
|
|
41
|
-
return await request.send(game.getGameReplayInfo({ providerId, seqNo, lang, appSecret }))
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
}
|
|
45
|
-
)
|
|
46
|
-
}
|
|
@@ -1,401 +0,0 @@
|
|
|
1
|
-
import { createMachine, assign, send } from 'xstate'
|
|
2
|
-
import game from '../api/game.js'
|
|
3
|
-
|
|
4
|
-
export default function (request) {
|
|
5
|
-
return createMachine(
|
|
6
|
-
{
|
|
7
|
-
id: 'game_search_v2',
|
|
8
|
-
initial: 'init',
|
|
9
|
-
context: {
|
|
10
|
-
keyword: '',
|
|
11
|
-
tagId: null,
|
|
12
|
-
mainTagList: [],
|
|
13
|
-
tagList: [],
|
|
14
|
-
gameList: [],
|
|
15
|
-
recentlySearch: [],
|
|
16
|
-
recentlyGame: [],
|
|
17
|
-
youMayLike: [],
|
|
18
|
-
// 以下變數為數據分析用
|
|
19
|
-
selectedType: null,
|
|
20
|
-
tagIndex: null,
|
|
21
|
-
click: null,
|
|
22
|
-
clickDefault: null,
|
|
23
|
-
traceId: null,
|
|
24
|
-
isYouMayLike: false,
|
|
25
|
-
isRecentlyGame: false,
|
|
26
|
-
isRecentlySearch: false,
|
|
27
|
-
gameCode: null,
|
|
28
|
-
lang: 'en-US',
|
|
29
|
-
},
|
|
30
|
-
states: {
|
|
31
|
-
init: {
|
|
32
|
-
on: {
|
|
33
|
-
INIT: {
|
|
34
|
-
target: 'preset',
|
|
35
|
-
actions: ['setLang'],
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
preset: {
|
|
40
|
-
invoke: {
|
|
41
|
-
src: 'fetchTags',
|
|
42
|
-
onDone: {
|
|
43
|
-
target: 'loading',
|
|
44
|
-
actions: 'setMainTagList',
|
|
45
|
-
},
|
|
46
|
-
onError: {
|
|
47
|
-
target: 'fail',
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
loading: {
|
|
52
|
-
invoke: {
|
|
53
|
-
src: 'fetchInitialData',
|
|
54
|
-
onDone: {
|
|
55
|
-
target: 'idle',
|
|
56
|
-
actions: 'setInitialData',
|
|
57
|
-
},
|
|
58
|
-
onError: {
|
|
59
|
-
target: '#game_search_v2.fail',
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
idle: {
|
|
64
|
-
on: {
|
|
65
|
-
SET_MAIN_TAG_ID: {
|
|
66
|
-
target: 'setGameList',
|
|
67
|
-
actions: ['setMainTagId', 'setTraceData'],
|
|
68
|
-
},
|
|
69
|
-
PLAY_GAME: {
|
|
70
|
-
target: 'sendingTrace',
|
|
71
|
-
actions: 'setGameCode',
|
|
72
|
-
},
|
|
73
|
-
START_SEARCH: {
|
|
74
|
-
target: 'searching',
|
|
75
|
-
actions: 'clearKeywords',
|
|
76
|
-
},
|
|
77
|
-
CLEAR_MAIN_TAG: {
|
|
78
|
-
actions: 'clearMainTag',
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
setGameList: {
|
|
83
|
-
always: [
|
|
84
|
-
{
|
|
85
|
-
target: 'idle',
|
|
86
|
-
actions: 'setGames',
|
|
87
|
-
cond: 'isRecentlyYouMayLike',
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
target: 'fetchGameList',
|
|
91
|
-
},
|
|
92
|
-
],
|
|
93
|
-
},
|
|
94
|
-
fetchGameList: {
|
|
95
|
-
invoke: {
|
|
96
|
-
src: 'fetchGames',
|
|
97
|
-
onDone: {
|
|
98
|
-
target: 'idle',
|
|
99
|
-
actions: 'setGames',
|
|
100
|
-
},
|
|
101
|
-
onError: {
|
|
102
|
-
target: '#game_search_v2.fail',
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
searching: {
|
|
107
|
-
initial: 'searchIdle',
|
|
108
|
-
states: {
|
|
109
|
-
searchIdle: {
|
|
110
|
-
on: {
|
|
111
|
-
SET_TAG_ID: {
|
|
112
|
-
target: '#game_search_v2.fetchGameList',
|
|
113
|
-
actions: ['setTagId', 'setTraceData'],
|
|
114
|
-
},
|
|
115
|
-
PRESS_ENTER: [
|
|
116
|
-
{
|
|
117
|
-
actions: send((context, event) => ({
|
|
118
|
-
type: 'SET_TAG_ID',
|
|
119
|
-
data: {
|
|
120
|
-
tagId: context.tagList[0]?.id,
|
|
121
|
-
traceData: {
|
|
122
|
-
isYouMayLike: false,
|
|
123
|
-
isRecentlyGame: false,
|
|
124
|
-
isRecentlySearch: false,
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
})),
|
|
128
|
-
cond: 'hasTagList',
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
target: '#game_search_v2.sendingTrace',
|
|
132
|
-
actions: 'clearExceptKeyword',
|
|
133
|
-
},
|
|
134
|
-
],
|
|
135
|
-
SET_KEYWORD: {
|
|
136
|
-
target: 'debouncing',
|
|
137
|
-
actions: ['setKeyword', 'setLang'],
|
|
138
|
-
},
|
|
139
|
-
STOP_SEARCH: {
|
|
140
|
-
target: '#game_search_v2.idle',
|
|
141
|
-
actions: 'clearKeywords',
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
debouncing: {
|
|
146
|
-
on: {
|
|
147
|
-
SET_KEYWORD: {
|
|
148
|
-
target: 'debouncing',
|
|
149
|
-
actions: ['setKeyword', 'setLang'],
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
after: {
|
|
153
|
-
500: {
|
|
154
|
-
target: 'fetching',
|
|
155
|
-
},
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
fetching: {
|
|
159
|
-
invoke: {
|
|
160
|
-
src: 'fetchTags',
|
|
161
|
-
onDone: {
|
|
162
|
-
target: 'searchIdle',
|
|
163
|
-
actions: 'setTagList',
|
|
164
|
-
},
|
|
165
|
-
onError: {
|
|
166
|
-
target: '#game_search_v2.fail',
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
sendingTrace: {
|
|
173
|
-
invoke: {
|
|
174
|
-
src: 'sendTrace',
|
|
175
|
-
onDone: {
|
|
176
|
-
target: 'idle',
|
|
177
|
-
},
|
|
178
|
-
onError: {
|
|
179
|
-
target: 'fail',
|
|
180
|
-
},
|
|
181
|
-
},
|
|
182
|
-
},
|
|
183
|
-
fail: {},
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
actions: {
|
|
188
|
-
setMainTagList: assign((context, event) => {
|
|
189
|
-
return {
|
|
190
|
-
mainTagList: event.data,
|
|
191
|
-
}
|
|
192
|
-
}),
|
|
193
|
-
setInitialData: assign((context, event) => {
|
|
194
|
-
const { recentlySearch = [], recentlyGame = [], youMayLike = [] } = event.data
|
|
195
|
-
let tagId = null
|
|
196
|
-
let gameList = []
|
|
197
|
-
if (recentlyGame?.length > 0) {
|
|
198
|
-
gameList = recentlyGame
|
|
199
|
-
} else if (youMayLike?.length > 0) {
|
|
200
|
-
gameList = youMayLike
|
|
201
|
-
}
|
|
202
|
-
return {
|
|
203
|
-
recentlySearch: recentlySearch.filter((item) => item.id && item.i18n),
|
|
204
|
-
recentlyGame,
|
|
205
|
-
youMayLike,
|
|
206
|
-
gameList,
|
|
207
|
-
tagId,
|
|
208
|
-
}
|
|
209
|
-
}),
|
|
210
|
-
setMainTagId: assign((context, event) => {
|
|
211
|
-
const { tagId } = event.data
|
|
212
|
-
const { mainTagList } = context
|
|
213
|
-
const tagIndex = mainTagList.findIndex((tag) => tag.id === tagId)
|
|
214
|
-
return {
|
|
215
|
-
keyword: '',
|
|
216
|
-
tagId,
|
|
217
|
-
tagIndex,
|
|
218
|
-
click: 1,
|
|
219
|
-
clickDefault: null,
|
|
220
|
-
}
|
|
221
|
-
}),
|
|
222
|
-
clearMainTag: assign((context, event) => {
|
|
223
|
-
return {
|
|
224
|
-
tagId: null,
|
|
225
|
-
}
|
|
226
|
-
}),
|
|
227
|
-
setTagId: assign((context, event) => {
|
|
228
|
-
const { tagId, clickTagType } = event.data
|
|
229
|
-
const { mainTagList, tagList, recentlySearch } = context
|
|
230
|
-
if (clickTagType === 'RECENTLY SEARCH') {
|
|
231
|
-
const tagIndex = recentlySearch.findIndex((tag) => tag.id === tagId)
|
|
232
|
-
return {
|
|
233
|
-
tagId,
|
|
234
|
-
tagIndex,
|
|
235
|
-
click: 1,
|
|
236
|
-
clickDefault: null,
|
|
237
|
-
}
|
|
238
|
-
} else if (clickTagType === 'POPULAR KEYWORDS' || tagList.length <= 0) {
|
|
239
|
-
const tagIndex = mainTagList.findIndex((tag) => tag.id === tagId)
|
|
240
|
-
return {
|
|
241
|
-
tagId,
|
|
242
|
-
tagIndex,
|
|
243
|
-
click: null,
|
|
244
|
-
clickDefault: 1,
|
|
245
|
-
}
|
|
246
|
-
} else {
|
|
247
|
-
const tagIndex = tagList.findIndex((tag) => tag.id === tagId)
|
|
248
|
-
return {
|
|
249
|
-
tagId,
|
|
250
|
-
tagIndex,
|
|
251
|
-
click: 1,
|
|
252
|
-
clickDefault: null,
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}),
|
|
256
|
-
setGames: assign((context, event) => {
|
|
257
|
-
if (event?.data) {
|
|
258
|
-
const { traceId, result } = event.data
|
|
259
|
-
return {
|
|
260
|
-
traceId,
|
|
261
|
-
gameList: result,
|
|
262
|
-
}
|
|
263
|
-
} else {
|
|
264
|
-
const { tagId, recentlyGame, youMayLike } = context
|
|
265
|
-
let gameList = []
|
|
266
|
-
if (tagId === 'Recently') {
|
|
267
|
-
gameList = recentlyGame
|
|
268
|
-
} else if (tagId === 'You may like') {
|
|
269
|
-
gameList = youMayLike
|
|
270
|
-
}
|
|
271
|
-
return {
|
|
272
|
-
traceId: null,
|
|
273
|
-
gameList,
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}),
|
|
277
|
-
setTraceData: assign((context, event) => {
|
|
278
|
-
const { isYouMayLike, isRecentlyGame, isRecentlySearch } = event.data?.traceData
|
|
279
|
-
return {
|
|
280
|
-
isYouMayLike,
|
|
281
|
-
isRecentlyGame,
|
|
282
|
-
isRecentlySearch,
|
|
283
|
-
}
|
|
284
|
-
}),
|
|
285
|
-
setKeyword: assign((context, event) => {
|
|
286
|
-
return {
|
|
287
|
-
keyword: event.data.keyword,
|
|
288
|
-
}
|
|
289
|
-
}),
|
|
290
|
-
setLang: assign((context, event) => {
|
|
291
|
-
return {
|
|
292
|
-
lang: event.data.lang,
|
|
293
|
-
}
|
|
294
|
-
}),
|
|
295
|
-
clearKeywords: assign((context, event) => {
|
|
296
|
-
return {
|
|
297
|
-
keyword: '',
|
|
298
|
-
}
|
|
299
|
-
}),
|
|
300
|
-
setTagList: assign((context, event) => {
|
|
301
|
-
return {
|
|
302
|
-
tagList: event.data,
|
|
303
|
-
}
|
|
304
|
-
}),
|
|
305
|
-
setGameCode: assign((context, event) => {
|
|
306
|
-
const { gameList } = context
|
|
307
|
-
const gameCode = event.data
|
|
308
|
-
const gameCodeIndex = gameList.findIndex((game) => game?.gameCode === gameCode)
|
|
309
|
-
return {
|
|
310
|
-
gameCode,
|
|
311
|
-
gameCodeIndex,
|
|
312
|
-
}
|
|
313
|
-
}),
|
|
314
|
-
clearExceptKeyword: assign((context, event) => {
|
|
315
|
-
return {
|
|
316
|
-
gameList: [],
|
|
317
|
-
traceId: null,
|
|
318
|
-
tagId: null,
|
|
319
|
-
tagIndex: null,
|
|
320
|
-
gameCode: null,
|
|
321
|
-
gameCodeIndex: null,
|
|
322
|
-
isYouMayLike: false,
|
|
323
|
-
isRecentlyGame: false,
|
|
324
|
-
isRecentlySearch: false,
|
|
325
|
-
query: context.keyword,
|
|
326
|
-
click: null,
|
|
327
|
-
clickDefault: null,
|
|
328
|
-
}
|
|
329
|
-
}),
|
|
330
|
-
},
|
|
331
|
-
guards: {
|
|
332
|
-
isRecentlyYouMayLike: (context, event) => {
|
|
333
|
-
const { tagId } = context
|
|
334
|
-
return tagId === 'Recently' || tagId === 'You may like'
|
|
335
|
-
},
|
|
336
|
-
hasTagList: (context, event) => {
|
|
337
|
-
const { tagList } = context
|
|
338
|
-
return tagList?.length > 0
|
|
339
|
-
},
|
|
340
|
-
},
|
|
341
|
-
services: {
|
|
342
|
-
fetchTags: async (context, event) => {
|
|
343
|
-
const { keyword, lang } = context
|
|
344
|
-
const { result } = await request.send(game.getGameTags({ q: keyword, lang }))
|
|
345
|
-
return result
|
|
346
|
-
},
|
|
347
|
-
fetchInitialData: async (context, event) => {
|
|
348
|
-
const data = await request.send(game.getGameSearchHome())
|
|
349
|
-
return data
|
|
350
|
-
},
|
|
351
|
-
fetchGames: async (context, event) => {
|
|
352
|
-
const { tagId, tagIndex, keyword, click, clickDefault } = context
|
|
353
|
-
const { traceId, result } = await request.send(
|
|
354
|
-
game.getGameSearchList({
|
|
355
|
-
id: tagId,
|
|
356
|
-
index: tagIndex,
|
|
357
|
-
q: keyword,
|
|
358
|
-
click,
|
|
359
|
-
clickDefault,
|
|
360
|
-
})
|
|
361
|
-
)
|
|
362
|
-
return { traceId, result }
|
|
363
|
-
},
|
|
364
|
-
sendTrace: async (context, event) => {
|
|
365
|
-
const {
|
|
366
|
-
traceId,
|
|
367
|
-
tagId,
|
|
368
|
-
tagIndex,
|
|
369
|
-
gameCode,
|
|
370
|
-
gameCodeIndex,
|
|
371
|
-
keyword: query,
|
|
372
|
-
click,
|
|
373
|
-
clickDefault,
|
|
374
|
-
isYouMayLike,
|
|
375
|
-
isRecentlyGame,
|
|
376
|
-
isRecentlySearch,
|
|
377
|
-
} = context
|
|
378
|
-
let id = tagId
|
|
379
|
-
if (tagId === 'Recently' || tagId === 'You may like') {
|
|
380
|
-
id = null
|
|
381
|
-
}
|
|
382
|
-
return await request.send(
|
|
383
|
-
game.setGameSearchTrace({
|
|
384
|
-
traceId,
|
|
385
|
-
tagId: id,
|
|
386
|
-
tagIndex,
|
|
387
|
-
gameCode,
|
|
388
|
-
gameCodeIndex,
|
|
389
|
-
query,
|
|
390
|
-
click,
|
|
391
|
-
clickDefault,
|
|
392
|
-
isYouMayLike,
|
|
393
|
-
isRecentlyGame,
|
|
394
|
-
isRecentlySearch,
|
|
395
|
-
})
|
|
396
|
-
)
|
|
397
|
-
},
|
|
398
|
-
},
|
|
399
|
-
}
|
|
400
|
-
)
|
|
401
|
-
}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { assign, createMachine } 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: 'honor_board',
|
|
9
|
-
type: 'parallel',
|
|
10
|
-
context: {
|
|
11
|
-
tick: 6000,
|
|
12
|
-
isPlaying: false,
|
|
13
|
-
},
|
|
14
|
-
states: {
|
|
15
|
-
feed: {
|
|
16
|
-
initial: 'updating',
|
|
17
|
-
states: {
|
|
18
|
-
updating: {
|
|
19
|
-
invoke: {
|
|
20
|
-
src: 'fetchHonorBoardList',
|
|
21
|
-
onDone: {
|
|
22
|
-
target: 'waiting',
|
|
23
|
-
actions: 'setBroadcastList',
|
|
24
|
-
},
|
|
25
|
-
onError: {
|
|
26
|
-
target: 'waiting',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
waiting: {
|
|
31
|
-
after: {
|
|
32
|
-
TIMEOUT: {
|
|
33
|
-
target: 'updating',
|
|
34
|
-
cond: 'isNotInGame',
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
broadcast: {
|
|
41
|
-
initial: 'idle',
|
|
42
|
-
states: {
|
|
43
|
-
idle: {
|
|
44
|
-
on: {
|
|
45
|
-
START_BROADCAST: {
|
|
46
|
-
target: 'picking',
|
|
47
|
-
actions: 'leaveGame',
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
picking: {
|
|
52
|
-
after: {
|
|
53
|
-
5000: {
|
|
54
|
-
target: 'display',
|
|
55
|
-
actions: 'setBroadcast',
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
display: {
|
|
60
|
-
after: {
|
|
61
|
-
5000: {
|
|
62
|
-
target: 'picking',
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
on: {
|
|
68
|
-
RESET_BROADCAST: {
|
|
69
|
-
target: '.idle',
|
|
70
|
-
actions: 'resetBroadcast',
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
delays: {
|
|
78
|
-
TIMEOUT: (context, event) => {
|
|
79
|
-
return context.tick * 10
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
actions: {
|
|
83
|
-
setBroadcastList: assign((context, event) => {
|
|
84
|
-
const broadcastList = (event.data || []).map((item) => item.data).flat()
|
|
85
|
-
const sortBroadcastList = broadcastList.sort((a, b) => {
|
|
86
|
-
if (!a.time) return -1
|
|
87
|
-
if (!b.time) return 1
|
|
88
|
-
return a.time - b.time
|
|
89
|
-
})
|
|
90
|
-
return { broadcastList: sortBroadcastList }
|
|
91
|
-
}),
|
|
92
|
-
setBroadcast: assign((context, event) => {
|
|
93
|
-
const { broadcastList = [], sentNormalBroadcastList = [], normalBroadcast = [] } = context
|
|
94
|
-
let sentNormalList = sentNormalBroadcastList
|
|
95
|
-
if (normalBroadcast) {
|
|
96
|
-
sentNormalList = [...sentNormalBroadcastList, normalBroadcast]
|
|
97
|
-
}
|
|
98
|
-
const nextNormalBroadcast = broadcastList?.find((broadcast) => {
|
|
99
|
-
return !sentNormalList.some((item) => item.broadcastId === broadcast.broadcastId)
|
|
100
|
-
})
|
|
101
|
-
return {
|
|
102
|
-
normalBroadcast: nextNormalBroadcast,
|
|
103
|
-
sentNormalBroadcastList: sentNormalList,
|
|
104
|
-
}
|
|
105
|
-
}),
|
|
106
|
-
resetBroadcast: assign((context, event) => {
|
|
107
|
-
return {
|
|
108
|
-
isPlaying: true,
|
|
109
|
-
normalBroadcast: null,
|
|
110
|
-
sentNormalBroadcastList: [],
|
|
111
|
-
}
|
|
112
|
-
}),
|
|
113
|
-
leaveGame: assign((context, event) => {
|
|
114
|
-
return {
|
|
115
|
-
isPlaying: false,
|
|
116
|
-
}
|
|
117
|
-
}),
|
|
118
|
-
},
|
|
119
|
-
guards: {
|
|
120
|
-
isNotInGame: (context, event) => {
|
|
121
|
-
return !context.isPlaying
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
services: {
|
|
125
|
-
fetchHonorBoardList: async (context, event) => {
|
|
126
|
-
const { data } = await request.send(activity.getHonorBroadcast({ isPwa: true, appSecret }))
|
|
127
|
-
return data
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
}
|
|
131
|
-
)
|
|
132
|
-
}
|
package/src/machine/merge.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import api from '../api/payment.js'
|
|
3
|
-
export default function (request) {
|
|
4
|
-
return createMachine(
|
|
5
|
-
{
|
|
6
|
-
id: 'merge',
|
|
7
|
-
initial: 'idle',
|
|
8
|
-
context: {
|
|
9
|
-
userInfo: null,
|
|
10
|
-
},
|
|
11
|
-
states: {
|
|
12
|
-
idle: {
|
|
13
|
-
always: [{ target: 'mergeable', cond: 'isMergeable' }],
|
|
14
|
-
},
|
|
15
|
-
mergeable: {
|
|
16
|
-
on: {
|
|
17
|
-
MERGE: {
|
|
18
|
-
target: 'merging',
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
merging: {
|
|
23
|
-
invoke: {
|
|
24
|
-
src: 'mergeWallet',
|
|
25
|
-
onDone: { target: 'idle' },
|
|
26
|
-
onError: { target: 'idle' },
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
on: {
|
|
31
|
-
SET_USER_INFO: {
|
|
32
|
-
actions: 'setUserInfo',
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
actions: {
|
|
38
|
-
setUserInfo: assign((context, event) => {
|
|
39
|
-
return {
|
|
40
|
-
userInfo: event.data,
|
|
41
|
-
}
|
|
42
|
-
}),
|
|
43
|
-
},
|
|
44
|
-
guards: {
|
|
45
|
-
isMergeable: (context, event) => {
|
|
46
|
-
const { retain, balance, withdraw_policy } = context.userInfo || {}
|
|
47
|
-
return retain > 0 && (parseFloat(balance) <= 5 || withdraw_policy === 'FREE')
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
services: {
|
|
51
|
-
mergeWallet: async (context, event) => {
|
|
52
|
-
return await request.send(api.mergeWallet())
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
}
|
|
56
|
-
)
|
|
57
|
-
}
|