@jetthai/cuora 1.0.78 → 1.0.79
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 +2 -0
- package/package.json +1 -1
- package/src/machine/game.js +12 -0
- package/src/machine/index.js +2 -0
- package/src/machine/side_v2.js +147 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
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.0.79](https://github.com/jetthai/cuora-module/compare/v1.0.78...v1.0.79) (2022-01-14)
|
|
6
|
+
|
|
5
7
|
### [1.0.78](https://github.com/jetthai/cuora-module/compare/v1.0.77...v1.0.78) (2022-01-14)
|
|
6
8
|
|
|
7
9
|
### [1.0.77](https://github.com/jetthai/cuora-module/compare/v1.0.76...v1.0.77) (2022-01-12)
|
package/package.json
CHANGED
package/src/machine/game.js
CHANGED
|
@@ -9,6 +9,7 @@ export default function (request) {
|
|
|
9
9
|
type: 'parallel',
|
|
10
10
|
context: {
|
|
11
11
|
roomId: null,
|
|
12
|
+
room: null,
|
|
12
13
|
list: [],
|
|
13
14
|
gameList: [],
|
|
14
15
|
// play params
|
|
@@ -38,6 +39,7 @@ export default function (request) {
|
|
|
38
39
|
idle: {
|
|
39
40
|
enter: 'clearGameInfo',
|
|
40
41
|
on: {
|
|
42
|
+
// todo - deprecated
|
|
41
43
|
ENTER_ROOM: {
|
|
42
44
|
target: 'loading',
|
|
43
45
|
actions: 'setRoomId',
|
|
@@ -45,6 +47,10 @@ export default function (request) {
|
|
|
45
47
|
return context.roomId !== event.roomId
|
|
46
48
|
},
|
|
47
49
|
},
|
|
50
|
+
SET_ROOM: {
|
|
51
|
+
target: 'loading',
|
|
52
|
+
actions: 'setRoom',
|
|
53
|
+
},
|
|
48
54
|
ENTER_GAME: {
|
|
49
55
|
target: 'connecting',
|
|
50
56
|
actions: ['setGameInfo', 'setLang'],
|
|
@@ -173,6 +179,12 @@ export default function (request) {
|
|
|
173
179
|
setRoomId: assign((context, event) => {
|
|
174
180
|
return { roomId: event.roomId }
|
|
175
181
|
}),
|
|
182
|
+
setRoom: assign((context, event) => {
|
|
183
|
+
return {
|
|
184
|
+
room: event.data,
|
|
185
|
+
roomId: event.data.id,
|
|
186
|
+
}
|
|
187
|
+
}),
|
|
176
188
|
setList: assign((context, event) => {
|
|
177
189
|
const { statusMap, optionMap } = context
|
|
178
190
|
const { list } = event.data
|
package/src/machine/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import payment_data from './payment_data'
|
|
|
14
14
|
import reward from './reward'
|
|
15
15
|
import setting from './setting'
|
|
16
16
|
import side from './side'
|
|
17
|
+
import side_v2 from './side_v2'
|
|
17
18
|
import withdraw from './withdraw'
|
|
18
19
|
import user_info from './user_info'
|
|
19
20
|
import user_sign_up from './user_sign_up'
|
|
@@ -41,6 +42,7 @@ export default {
|
|
|
41
42
|
reward,
|
|
42
43
|
setting,
|
|
43
44
|
side,
|
|
45
|
+
side_v2,
|
|
44
46
|
withdraw,
|
|
45
47
|
user_info,
|
|
46
48
|
user_sign_up,
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import api from '../api/game'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
return createMachine(
|
|
6
|
+
{
|
|
7
|
+
id: 'side_v2',
|
|
8
|
+
initial: 'loading',
|
|
9
|
+
context: {
|
|
10
|
+
menu: {},
|
|
11
|
+
room: null,
|
|
12
|
+
roomHistory: [],
|
|
13
|
+
},
|
|
14
|
+
states: {
|
|
15
|
+
loading: {
|
|
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
|
+
entry: 'resetRoomHistory',
|
|
29
|
+
initial: 'home',
|
|
30
|
+
states: {
|
|
31
|
+
home: {
|
|
32
|
+
entry: assign({ room: (context, event) => context.menu['home'] }),
|
|
33
|
+
},
|
|
34
|
+
favorite: {
|
|
35
|
+
entry: assign({ room: (context, event) => context.menu['favorite'] }),
|
|
36
|
+
},
|
|
37
|
+
hot: {
|
|
38
|
+
entry: assign({ room: (context, event) => context.menu['hot'] }),
|
|
39
|
+
},
|
|
40
|
+
new: {
|
|
41
|
+
entry: assign({ room: (context, event) => context.menu['new'] }),
|
|
42
|
+
},
|
|
43
|
+
slot: {
|
|
44
|
+
entry: assign({ room: (context, event) => context.menu['slot'] }),
|
|
45
|
+
},
|
|
46
|
+
fish: {
|
|
47
|
+
entry: assign({ room: (context, event) => context.menu['fish'] }),
|
|
48
|
+
},
|
|
49
|
+
arcade: {
|
|
50
|
+
entry: assign({ room: (context, event) => context.menu['arcade'] }),
|
|
51
|
+
},
|
|
52
|
+
table: {
|
|
53
|
+
entry: assign({ room: (context, event) => context.menu['table'] }),
|
|
54
|
+
},
|
|
55
|
+
search: {},
|
|
56
|
+
history: {
|
|
57
|
+
type: 'history',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
feature: {
|
|
62
|
+
on: {
|
|
63
|
+
RETURN: { target: 'room.history' },
|
|
64
|
+
CLICK_HOT: { target: 'room.hot' },
|
|
65
|
+
CLICK_NEW: { target: 'room.new' },
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
category: {
|
|
69
|
+
on: {
|
|
70
|
+
RETURN: { target: 'room.history' },
|
|
71
|
+
CLICK_SLOT: { target: 'room.slot' },
|
|
72
|
+
CLICK_FISH: { target: 'room.fish' },
|
|
73
|
+
CLICK_ARCADE: { target: 'room.arcade' },
|
|
74
|
+
CLICK_TABLE: { target: 'room.table' },
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
on: {
|
|
79
|
+
CLICK_HOME: { target: 'room.home' },
|
|
80
|
+
CLICK_FAVORITE: { target: 'room.favorite' },
|
|
81
|
+
CLICK_FEATURE: { target: 'feature' },
|
|
82
|
+
CLICK_CATEGORY: { target: 'category' },
|
|
83
|
+
CLICK_SEARCH: { target: 'room.search' },
|
|
84
|
+
FORWARD_ROOM: { actions: 'forwardRoom' },
|
|
85
|
+
BACKWARD_ROOM: { actions: 'backwardRoom' },
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
actions: {
|
|
90
|
+
makeMenu: assign((context, event) => {
|
|
91
|
+
const { list = [] } = event.data
|
|
92
|
+
const map = {
|
|
93
|
+
home: ['SYSTEM_PERSONAL', 'SYSTEM_INDEX_LIST'],
|
|
94
|
+
favorite: 'SYSTEM_MY_FAVORITE',
|
|
95
|
+
hot: 'SYSTEM_TOP_GAME',
|
|
96
|
+
new: 'SYSTEM_NEW_GAME',
|
|
97
|
+
slot: 'SYSTEM_BIG_CATEGORY_SLOT',
|
|
98
|
+
fish: 'SYSTEM_BIG_CATEGORY_FISHING',
|
|
99
|
+
arcade: 'SYSTEM_BIG_CATEGORY_ARCADE',
|
|
100
|
+
table: 'SYSTEM_BIG_CATEGORY_TABLECARD',
|
|
101
|
+
}
|
|
102
|
+
const menu = {}
|
|
103
|
+
Object.keys(map).forEach((key) => {
|
|
104
|
+
if (Array.isArray(map[key])) {
|
|
105
|
+
// 若是陣列則依順序決定館別內容
|
|
106
|
+
map[key].some((val) => {
|
|
107
|
+
const category = list.find((item) => item.category === val)
|
|
108
|
+
if (category) {
|
|
109
|
+
menu[key] = category
|
|
110
|
+
return true
|
|
111
|
+
} else {
|
|
112
|
+
return false
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
} else {
|
|
116
|
+
menu[key] = list.find((item) => item.category === map[key])
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
return { menu }
|
|
120
|
+
}),
|
|
121
|
+
forwardRoom: assign((context, event) => {
|
|
122
|
+
return {
|
|
123
|
+
room: event.data,
|
|
124
|
+
roomHistory: [...context.roomHistory, context.room],
|
|
125
|
+
}
|
|
126
|
+
}),
|
|
127
|
+
backwardRoom: assign((context, event) => {
|
|
128
|
+
const { roomHistory } = context
|
|
129
|
+
return {
|
|
130
|
+
room: roomHistory.slice(-1)[0],
|
|
131
|
+
roomHistory: roomHistory.slice(0, -1),
|
|
132
|
+
}
|
|
133
|
+
}),
|
|
134
|
+
resetRoomHistory: assign((context, event) => {
|
|
135
|
+
return {
|
|
136
|
+
roomHistory: [],
|
|
137
|
+
}
|
|
138
|
+
}),
|
|
139
|
+
},
|
|
140
|
+
services: {
|
|
141
|
+
getRoomItems: async (context, event) => {
|
|
142
|
+
return await request.send(api.getGameCategory({ id: context.room?.id }))
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
}
|
|
146
|
+
)
|
|
147
|
+
}
|