@jetthai/cuora 1.1.341-dev-11 → 1.1.341-rank-1

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/CHANGELOG.md CHANGED
@@ -2,33 +2,7 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
- ### [1.1.341-dev-11](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-10...v1.1.341-dev-11) (2025-03-11)
6
-
7
- ### [1.1.341-dev-10](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-9...v1.1.341-dev-10) (2025-03-11)
8
-
9
- ### [1.1.341-rank-3](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-8...v1.1.341-rank-3) (2025-03-10)
10
-
11
- ### [1.1.341-rank-2](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-5...v1.1.341-rank-2) (2025-03-06)
12
-
13
- ### [1.1.341-rank-1](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-4...v1.1.341-rank-1) (2025-03-05)
14
-
15
- ### [1.1.341-dev-9](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-8...v1.1.341-dev-9) (2025-03-10)
16
-
17
- ### [1.1.341-dev-8](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-7...v1.1.341-dev-8) (2025-03-10)
18
-
19
- ### [1.1.341-dev-7](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-6...v1.1.341-dev-7) (2025-03-10)
20
-
21
- ### [1.1.341-dev-6](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-5...v1.1.341-dev-6) (2025-03-06)
22
-
23
- ### [1.1.341-dev-5](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-4...v1.1.341-dev-5) (2025-03-06)
24
-
25
- ### [1.1.341-dev-4](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-3...v1.1.341-dev-4) (2025-03-03)
26
-
27
- ### [1.1.341-dev-3](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-2...v1.1.341-dev-3) (2025-03-03)
28
-
29
- ### [1.1.341-dev-2](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-1...v1.1.341-dev-2) (2025-02-27)
30
-
31
- ### [1.1.341-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.341...v1.1.341-dev-1) (2025-02-27)
5
+ ### [1.1.341-rank-1](https://github.com/jetthai/cuora-module/compare/v1.1.341...v1.1.341-rank-1) (2025-03-05)
32
6
 
33
7
  ### [1.1.341](https://github.com/jetthai/cuora-module/compare/v1.1.340...v1.1.341) (2025-02-25)
34
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.341-dev-11",
3
+ "version": "1.1.341-rank-1",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
package/src/api/game.js CHANGED
@@ -1,4 +1,7 @@
1
1
  export default {
2
+ getGameSHA: () => ({ method: 'get', url: 'game/list/v2/sha' }),
3
+ getOptionMap: (code) => ({ method: 'get', url: 'game/list/v2/options', params: { code } }),
4
+ getGameStatus: () => ({ method: 'get', url: 'game/list/v2/status' }),
2
5
  getGameCategory: ({ id, first } = {}) => ({ method: 'get', url: 'game/list/v2/category', params: { id, first } }),
3
6
  addFavoriteGame: (code) => ({ method: 'post', url: 'game/myfavorite/add', params: { games: [code] } }),
4
7
  removeFavoriteGame: (code) => ({ method: 'post', url: 'game/myfavorite/remove', params: { games: [code] } }),
@@ -97,5 +100,4 @@ export default {
97
100
  }),
98
101
  getFreeGameList: () => ({ method: 'get', url: 'activities/getFreeGameRewardList' }),
99
102
  getFreeGameReward: ({ activityNo, receiveNo }) => ({ method: 'post', url: 'activities/getFreeGameReward', params: { activityNo, receiveNo } }),
100
- getV3GameInfo: ({ appSecret, gameCodes }) => ({ method: 'post', url: 'game/list/v3/gameInfo', params: { appSecret, gameCodes } }),
101
103
  }
@@ -18,9 +18,4 @@ export default {
18
18
  method: 'post',
19
19
  params: { activityNo, cycle, round },
20
20
  }),
21
- getRankingGames: ({ activityNo }) => ({
22
- url: 'hot-game/ranking',
23
- method: 'get',
24
- params: { activityNo },
25
- }),
26
21
  }
@@ -150,8 +150,12 @@ export default function (request) {
150
150
  }
151
151
  }),
152
152
  resetActivities: assign((context, event) => {
153
+ const { activityList = [], specifyActivities = [] } = context
154
+ const keepActivities = activityList.filter((activity) => specifyActivities.includes(activity.activityType))
153
155
  return {
154
156
  isPlaying: true,
157
+ activityList: keepActivities,
158
+ promotionList: [],
155
159
  }
156
160
  }),
157
161
  leaveGame: assign((context, event) => {
@@ -123,8 +123,12 @@ export default function (request) {
123
123
  }
124
124
  }),
125
125
  resetActivities: assign((context, event) => {
126
+ const { activityList = [], detailNeededActivityTypes = [] } = context
127
+ const keepActivities = activityList.filter((activity) => detailNeededActivityTypes.includes(activity.activityType))
126
128
  return {
127
129
  isPlaying: true,
130
+ activityList: keepActivities,
131
+ promotionList: [],
128
132
  }
129
133
  }),
130
134
  leaveGame: assign((context, event) => {
@@ -430,7 +430,7 @@ export default function (request) {
430
430
  }),
431
431
  redirectTo3Party: async (context, event) => {
432
432
  const { provider, channel, subchannel, fc } = event.data
433
- const deviceTokenEnable = context.siteConfig?.dtVerify
433
+ const deviceTokenEnable = context.siteConfig?.dtVerify === '1'
434
434
 
435
435
  const dt = await getDeviceToken({
436
436
  fpToken,
@@ -513,7 +513,7 @@ export default function (request) {
513
513
  return await request.send(user.getUserInfo())
514
514
  },
515
515
  checkDeviceToken: async (context, event) => {
516
- const deviceTokenEnable = context.siteConfig?.dtVerify
516
+ const deviceTokenEnable = context.siteConfig?.dtVerify === '1'
517
517
  if (deviceTokenEnable) {
518
518
  const { exist } = await request.send(user.checkDt())
519
519
  if (!exist) {
@@ -17,7 +17,7 @@ export default function (request) {
17
17
  lineat: null,
18
18
  },
19
19
  loginMethods: {},
20
- forceValidation: false,
20
+ forceValidation: '0',
21
21
  urls: {
22
22
  widget: null,
23
23
  },
@@ -55,8 +55,8 @@ export default function (request) {
55
55
  target: 'fetching',
56
56
  cond: (context, event) => {
57
57
  const { siteConfig = {}, promotion = {}, selectedCrypto } = context
58
- const { walletMode = '', bonusPreviewEnable } = siteConfig
59
- return !!selectedCrypto && walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
58
+ const { walletMode = '', bonusPreviewEnable = '0' } = siteConfig
59
+ return !!selectedCrypto && walletMode === '4' && bonusPreviewEnable === '1' && promotion.activityNo != 'none'
60
60
  },
61
61
  },
62
62
  { target: 'loaded' },
@@ -72,8 +72,8 @@ export default function (request) {
72
72
  target: 'fetching',
73
73
  cond: (context, event) => {
74
74
  const { siteConfig = {}, promotion = {} } = context
75
- const { walletMode = '', bonusPreviewEnable } = siteConfig
76
- return walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
75
+ const { walletMode = '', bonusPreviewEnable = '0' } = siteConfig
76
+ return walletMode === '4' && bonusPreviewEnable === '1' && promotion.activityNo != 'none'
77
77
  },
78
78
  },
79
79
  { target: 'loaded' },
@@ -49,8 +49,8 @@ export default function (request) {
49
49
  target: 'fetching',
50
50
  cond: (context, event) => {
51
51
  const { siteConfig = {}, promotion = {}, selectedCard } = context
52
- const { walletMode = '', bonusPreviewEnable } = siteConfig
53
- return !!selectedCard && walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
52
+ const { walletMode = '', bonusPreviewEnable = '0' } = siteConfig
53
+ return !!selectedCard && walletMode === '4' && bonusPreviewEnable === '1' && promotion.activityNo != 'none'
54
54
  },
55
55
  },
56
56
  { target: 'loaded' },
@@ -78,8 +78,8 @@ export default function (request) {
78
78
  actions: 'setCard',
79
79
  cond: (context, event) => {
80
80
  const { siteConfig = {}, promotion = {} } = context
81
- const { walletMode = '', bonusPreviewEnable } = siteConfig
82
- return walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
81
+ const { walletMode = '', bonusPreviewEnable = '0' } = siteConfig
82
+ return walletMode === '4' && bonusPreviewEnable === '1' && promotion.activityNo != 'none'
83
83
  },
84
84
  },
85
85
  {
@@ -216,8 +216,8 @@ export default function (request) {
216
216
  actions: 'setCard',
217
217
  cond: (context, event) => {
218
218
  const { siteConfig = {}, promotion = {} } = context
219
- const { walletMode = '', bonusPreviewEnable } = siteConfig
220
- return walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
219
+ const { walletMode = '', bonusPreviewEnable = '0' } = siteConfig
220
+ return walletMode === '4' && bonusPreviewEnable === '1' && promotion.activityNo != 'none'
221
221
  },
222
222
  },
223
223
  {
@@ -49,8 +49,8 @@ export default function (request) {
49
49
  target: 'fetching',
50
50
  cond: (context, event) => {
51
51
  const { siteConfig = {}, promotion = {}, selectedQrcode } = context
52
- const { walletMode = '', bonusPreviewEnable } = siteConfig
53
- return !!selectedQrcode && walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
52
+ const { walletMode = '', bonusPreviewEnable = '0' } = siteConfig
53
+ return !!selectedQrcode && walletMode === '4' && bonusPreviewEnable === '1' && promotion.activityNo != 'none'
54
54
  },
55
55
  },
56
56
  {
@@ -86,8 +86,8 @@ export default function (request) {
86
86
  actions: 'setQrcode',
87
87
  cond: (context, event) => {
88
88
  const { siteConfig = {}, promotion = {} } = context
89
- const { walletMode = '', bonusPreviewEnable } = siteConfig
90
- return walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
89
+ const { walletMode = '', bonusPreviewEnable = '0' } = siteConfig
90
+ return walletMode === '4' && bonusPreviewEnable === '1' && promotion.activityNo != 'none'
91
91
  },
92
92
  },
93
93
  {
@@ -314,8 +314,8 @@ export default function (request) {
314
314
  actions: 'setQrcode',
315
315
  cond: (context, event) => {
316
316
  const { siteConfig = {}, promotion = {} } = context
317
- const { walletMode = '', bonusPreviewEnable } = siteConfig
318
- return walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
317
+ const { walletMode = '', bonusPreviewEnable = '0' } = siteConfig
318
+ return walletMode === '4' && bonusPreviewEnable === '1' && promotion.activityNo != 'none'
319
319
  },
320
320
  },
321
321
  {
@@ -74,8 +74,8 @@ export default function (request) {
74
74
  target: 'fetching',
75
75
  cond: (context, event) => {
76
76
  const { siteConfig = {}, promotion = {} } = context
77
- const { walletMode = '', bonusPreviewEnable } = siteConfig
78
- return walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
77
+ const { walletMode = '', bonusPreviewEnable = '0' } = siteConfig
78
+ return walletMode === '4' && bonusPreviewEnable === '1' && promotion.activityNo != 'none'
79
79
  },
80
80
  },
81
81
  { target: 'loaded' },
@@ -2,22 +2,16 @@ import { createMachine, assign } from 'xstate'
2
2
  import ranking from '../api/ranking.js'
3
3
 
4
4
  export default function (request) {
5
- const cycleMapping = ['DAILY', 'WEEKLY', 'MONTHLY']
5
+ const rateMapping = ['DAILY', 'WEEKLY', 'MONTHLY']
6
6
 
7
7
  function roundProcess(rounds) {
8
8
  const roundArrays = rounds.map((round) => Array.from({ length: round }, (_, i) => i + 1))
9
9
  return roundArrays.reduce((acc, roundArray, index) => {
10
- acc[cycleMapping[index]] = roundArray.reverse()
10
+ acc[rateMapping[index]] = roundArray.reverse()
11
11
  return acc
12
12
  }, {})
13
13
  }
14
14
 
15
- function transGameData(item) {
16
- if (!item) return {}
17
- item.providerId = item.provider
18
- return item
19
- }
20
-
21
15
  return createMachine(
22
16
  {
23
17
  id: 'dragon_tiger_ranking',
@@ -29,13 +23,12 @@ export default function (request) {
29
23
  currentRound: [],
30
24
  cycle: '',
31
25
  round: 0,
32
- rule: '',
33
26
  // api detail 資料
27
+ rule: '',
34
28
  description: '',
35
29
  descriptionUrl: [],
36
30
  // api detail 排名資料
37
31
  playerRanking: {},
38
- gameRanking: [],
39
32
  topRanking: [],
40
33
  // 前端這邊用的選單資料 { cycle, round }
41
34
  options: {},
@@ -90,20 +83,8 @@ export default function (request) {
90
83
  invoke: {
91
84
  src: 'fetchRankingDetail',
92
85
  onDone: {
93
- target: 'getRankingGames',
94
- actions: 'setRanking',
95
- },
96
- onError: {
97
86
  target: 'idle',
98
- },
99
- },
100
- },
101
- getRankingGames: {
102
- invoke: {
103
- src: 'fetchRankingGames',
104
- onDone: {
105
- target: 'idle',
106
- actions: 'setRankingGames',
87
+ actions: 'setRanking',
107
88
  },
108
89
  onError: {
109
90
  target: 'idle',
@@ -121,32 +102,23 @@ export default function (request) {
121
102
  }
122
103
  }),
123
104
  setRanking: assign((context, event) => {
124
- const topRanking = event.data?.topRanking?.map((rank) => transGameData(rank))
125
105
  return {
106
+ rule: event.data?.rule,
126
107
  description: event.data?.description,
127
108
  descriptionUrl: event.data?.descriptionUrl,
128
- topRanking: topRanking || [],
129
- playerRanking: transGameData(event.data?.playerRanking) || {},
130
- }
131
- }),
132
- setRankingGames: assign((context, event) => {
133
- const gameRanking = event.data?.map((rank) => transGameData(rank))
134
- return {
135
- gameRanking: gameRanking || [],
109
+ topRanking: event.data?.topRanking || [],
110
+ playerRanking: event.data?.playerRanking || {},
136
111
  }
137
112
  }),
138
113
  setRankingOptions: assign((context, event) => {
139
114
  const cycle = event.data?.cycle
140
115
  const currentRound = event.data?.currentRound || []
141
116
  // 取得結算週期選單列表
142
- const cycleOptions = cycleMapping.slice(0, currentRound.length)
117
+ const cycleOptions = rateMapping.slice(0, currentRound.length)
118
+ // 如果是月結算,則加入全部選項
119
+ if (cycle === 'MONTHLY') cycleOptions.push('ALL')
143
120
  // 取得每週期的歷史期數選單列表
144
121
  const roundOptions = roundProcess(currentRound)
145
- // 如果是月結算,則加入全部選項
146
- if (cycle === 'MONTHLY') {
147
- cycleOptions.push('ALL')
148
- roundOptions.ALL = roundOptions.MONTHLY
149
- }
150
122
  return {
151
123
  options: { cycle: cycleOptions, round: roundOptions },
152
124
  round: currentRound[currentRound.length - 1],
@@ -158,8 +130,7 @@ export default function (request) {
158
130
  // 處理變更 cycle,如果沒有輸入或沒有變更就不更新
159
131
  if (event.data?.cycle && cycle !== event.data?.cycle) {
160
132
  const { currentRound } = context
161
- const cycleForRound = event.data?.cycle === 'ALL' ? 'MONTHLY' : event.data?.cycle
162
- const cycleIndex = cycleMapping.indexOf(cycleForRound)
133
+ const cycleIndex = rateMapping.indexOf(event.data?.cycle)
163
134
  return { cycle: event.data?.cycle, round: currentRound[cycleIndex] }
164
135
  }
165
136
  if (event.data?.round && round !== event.data?.round) {
@@ -187,11 +158,6 @@ export default function (request) {
187
158
  const { data } = await request.send(ranking.getRankingDetail({ activityNo, cycle, round }))
188
159
  return data
189
160
  },
190
- fetchRankingGames: async (context) => {
191
- const { activityNo } = context
192
- const { data } = await request.send(ranking.getRankingGames({ activityNo }))
193
- return data
194
- },
195
161
  },
196
162
  }
197
163
  )
@@ -1,9 +1,6 @@
1
1
  import { assign, createMachine } from 'xstate'
2
- import api from '../api/game.js'
3
-
4
- export default function (request) {
5
- const { appSecret } = request.config
6
2
 
3
+ export default function () {
7
4
  return createMachine(
8
5
  {
9
6
  id: 'error',
@@ -11,7 +8,6 @@ export default function (request) {
11
8
  context: {
12
9
  error: null,
13
10
  gameCode: null,
14
- game: null,
15
11
  },
16
12
  states: {
17
13
  normal: {
@@ -32,23 +28,15 @@ export default function (request) {
32
28
  { target: 'unfinishedGame', cond: 'isUnfinishedGame', actions: 'setUnfinishedGame' },
33
29
  { target: 'freeGameSettle', cond: 'isFreeGameSettle' },
34
30
  { target: 'freeGameGiveUp', cond: 'isFreeGameGiveUp' },
31
+ // { target: 'hall' },
35
32
  ],
36
33
  },
37
34
  logout: {},
38
35
  deposit: {},
39
- unfinishedGame: {
40
- invoke: {
41
- src: 'getGameInfo',
42
- onDone: {
43
- actions: 'setGame',
44
- },
45
- onError: {
46
- target: 'unfinishedGame',
47
- },
48
- },
49
- },
36
+ unfinishedGame: {},
50
37
  freeGameSettle: {},
51
38
  freeGameGiveUp: {},
39
+ // hall: {},
52
40
  },
53
41
  },
54
42
  },
@@ -70,12 +58,6 @@ export default function (request) {
70
58
  gameCode: context.error.extend.split(/_(.+)/)[1],
71
59
  }
72
60
  }),
73
- setGame: assign((context, event) => {
74
- const { data = [] } = event.data
75
- return {
76
- game: data?.[0],
77
- }
78
- }),
79
61
  },
80
62
  guards: {
81
63
  isLogout: (context, event) => {
@@ -94,12 +76,7 @@ export default function (request) {
94
76
  return context.error.code === 'ERR_G125'
95
77
  },
96
78
  },
97
- services: {
98
- getGameInfo: async (context, event) => {
99
- const { gameCode } = context
100
- return await request.send(api.getV3GameInfo({ appSecret, gameCodes: [gameCode] }))
101
- },
102
- },
79
+ services: {},
103
80
  }
104
81
  )
105
82
  }
@@ -40,15 +40,14 @@ export default function (request) {
40
40
  gameCode: null,
41
41
  name: null,
42
42
  },
43
- walletMode: null,
44
43
  lang: 'en_US',
45
44
  isMobile: new UAParser().getResult().device.type,
46
45
  gameURL: null,
47
46
  gameToken: null,
48
47
  gameHtml: null,
49
- gameWalletType: null,
50
48
  switchGame: null,
51
49
  isPlaying: false,
50
+ ...oldContext,
52
51
  },
53
52
  states: {
54
53
  flow: {
@@ -81,7 +80,7 @@ export default function (request) {
81
80
  },
82
81
  ENTER_GAME: {
83
82
  target: 'connecting',
84
- actions: ['setGameInfo', 'setLang', 'setWalletMode'],
83
+ actions: ['setGameInfo', 'setLang'],
85
84
  },
86
85
  MENU_ENTER_GAME: {
87
86
  target: 'connecting',
@@ -206,6 +205,7 @@ export default function (request) {
206
205
  actions: ['setIsPlaying', 'resetContent', 'resetSHA'],
207
206
  },
208
207
  LEAVE_GAME_REFRESH: {
208
+ target: '#game.oldTimer',
209
209
  actions: 'setIsPlaying',
210
210
  },
211
211
  },
@@ -280,6 +280,63 @@ export default function (request) {
280
280
  },
281
281
  },
282
282
  },
283
+ oldTimer: {
284
+ initial: 'fetchingGameSHA',
285
+ states: {
286
+ fetchingGameSHA: {
287
+ invoke: {
288
+ src: 'fetchGameSHA',
289
+ onDone: {
290
+ target: 'checking',
291
+ actions: 'setGameSHA',
292
+ },
293
+ onError: {
294
+ target: 'pending',
295
+ },
296
+ },
297
+ },
298
+ checking: {
299
+ always: [{ target: 'updatingStatus', cond: 'isStatusChanged' }, { target: 'pending' }],
300
+ },
301
+ updatingStatus: {
302
+ invoke: {
303
+ src: 'fetchStatus',
304
+ onDone: {
305
+ target: 'updatingOption',
306
+ actions: ['setStatus'],
307
+ },
308
+ onError: {
309
+ target: 'pending',
310
+ },
311
+ },
312
+ },
313
+ updatingOption: {
314
+ invoke: {
315
+ src: 'fetchOption',
316
+ onDone: {
317
+ target: 'pending',
318
+ actions: 'mergeOption',
319
+ },
320
+ onError: {
321
+ target: 'pending',
322
+ },
323
+ },
324
+ },
325
+ pending: {
326
+ after: {
327
+ 20000: [
328
+ {
329
+ target: 'fetchingGameSHA',
330
+ cond: 'isNotInGame',
331
+ },
332
+ {
333
+ target: 'pending',
334
+ },
335
+ ],
336
+ },
337
+ },
338
+ },
339
+ },
283
340
  },
284
341
  },
285
342
  {
@@ -392,9 +449,9 @@ export default function (request) {
392
449
  gameURL: (context, event) => {
393
450
  return event.data.gameURL
394
451
  },
395
- gameWalletType: (context, event) => {
396
- return event.data.gameWalletType
397
- },
452
+ }),
453
+ clearGameInfo: assign((context, event) => {
454
+ return { game: { providerId: null, gameId: null, gameTypeId: null, mappingId: null } }
398
455
  }),
399
456
  setGameInfo: assign((context, event) => {
400
457
  const { providerId, gameId, gameTypeId, mappingId, portrait, gameCode, name } = event.data.game
@@ -407,9 +464,6 @@ export default function (request) {
407
464
  const { providerId, gameId, gameTypeId, mappingId, portrait, gameCode, name } = context.switchGame
408
465
  return { game: { providerId, gameId, gameTypeId, mappingId, portrait: portrait ? 1 : 0, gameCode, name } }
409
466
  }),
410
- setWalletMode: assign((context, event) => {
411
- return { walletMode: event.data.walletMode }
412
- }),
413
467
  setLang: assign((context, event) => {
414
468
  const lang = event.data.locale.replace('-', '_')
415
469
  return { lang }
@@ -429,6 +483,7 @@ export default function (request) {
429
483
  isPlaying: event.data,
430
484
  }
431
485
  }),
486
+ ...oldActions,
432
487
  },
433
488
  guards: {
434
489
  isDifferentRoom: (context, event) => context.room?.categoryId !== event.data?.categoryId,
@@ -437,9 +492,13 @@ export default function (request) {
437
492
  // 是否有下一頁
438
493
  return loadable && !isLastPage
439
494
  },
495
+ isNotInGame: (context, event) => {
496
+ return !context.isPlaying
497
+ },
440
498
  hasRoomAndIsNotInGame: (context, event) => {
441
499
  return context.room?.categoryId && !context.isPlaying
442
500
  },
501
+ ...oldGuards,
443
502
  },
444
503
  services: {
445
504
  batchFetch: async (context, event) => {
@@ -546,7 +605,7 @@ export default function (request) {
546
605
  },
547
606
  connectGame: async (context, event) => {
548
607
  const returnProviders = ['RSG', 'KP', 'EPICWIN', 'AMBSLOT', 'SEXY_VENUS', 'SEXY_SEXYBCRT', 'PG', 'NPG']
549
- const { lang, isMobile, walletMode } = context
608
+ const { lang, isMobile } = context
550
609
  const { providerId, gameId, gameTypeId, mappingId } = context.game
551
610
  const params = {
552
611
  provider_id: providerId,
@@ -556,18 +615,85 @@ export default function (request) {
556
615
  is_demo: false,
557
616
  is_mobile: isMobile === 'mobile' ? 'y' : null,
558
617
  lang,
559
- selected_wallet_type: walletMode,
560
618
  return_url: returnProviders.includes(providerId) ? `${window.location.origin}${context.base}return` : window.location.href, // For providers to return.
561
619
  }
562
- const { type, redirect_url, gameToken, gameHtml, wallet_type } = await request.send(api.playGame(params))
563
- return { type, gameToken, gameHtml, gameURL: redirect_url, gameWalletType: wallet_type }
620
+ const { type, redirect_url, gameToken, gameHtml } = await request.send(api.playGame(params))
621
+ return { type, gameToken, gameHtml, gameURL: redirect_url }
564
622
  },
565
623
  disconnectGame: async (context, event) => {
566
624
  const uid_site = event.data
567
625
  const provider_id = context.game.providerId
568
626
  return await request.send(api.logoutGame({ uid_site, provider_id }))
569
627
  },
628
+ ...oldServices(request),
570
629
  },
571
630
  }
572
631
  )
573
632
  }
633
+
634
+ const oldContext = {
635
+ sha: {
636
+ status: null,
637
+ },
638
+ isStatusChanged: false,
639
+ statusMap: {},
640
+ optionMap: {},
641
+ }
642
+
643
+ const oldActions = {
644
+ setGameSHA: assign((context, event) => {
645
+ const { sha } = context
646
+ const newSha = event.data
647
+ return {
648
+ sha: newSha,
649
+ isStatusChanged: !sha.status || sha.status !== newSha.status,
650
+ }
651
+ }),
652
+ setStatus: assign((context, event) => {
653
+ return {
654
+ statusMap: event.data,
655
+ }
656
+ }),
657
+ mergeOption: assign((context, event) => {
658
+ const { optionMap } = context
659
+ return {
660
+ optionMap: { ...optionMap, ...event.data },
661
+ }
662
+ }),
663
+ resetSHA: assign((context, event) => {
664
+ return {
665
+ sha: {
666
+ status: null,
667
+ },
668
+ isStatusChanged: false,
669
+ statusMap: {},
670
+ optionMap: {},
671
+ }
672
+ }),
673
+ }
674
+
675
+ const oldGuards = {
676
+ isStatusChanged: (context, event) => context.isStatusChanged,
677
+ }
678
+
679
+ const oldServices = (request) => ({
680
+ fetchOption: async (context, event) => {
681
+ if (request.getToken()) {
682
+ return await request.send(api.getOptionMap())
683
+ }
684
+ },
685
+ fetchGameSHA: async (context, event) => {
686
+ if (request.getToken()) {
687
+ return await request.send(api.getGameSHA())
688
+ } else {
689
+ return {
690
+ status: null,
691
+ }
692
+ }
693
+ },
694
+ fetchStatus: async (context, event) => {
695
+ if (request.getToken()) {
696
+ return await request.send(api.getGameStatus())
697
+ }
698
+ },
699
+ })
@@ -1,6 +1,5 @@
1
1
  import { assign, createMachine } from 'xstate'
2
2
  import common from '../api/common.js'
3
- import game from '../api/game.js'
4
3
 
5
4
  export default function (request) {
6
5
  const { appSecret } = request.config
@@ -9,35 +8,15 @@ export default function (request) {
9
8
  id: 'navbar',
10
9
  initial: 'fetching',
11
10
  context: {
12
- navbar: [],
13
- gameCodes: [],
11
+ navbar: null,
14
12
  },
15
13
  states: {
16
14
  fetching: {
17
15
  invoke: {
18
16
  src: 'fetchNavbar',
19
- onDone: [
20
- {
21
- target: 'checking',
22
- actions: ['setNavbar', 'filterGameCodes'],
23
- cond: 'haveGames',
24
- },
25
- { target: 'idle' },
26
- ],
27
- onError: {
28
- target: 'idle',
29
- },
30
- },
31
- },
32
- checking: {
33
- always: [{ target: 'combinning', cond: (context, event) => context.gameCodes?.length > 0 }, { target: 'idle' }],
34
- },
35
- combinning: {
36
- invoke: {
37
- src: 'getGameInfo',
38
17
  onDone: {
39
18
  target: 'idle',
40
- actions: 'combindGames',
19
+ actions: 'setNavbar',
41
20
  },
42
21
  onError: {
43
22
  target: 'idle',
@@ -55,47 +34,6 @@ export default function (request) {
55
34
  navbar: navbarConfig.settings,
56
35
  }
57
36
  }),
58
- filterGameCodes: assign((context, event) => {
59
- const { navbar = [] } = context
60
- const gameCodes = navbar.reduce((acc, item) => {
61
- if (item.type.toLowerCase() === 'game' && item.gameCode) {
62
- acc.push(item.gameCode)
63
- }
64
- return acc
65
- }, [])
66
-
67
- return { gameCodes }
68
- }),
69
- combindGames: assign((context, event) => {
70
- const gameInfo = event.data?.data || []
71
- const { navbar = [] } = context
72
- const combindNavBar = navbar.map((item) => {
73
- if (item.type.toLowerCase() === 'game') {
74
- const currentGame = gameInfo.find((game) => game.gameCode === item.gameCode)
75
- return {
76
- ...item,
77
- ...currentGame,
78
- }
79
- } else {
80
- return item
81
- }
82
- })
83
-
84
- return {
85
- navbar: combindNavBar,
86
- }
87
- }),
88
- },
89
- guards: {
90
- haveGames: (context, event) => {
91
- const { navbarConfig = {} } = event.data
92
- const { settings = [] } = navbarConfig
93
- if (settings?.length) {
94
- return settings.some((item) => item.type.toLowerCase() === 'game')
95
- } else {
96
- return false
97
- }
98
- },
99
37
  },
100
38
  services: {
101
39
  fetchNavbar: async (context, event) => {
@@ -113,10 +51,6 @@ export default function (request) {
113
51
  )
114
52
  return { navbarConfig: JSON.parse(decodeResult) }
115
53
  },
116
- getGameInfo: async (context, event) => {
117
- const { gameCodes } = context
118
- return await request.send(game.getV3GameInfo({ appSecret, gameCodes }))
119
- },
120
54
  },
121
55
  }
122
56
  )
@@ -273,18 +273,6 @@ export default function (request) {
273
273
  callback({ type: 'ACTIVITY_INFO', data })
274
274
  })
275
275
 
276
- // 監聽 activity-reward-info 事件
277
- clientSocket.on('activity-reward-info', (data) => {
278
- console.log('[socket][activity-reward-info]:', data)
279
- callback({ type: 'ACTIVITY_INFO', data })
280
- })
281
-
282
- // 監聽 message-notice-info 事件
283
- clientSocket.on('message-notice-info', (data) => {
284
- console.log('[socket][message-notice-info]:', data)
285
- callback({ type: 'ACTIVITY_INFO', data })
286
- })
287
-
288
276
  // 監聽 payment-info 事件
289
277
  clientSocket.on('payment-info', (data) => {
290
278
  console.log('[socket][payment-info]:', data, data.windowType)