@jetthai/cuora 1.1.343-depositEvent-1 → 1.1.343-dev-2
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 +87 -3
- package/package.json +1 -1
- package/src/api/game.js +1 -3
- package/src/api/index.js +2 -1
- package/src/api/ranking.js +26 -0
- package/src/machine/activity/activity.js +0 -4
- package/src/machine/activity/activity_cash.js +0 -4
- package/src/machine/deposit/index.js +0 -6
- package/src/machine/dragon_tiger_ranking.js +200 -0
- package/src/machine/error.js +28 -5
- package/src/machine/game_v2_1.js +0 -135
- package/src/machine/index.js +2 -0
- package/src/machine/navbar.js +68 -2
- package/src/machine/websocket.js +26 -18
- package/src/machine/deposit/crypto.js +0 -288
- package/src/machine/deposit/crypto_button.js +0 -432
- package/src/machine/deposit/crypto_cash.js +0 -255
package/CHANGELOG.md
CHANGED
|
@@ -2,11 +2,95 @@
|
|
|
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.343-
|
|
5
|
+
### [1.1.343-dev-2](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-5...v1.1.343-dev-2) (2025-03-13)
|
|
6
6
|
|
|
7
|
-
### [1.1.343](https://github.com/jetthai/cuora-module/compare/v1.1.
|
|
7
|
+
### [1.1.343-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-12...v1.1.343-dev-1) (2025-03-13)
|
|
8
8
|
|
|
9
|
-
### [1.1.
|
|
9
|
+
### [1.1.341-dev-12](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-4...v1.1.341-dev-12) (2025-03-12)
|
|
10
|
+
|
|
11
|
+
### [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)
|
|
12
|
+
|
|
13
|
+
### [1.1.341-dev-10](https://github.com/jetthai/cuora-module/compare/v1.1.343...v1.1.341-dev-10) (2025-03-11)
|
|
14
|
+
|
|
15
|
+
### [1.1.343](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-9...v1.1.343) (2025-03-11)
|
|
16
|
+
|
|
17
|
+
### [1.1.341-dev-9](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-3...v1.1.341-dev-9) (2025-03-10)
|
|
18
|
+
|
|
19
|
+
### [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)
|
|
20
|
+
|
|
21
|
+
### [1.1.341-dev-7](https://github.com/jetthai/cuora-module/compare/v1.1.342...v1.1.341-dev-7) (2025-03-10)
|
|
22
|
+
|
|
23
|
+
### [1.1.342](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-6...v1.1.342) (2025-03-10)
|
|
24
|
+
|
|
25
|
+
### [1.1.341-dev-6](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-2...v1.1.341-dev-6) (2025-03-06)
|
|
26
|
+
|
|
27
|
+
### [1.1.341-dev-5](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-1...v1.1.341-dev-5) (2025-03-06)
|
|
28
|
+
|
|
29
|
+
### [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)
|
|
30
|
+
|
|
31
|
+
### [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)
|
|
32
|
+
|
|
33
|
+
### [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)
|
|
34
|
+
|
|
35
|
+
### [1.1.341-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.341...v1.1.341-dev-1) (2025-02-27)
|
|
36
|
+
|
|
37
|
+
### [1.1.343-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-12...v1.1.343-dev-1) (2025-03-13)
|
|
38
|
+
|
|
39
|
+
### [1.1.343](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-9...v1.1.343) (2025-03-11)
|
|
40
|
+
|
|
41
|
+
### [1.1.342](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-6...v1.1.342) (2025-03-10)
|
|
42
|
+
|
|
43
|
+
### [1.1.341-dev-12](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-4...v1.1.341-dev-12) (2025-03-12)
|
|
44
|
+
|
|
45
|
+
### [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)
|
|
46
|
+
|
|
47
|
+
### [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)
|
|
48
|
+
|
|
49
|
+
### [1.1.341-dev-9](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-3...v1.1.341-dev-9) (2025-03-10)
|
|
50
|
+
|
|
51
|
+
### [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)
|
|
52
|
+
|
|
53
|
+
### [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)
|
|
54
|
+
|
|
55
|
+
### [1.1.341-dev-6](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-2...v1.1.341-dev-6) (2025-03-06)
|
|
56
|
+
|
|
57
|
+
### [1.1.341-dev-5](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-1...v1.1.341-dev-5) (2025-03-06)
|
|
58
|
+
|
|
59
|
+
### [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)
|
|
60
|
+
|
|
61
|
+
### [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)
|
|
62
|
+
|
|
63
|
+
### [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)
|
|
64
|
+
|
|
65
|
+
### [1.1.341-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.341...v1.1.341-dev-1) (2025-02-27)
|
|
66
|
+
|
|
67
|
+
### [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)
|
|
68
|
+
|
|
69
|
+
### [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)
|
|
70
|
+
|
|
71
|
+
### [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)
|
|
72
|
+
|
|
73
|
+
### [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)
|
|
74
|
+
|
|
75
|
+
### [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)
|
|
76
|
+
|
|
77
|
+
### [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)
|
|
78
|
+
|
|
79
|
+
### [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)
|
|
80
|
+
|
|
81
|
+
### [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)
|
|
82
|
+
|
|
83
|
+
### [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)
|
|
84
|
+
|
|
85
|
+
### [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)
|
|
86
|
+
|
|
87
|
+
### [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)
|
|
88
|
+
|
|
89
|
+
### [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)
|
|
90
|
+
|
|
91
|
+
### [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)
|
|
92
|
+
|
|
93
|
+
### [1.1.341-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.341...v1.1.341-dev-1) (2025-02-27)
|
|
10
94
|
|
|
11
95
|
### [1.1.341](https://github.com/jetthai/cuora-module/compare/v1.1.340...v1.1.341) (2025-02-25)
|
|
12
96
|
|
package/package.json
CHANGED
package/src/api/game.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
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' }),
|
|
5
2
|
getGameCategory: ({ id, first } = {}) => ({ method: 'get', url: 'game/list/v2/category', params: { id, first } }),
|
|
6
3
|
addFavoriteGame: (code) => ({ method: 'post', url: 'game/myfavorite/add', params: { games: [code] } }),
|
|
7
4
|
removeFavoriteGame: (code) => ({ method: 'post', url: 'game/myfavorite/remove', params: { games: [code] } }),
|
|
@@ -100,4 +97,5 @@ export default {
|
|
|
100
97
|
}),
|
|
101
98
|
getFreeGameList: () => ({ method: 'get', url: 'activities/getFreeGameRewardList' }),
|
|
102
99
|
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 } }),
|
|
103
101
|
}
|
package/src/api/index.js
CHANGED
|
@@ -6,5 +6,6 @@ import mailbox from './mailbox.js'
|
|
|
6
6
|
import payment from './payment.js'
|
|
7
7
|
import user from './user.js'
|
|
8
8
|
import form from './form.js'
|
|
9
|
+
import ranking from './ranking.js'
|
|
9
10
|
|
|
10
|
-
export default { activity, auth, common, game, mailbox, payment, user, form }
|
|
11
|
+
export default { activity, auth, common, game, mailbox, payment, user, form, ranking }
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
// 未登入排名資料
|
|
3
|
+
getTournament: ({ activityNo }) => ({
|
|
4
|
+
url: 'tournament/detail',
|
|
5
|
+
method: 'get',
|
|
6
|
+
params: { activityNo },
|
|
7
|
+
isPublic: true,
|
|
8
|
+
}),
|
|
9
|
+
// 登入後排名預設期數資料
|
|
10
|
+
getRankingOptions: ({ activityNo }) => ({
|
|
11
|
+
url: 'ranking/detail/option',
|
|
12
|
+
method: 'get',
|
|
13
|
+
params: { activityNo },
|
|
14
|
+
}),
|
|
15
|
+
// 登入後排名資料
|
|
16
|
+
getRankingDetail: ({ activityNo, cycle, round }) => ({
|
|
17
|
+
url: 'ranking/detail',
|
|
18
|
+
method: 'post',
|
|
19
|
+
params: { activityNo, cycle, round },
|
|
20
|
+
}),
|
|
21
|
+
getRankingGames: ({ activityNo }) => ({
|
|
22
|
+
url: 'hot-game/ranking',
|
|
23
|
+
method: 'get',
|
|
24
|
+
params: { activityNo },
|
|
25
|
+
}),
|
|
26
|
+
}
|
|
@@ -150,12 +150,8 @@ 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))
|
|
155
153
|
return {
|
|
156
154
|
isPlaying: true,
|
|
157
|
-
activityList: keepActivities,
|
|
158
|
-
promotionList: [],
|
|
159
155
|
}
|
|
160
156
|
}),
|
|
161
157
|
leaveGame: assign((context, event) => {
|
|
@@ -123,12 +123,8 @@ 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))
|
|
128
126
|
return {
|
|
129
127
|
isPlaying: true,
|
|
130
|
-
activityList: keepActivities,
|
|
131
|
-
promotionList: [],
|
|
132
128
|
}
|
|
133
129
|
}),
|
|
134
130
|
leaveGame: assign((context, event) => {
|
|
@@ -2,8 +2,6 @@ import manual_vn from './manual_vn.js'
|
|
|
2
2
|
import loadcard_vn from './loadcard_vn.js'
|
|
3
3
|
import qrcode_v2 from './qrcode_v2.js'
|
|
4
4
|
import deposit_fc from './deposit_fc.js'
|
|
5
|
-
import crypto from './crypto.js'
|
|
6
|
-
import crypto_button from './crypto_button.js'
|
|
7
5
|
import direct from './direct.js'
|
|
8
6
|
import amb from './amb.js'
|
|
9
7
|
import float from './float.js'
|
|
@@ -13,7 +11,6 @@ import usdt from './usdt.js'
|
|
|
13
11
|
import manual_cash from './manual_cash.js'
|
|
14
12
|
import qrcode_cash from './qrcode_cash.js'
|
|
15
13
|
import usdt_cash from './usdt_cash.js'
|
|
16
|
-
import crypto_cash from './crypto_cash.js'
|
|
17
14
|
import direct_cash from './direct_cash.js'
|
|
18
15
|
import loadcard_cash from './loadcard_cash.js'
|
|
19
16
|
import crypto_bank from './crypto_bank.js'
|
|
@@ -30,8 +27,6 @@ export default {
|
|
|
30
27
|
loadcard_vn,
|
|
31
28
|
qrcode_v2,
|
|
32
29
|
deposit_fc,
|
|
33
|
-
crypto,
|
|
34
|
-
crypto_button,
|
|
35
30
|
direct,
|
|
36
31
|
amb,
|
|
37
32
|
float,
|
|
@@ -41,7 +36,6 @@ export default {
|
|
|
41
36
|
manual_cash,
|
|
42
37
|
qrcode_cash,
|
|
43
38
|
usdt_cash,
|
|
44
|
-
crypto_cash,
|
|
45
39
|
direct_cash,
|
|
46
40
|
loadcard_cash,
|
|
47
41
|
crypto_bank,
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { createMachine, assign } from 'xstate'
|
|
2
|
+
import ranking from '../api/ranking.js'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
const cycleMapping = ['DAILY', 'WEEKLY', 'MONTHLY']
|
|
6
|
+
|
|
7
|
+
function roundProcess(rounds) {
|
|
8
|
+
const roundArrays = rounds.map((round) => Array.from({ length: round }, (_, i) => i + 1))
|
|
9
|
+
return roundArrays.reduce((acc, roundArray, index) => {
|
|
10
|
+
acc[cycleMapping[index]] = roundArray.reverse()
|
|
11
|
+
return acc
|
|
12
|
+
}, {})
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function transGameData(item) {
|
|
16
|
+
if (!item) return {}
|
|
17
|
+
item.providerId = item.provider
|
|
18
|
+
return item
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return createMachine(
|
|
22
|
+
{
|
|
23
|
+
id: 'dragon_tiger_ranking',
|
|
24
|
+
initial: 'idle',
|
|
25
|
+
context: {
|
|
26
|
+
auth: false,
|
|
27
|
+
activityNo: '',
|
|
28
|
+
// api options 回傳的資料
|
|
29
|
+
currentRound: [],
|
|
30
|
+
cycle: '',
|
|
31
|
+
round: 0,
|
|
32
|
+
rule: '',
|
|
33
|
+
// api detail 資料
|
|
34
|
+
description: '',
|
|
35
|
+
descriptionUrl: [],
|
|
36
|
+
// api detail 排名資料
|
|
37
|
+
playerRanking: {},
|
|
38
|
+
gameRanking: [],
|
|
39
|
+
topRanking: [],
|
|
40
|
+
// 前端這邊用的選單資料 { cycle, round }
|
|
41
|
+
options: {},
|
|
42
|
+
},
|
|
43
|
+
states: {
|
|
44
|
+
idle: {
|
|
45
|
+
on: {
|
|
46
|
+
SET_ACTIVITY: {
|
|
47
|
+
target: 'loading',
|
|
48
|
+
},
|
|
49
|
+
SET_OPTIONS: {
|
|
50
|
+
target: 'setting',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
loading: {
|
|
55
|
+
entry: 'setActivity',
|
|
56
|
+
always: [{ target: 'getRankingOptions', cond: 'hasAuth' }, { target: 'getTournament' }],
|
|
57
|
+
},
|
|
58
|
+
setting: {
|
|
59
|
+
entry: 'setOptions',
|
|
60
|
+
always: [{ target: 'getRankingDetail' }],
|
|
61
|
+
},
|
|
62
|
+
// 未登入時取得排名資料
|
|
63
|
+
getTournament: {
|
|
64
|
+
invoke: {
|
|
65
|
+
src: 'fetchTournament',
|
|
66
|
+
onDone: {
|
|
67
|
+
target: 'idle',
|
|
68
|
+
actions: 'setRanking',
|
|
69
|
+
},
|
|
70
|
+
onError: {
|
|
71
|
+
target: 'idle',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
// 登入後取得排名選單資料
|
|
76
|
+
getRankingOptions: {
|
|
77
|
+
invoke: {
|
|
78
|
+
src: 'fetchRankingOptions',
|
|
79
|
+
onDone: {
|
|
80
|
+
target: 'getRankingGames',
|
|
81
|
+
actions: 'setRankingOptions',
|
|
82
|
+
},
|
|
83
|
+
onError: {
|
|
84
|
+
target: 'idle',
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
// 登入後取得排名資料
|
|
89
|
+
getRankingDetail: {
|
|
90
|
+
invoke: {
|
|
91
|
+
src: 'fetchRankingDetail',
|
|
92
|
+
onDone: {
|
|
93
|
+
target: 'idle',
|
|
94
|
+
actions: 'setRanking',
|
|
95
|
+
},
|
|
96
|
+
onError: {
|
|
97
|
+
target: 'idle',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
getRankingGames: {
|
|
102
|
+
invoke: {
|
|
103
|
+
src: 'fetchRankingGames',
|
|
104
|
+
onDone: {
|
|
105
|
+
target: 'getRankingDetail',
|
|
106
|
+
actions: 'setRankingGames',
|
|
107
|
+
},
|
|
108
|
+
onError: {
|
|
109
|
+
target: 'idle',
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
actions: {
|
|
117
|
+
setActivity: assign((context, event) => {
|
|
118
|
+
return {
|
|
119
|
+
auth: !!request.getToken(),
|
|
120
|
+
activityNo: event.data?.activityNo,
|
|
121
|
+
}
|
|
122
|
+
}),
|
|
123
|
+
setRanking: assign((context, event) => {
|
|
124
|
+
const topRanking = event.data?.topRanking?.map((rank) => transGameData(rank))
|
|
125
|
+
return {
|
|
126
|
+
description: event.data?.description,
|
|
127
|
+
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 || [],
|
|
136
|
+
}
|
|
137
|
+
}),
|
|
138
|
+
setRankingOptions: assign((context, event) => {
|
|
139
|
+
const cycle = event.data?.cycle
|
|
140
|
+
const currentRound = event.data?.currentRound || []
|
|
141
|
+
// 取得結算週期選單列表
|
|
142
|
+
const cycleOptions = cycleMapping.slice(0, currentRound.length)
|
|
143
|
+
// 取得每週期的歷史期數選單列表
|
|
144
|
+
const roundOptions = roundProcess(currentRound)
|
|
145
|
+
// 如果是月結算,則加入全部選項
|
|
146
|
+
if (cycle === 'MONTHLY') {
|
|
147
|
+
cycleOptions.push('ALL')
|
|
148
|
+
roundOptions.ALL = roundOptions.MONTHLY
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
...event.data,
|
|
152
|
+
options: { cycle: cycleOptions, round: roundOptions },
|
|
153
|
+
// 初始固定顯示 DAILY
|
|
154
|
+
cycle: event.data?.rule !== 'NORMAL' ? 'DAILY' : cycle,
|
|
155
|
+
round: currentRound[0],
|
|
156
|
+
}
|
|
157
|
+
}),
|
|
158
|
+
setOptions: assign((context, event) => {
|
|
159
|
+
const { cycle, round } = context
|
|
160
|
+
// 處理變更 cycle,如果沒有輸入或沒有變更就不更新
|
|
161
|
+
if (event.data?.cycle && cycle !== event.data?.cycle) {
|
|
162
|
+
const { currentRound } = context
|
|
163
|
+
const cycleForRound = event.data?.cycle === 'ALL' ? 'MONTHLY' : event.data?.cycle
|
|
164
|
+
const cycleIndex = cycleMapping.indexOf(cycleForRound)
|
|
165
|
+
return { cycle: event.data?.cycle, round: currentRound[cycleIndex] }
|
|
166
|
+
}
|
|
167
|
+
if (event.data?.round && round !== event.data?.round) {
|
|
168
|
+
return { round: event.data?.round }
|
|
169
|
+
}
|
|
170
|
+
return {}
|
|
171
|
+
}),
|
|
172
|
+
},
|
|
173
|
+
guards: {
|
|
174
|
+
hasAuth: (context) => context.auth,
|
|
175
|
+
},
|
|
176
|
+
services: {
|
|
177
|
+
fetchTournament: async (context) => {
|
|
178
|
+
const { activityNo } = context
|
|
179
|
+
const { data } = await request.send(ranking.getTournament({ activityNo }))
|
|
180
|
+
return data
|
|
181
|
+
},
|
|
182
|
+
fetchRankingOptions: async (context) => {
|
|
183
|
+
const { activityNo } = context
|
|
184
|
+
const { data } = await request.send(ranking.getRankingOptions({ activityNo }))
|
|
185
|
+
return data
|
|
186
|
+
},
|
|
187
|
+
fetchRankingDetail: async (context, event) => {
|
|
188
|
+
const { activityNo, cycle, round } = context
|
|
189
|
+
const { data } = await request.send(ranking.getRankingDetail({ activityNo, cycle, round }))
|
|
190
|
+
return data
|
|
191
|
+
},
|
|
192
|
+
fetchRankingGames: async (context) => {
|
|
193
|
+
const { activityNo } = context
|
|
194
|
+
const { data } = await request.send(ranking.getRankingGames({ activityNo }))
|
|
195
|
+
return data
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
}
|
|
199
|
+
)
|
|
200
|
+
}
|
package/src/machine/error.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
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
|
|
2
6
|
|
|
3
|
-
export default function () {
|
|
4
7
|
return createMachine(
|
|
5
8
|
{
|
|
6
9
|
id: 'error',
|
|
@@ -8,6 +11,7 @@ export default function () {
|
|
|
8
11
|
context: {
|
|
9
12
|
error: null,
|
|
10
13
|
gameCode: null,
|
|
14
|
+
game: null,
|
|
11
15
|
},
|
|
12
16
|
states: {
|
|
13
17
|
normal: {
|
|
@@ -28,15 +32,23 @@ export default function () {
|
|
|
28
32
|
{ target: 'unfinishedGame', cond: 'isUnfinishedGame', actions: 'setUnfinishedGame' },
|
|
29
33
|
{ target: 'freeGameSettle', cond: 'isFreeGameSettle' },
|
|
30
34
|
{ target: 'freeGameGiveUp', cond: 'isFreeGameGiveUp' },
|
|
31
|
-
// { target: 'hall' },
|
|
32
35
|
],
|
|
33
36
|
},
|
|
34
37
|
logout: {},
|
|
35
38
|
deposit: {},
|
|
36
|
-
unfinishedGame: {
|
|
39
|
+
unfinishedGame: {
|
|
40
|
+
invoke: {
|
|
41
|
+
src: 'getGameInfo',
|
|
42
|
+
onDone: {
|
|
43
|
+
actions: 'setGame',
|
|
44
|
+
},
|
|
45
|
+
onError: {
|
|
46
|
+
target: 'unfinishedGame',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
37
50
|
freeGameSettle: {},
|
|
38
51
|
freeGameGiveUp: {},
|
|
39
|
-
// hall: {},
|
|
40
52
|
},
|
|
41
53
|
},
|
|
42
54
|
},
|
|
@@ -58,6 +70,12 @@ export default function () {
|
|
|
58
70
|
gameCode: context.error.extend.split(/_(.+)/)[1],
|
|
59
71
|
}
|
|
60
72
|
}),
|
|
73
|
+
setGame: assign((context, event) => {
|
|
74
|
+
const { data = [] } = event.data
|
|
75
|
+
return {
|
|
76
|
+
game: data?.[0],
|
|
77
|
+
}
|
|
78
|
+
}),
|
|
61
79
|
},
|
|
62
80
|
guards: {
|
|
63
81
|
isLogout: (context, event) => {
|
|
@@ -76,7 +94,12 @@ export default function () {
|
|
|
76
94
|
return context.error.code === 'ERR_G125'
|
|
77
95
|
},
|
|
78
96
|
},
|
|
79
|
-
services: {
|
|
97
|
+
services: {
|
|
98
|
+
getGameInfo: async (context, event) => {
|
|
99
|
+
const { gameCode } = context
|
|
100
|
+
return await request.send(api.getV3GameInfo({ appSecret, gameCodes: [gameCode] }))
|
|
101
|
+
},
|
|
102
|
+
},
|
|
80
103
|
}
|
|
81
104
|
)
|
|
82
105
|
}
|
package/src/machine/game_v2_1.js
CHANGED
|
@@ -49,7 +49,6 @@ export default function (request) {
|
|
|
49
49
|
gameWalletType: null,
|
|
50
50
|
switchGame: null,
|
|
51
51
|
isPlaying: false,
|
|
52
|
-
...oldContext,
|
|
53
52
|
},
|
|
54
53
|
states: {
|
|
55
54
|
flow: {
|
|
@@ -207,7 +206,6 @@ export default function (request) {
|
|
|
207
206
|
actions: ['setIsPlaying', 'resetContent', 'resetSHA'],
|
|
208
207
|
},
|
|
209
208
|
LEAVE_GAME_REFRESH: {
|
|
210
|
-
target: '#game.oldTimer',
|
|
211
209
|
actions: 'setIsPlaying',
|
|
212
210
|
},
|
|
213
211
|
},
|
|
@@ -282,63 +280,6 @@ export default function (request) {
|
|
|
282
280
|
},
|
|
283
281
|
},
|
|
284
282
|
},
|
|
285
|
-
oldTimer: {
|
|
286
|
-
initial: 'fetchingGameSHA',
|
|
287
|
-
states: {
|
|
288
|
-
fetchingGameSHA: {
|
|
289
|
-
invoke: {
|
|
290
|
-
src: 'fetchGameSHA',
|
|
291
|
-
onDone: {
|
|
292
|
-
target: 'checking',
|
|
293
|
-
actions: 'setGameSHA',
|
|
294
|
-
},
|
|
295
|
-
onError: {
|
|
296
|
-
target: 'pending',
|
|
297
|
-
},
|
|
298
|
-
},
|
|
299
|
-
},
|
|
300
|
-
checking: {
|
|
301
|
-
always: [{ target: 'updatingStatus', cond: 'isStatusChanged' }, { target: 'pending' }],
|
|
302
|
-
},
|
|
303
|
-
updatingStatus: {
|
|
304
|
-
invoke: {
|
|
305
|
-
src: 'fetchStatus',
|
|
306
|
-
onDone: {
|
|
307
|
-
target: 'updatingOption',
|
|
308
|
-
actions: ['setStatus'],
|
|
309
|
-
},
|
|
310
|
-
onError: {
|
|
311
|
-
target: 'pending',
|
|
312
|
-
},
|
|
313
|
-
},
|
|
314
|
-
},
|
|
315
|
-
updatingOption: {
|
|
316
|
-
invoke: {
|
|
317
|
-
src: 'fetchOption',
|
|
318
|
-
onDone: {
|
|
319
|
-
target: 'pending',
|
|
320
|
-
actions: 'mergeOption',
|
|
321
|
-
},
|
|
322
|
-
onError: {
|
|
323
|
-
target: 'pending',
|
|
324
|
-
},
|
|
325
|
-
},
|
|
326
|
-
},
|
|
327
|
-
pending: {
|
|
328
|
-
after: {
|
|
329
|
-
20000: [
|
|
330
|
-
{
|
|
331
|
-
target: 'fetchingGameSHA',
|
|
332
|
-
cond: 'isNotInGame',
|
|
333
|
-
},
|
|
334
|
-
{
|
|
335
|
-
target: 'pending',
|
|
336
|
-
},
|
|
337
|
-
],
|
|
338
|
-
},
|
|
339
|
-
},
|
|
340
|
-
},
|
|
341
|
-
},
|
|
342
283
|
},
|
|
343
284
|
},
|
|
344
285
|
{
|
|
@@ -455,9 +396,6 @@ export default function (request) {
|
|
|
455
396
|
return event.data.gameWalletType
|
|
456
397
|
},
|
|
457
398
|
}),
|
|
458
|
-
clearGameInfo: assign((context, event) => {
|
|
459
|
-
return { game: { providerId: null, gameId: null, gameTypeId: null, mappingId: null } }
|
|
460
|
-
}),
|
|
461
399
|
setGameInfo: assign((context, event) => {
|
|
462
400
|
const { providerId, gameId, gameTypeId, mappingId, portrait, gameCode, name } = event.data.game
|
|
463
401
|
return { game: { providerId, gameId, gameTypeId, mappingId, portrait: portrait ? 1 : 0, gameCode, name } }
|
|
@@ -491,7 +429,6 @@ export default function (request) {
|
|
|
491
429
|
isPlaying: event.data,
|
|
492
430
|
}
|
|
493
431
|
}),
|
|
494
|
-
...oldActions,
|
|
495
432
|
},
|
|
496
433
|
guards: {
|
|
497
434
|
isDifferentRoom: (context, event) => context.room?.categoryId !== event.data?.categoryId,
|
|
@@ -500,13 +437,9 @@ export default function (request) {
|
|
|
500
437
|
// 是否有下一頁
|
|
501
438
|
return loadable && !isLastPage
|
|
502
439
|
},
|
|
503
|
-
isNotInGame: (context, event) => {
|
|
504
|
-
return !context.isPlaying
|
|
505
|
-
},
|
|
506
440
|
hasRoomAndIsNotInGame: (context, event) => {
|
|
507
441
|
return context.room?.categoryId && !context.isPlaying
|
|
508
442
|
},
|
|
509
|
-
...oldGuards,
|
|
510
443
|
},
|
|
511
444
|
services: {
|
|
512
445
|
batchFetch: async (context, event) => {
|
|
@@ -634,75 +567,7 @@ export default function (request) {
|
|
|
634
567
|
const provider_id = context.game.providerId
|
|
635
568
|
return await request.send(api.logoutGame({ uid_site, provider_id }))
|
|
636
569
|
},
|
|
637
|
-
...oldServices(request),
|
|
638
570
|
},
|
|
639
571
|
}
|
|
640
572
|
)
|
|
641
573
|
}
|
|
642
|
-
|
|
643
|
-
const oldContext = {
|
|
644
|
-
sha: {
|
|
645
|
-
status: null,
|
|
646
|
-
},
|
|
647
|
-
isStatusChanged: false,
|
|
648
|
-
statusMap: {},
|
|
649
|
-
optionMap: {},
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
const oldActions = {
|
|
653
|
-
setGameSHA: assign((context, event) => {
|
|
654
|
-
const { sha } = context
|
|
655
|
-
const newSha = event.data
|
|
656
|
-
return {
|
|
657
|
-
sha: newSha,
|
|
658
|
-
isStatusChanged: !sha.status || sha.status !== newSha.status,
|
|
659
|
-
}
|
|
660
|
-
}),
|
|
661
|
-
setStatus: assign((context, event) => {
|
|
662
|
-
return {
|
|
663
|
-
statusMap: event.data,
|
|
664
|
-
}
|
|
665
|
-
}),
|
|
666
|
-
mergeOption: assign((context, event) => {
|
|
667
|
-
const { optionMap } = context
|
|
668
|
-
return {
|
|
669
|
-
optionMap: { ...optionMap, ...event.data },
|
|
670
|
-
}
|
|
671
|
-
}),
|
|
672
|
-
resetSHA: assign((context, event) => {
|
|
673
|
-
return {
|
|
674
|
-
sha: {
|
|
675
|
-
status: null,
|
|
676
|
-
},
|
|
677
|
-
isStatusChanged: false,
|
|
678
|
-
statusMap: {},
|
|
679
|
-
optionMap: {},
|
|
680
|
-
}
|
|
681
|
-
}),
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
const oldGuards = {
|
|
685
|
-
isStatusChanged: (context, event) => context.isStatusChanged,
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
const oldServices = (request) => ({
|
|
689
|
-
fetchOption: async (context, event) => {
|
|
690
|
-
if (request.getToken()) {
|
|
691
|
-
return await request.send(api.getOptionMap())
|
|
692
|
-
}
|
|
693
|
-
},
|
|
694
|
-
fetchGameSHA: async (context, event) => {
|
|
695
|
-
if (request.getToken()) {
|
|
696
|
-
return await request.send(api.getGameSHA())
|
|
697
|
-
} else {
|
|
698
|
-
return {
|
|
699
|
-
status: null,
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
},
|
|
703
|
-
fetchStatus: async (context, event) => {
|
|
704
|
-
if (request.getToken()) {
|
|
705
|
-
return await request.send(api.getGameStatus())
|
|
706
|
-
}
|
|
707
|
-
},
|
|
708
|
-
})
|