Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
RB_StrongestBrain_250520
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
SparkProjects
RB_StrongestBrain_250520
Commits
6f300672
Commit
6f300672
authored
May 23, 2025
by
haiyoucuv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
11
parent
c6050460
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
2 deletions
+48
-2
Game.ts
src/pages/GamePage/Game.ts
+9
-0
gameStore.ts
src/store/gameStore.ts
+39
-2
No files found.
src/pages/GamePage/Game.ts
View file @
6f300672
...
...
@@ -52,6 +52,15 @@ export class Game extends Base {
const
{
levelIndex
,
levelIdxArr
}
=
gameStore
.
gameInfo
;
if
(
levelIndex
>
0
)
{
if
(
levelIndex
>=
LevelArr
.
length
)
{
gameStore
.
submit
(
LevelArr
.
length
);
return
;
}
else
{
gameStore
.
middleSubmit
(
levelIndex
);
}
}
if
(
levelIndex
>=
levelIdxArr
.
length
)
{
return
;
}
...
...
src/store/gameStore.ts
View file @
6f300672
import
{
makeAutoObservable
,
}
from
'mobx'
;
import
{
LevelArr
}
from
"@/pages/GamePage/Level/LevelConfig.ts"
;
import
API
from
"@/api"
;
import
{
AESEncrypt
}
from
"@/utils/Crypto.ts"
;
import
{
PageCtrl
}
from
"@/core/ctrls/PageCtrl.tsx"
;
import
HomePage
from
"@/pages/HomePage/HomePage.tsx"
;
import
{
ModalCtrl
}
from
"@/core/ctrls/ModalCtrl.tsx"
;
import
Settlechance
from
"@/components/settlechance/settlechance"
;
import
Settlenochance
from
"@/components/settlenochance/settlenochance"
;
class
GameStore
{
...
...
@@ -9,6 +15,7 @@ class GameStore {
}
gameInfo
=
{
recordId
:
""
,
levelIndex
:
-
1
,
levelIdxArr
:
[],
countdownSeconds
:
180
,
...
...
@@ -23,16 +30,46 @@ class GameStore {
this
.
gameInfo
.
levelIdxArr
=
LevelArr
.
map
((
_
,
index
)
=>
index
);
this
.
gameInfo
.
levelIdxArr
.
sort
(()
=>
Math
.
random
()
-
0.5
);
this
.
gameInfo
.
levelIndex
=
-
1
;
this
.
gameInfo
.
recordId
=
data
.
recordId
;
this
.
gameInfo
.
countdownSeconds
=
data
.
countdownSeconds
;
this
.
gameInfo
.
remainTipTimes
=
data
.
remainTipTimes
return
success
;
}
async
submit
()
{
async
middleSubmit
(
score
:
number
)
{
console
.
log
(
score
);
const
param
=
AESEncrypt
(
JSON
.
stringify
({
recordId
:
this
.
gameInfo
.
recordId
,
score
,
timestamp
:
Date
.
now
(),
}),
"7A2F4B8D1E6C3905"
,
"cDOiBC1n2QrkAY2P"
);
const
score
=
this
.
gameInfo
.
levelIndex
;
const
{
success
,
data
}
=
await
API
.
middleSubmit
({
param
});
return
success
;
}
async
submit
(
score
:
number
)
{
console
.
log
(
score
);
const
param
=
AESEncrypt
(
JSON
.
stringify
({
recordId
:
this
.
gameInfo
.
recordId
,
score
,
timestamp
:
Date
.
now
(),
}),
"7A2F4B8D1E6C3905"
,
"cDOiBC1n2QrkAY2P"
);
const
{
success
,
data
}
=
await
API
.
middleSubmit
({
param
});
if
(
!
success
)
{
PageCtrl
.
changePage
(
HomePage
);
return
success
;
}
if
(
data
.
drawChance
)
{
ModalCtrl
.
showModal
(
Settlechance
,
{
score
,
...
data
});
}
else
{
ModalCtrl
.
showModal
(
Settlenochance
,
{
score
,
...
data
});
}
return
success
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment