Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Neos
Commits
ab0861ed
Commit
ab0861ed
authored
Apr 08, 2023
by
timel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: comments, 50%
parent
12b44c96
Pipeline
#21148
failed with stages
in 16 minutes and 10 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
26 deletions
+30
-26
src/hook/index.ts
src/hook/index.ts
+1
-1
src/hook/useConfig.ts
src/hook/useConfig.ts
+20
-16
src/ui/Login.tsx
src/ui/Login.tsx
+4
-4
src/ui/Mora.tsx
src/ui/Mora.tsx
+3
-3
src/ui/WaitRoom.tsx
src/ui/WaitRoom.tsx
+2
-2
No files found.
src/hook/index.ts
View file @
ab0861ed
export
*
from
"
./useApp
"
;
export
*
from
"
./useEnv
"
;
export
*
from
"
./use
AutoMode
"
;
export
*
from
"
./use
Config
"
;
src/hook/use
AutoMode
.ts
→
src/hook/use
Config
.ts
View file @
ab0861ed
...
...
@@ -7,35 +7,39 @@ import { useEnv } from ".";
const
{
DEV
,
VITE_IS_AI_MODE
,
VITE_IS_AI_FIRST
,
VITE_AI_MODE_DEFAULT_DECK
}
=
useEnv
();
interface
AutoMod
eConfig
{
defaultPlayer
?
:
string
;
defaultDeck
?
:
string
;
defaultPassword
?
:
string
;
defaultMora
?
:
string
;
isAiMode
?
:
boolean
;
isAiFirst
?
:
boolean
;
interface
Prepar
eConfig
{
defaultPlayer
:
string
;
defaultDeck
:
string
;
defaultPassword
:
string
;
defaultMora
:
string
;
isAiMode
:
boolean
;
isAiFirst
:
boolean
;
}
const
autoModeConfig
:
AutoMod
eConfig
=
{
const
autoModeConfig
:
Prepar
eConfig
=
{
defaultPlayer
:
""
,
defaultDeck
:
VITE_AI_MODE_DEFAULT_DECK
??
"
Hero
"
,
// 无需考虑undefined的情况,如果为undefined,界面上会显示【请选择】
defaultDeck
:
VITE_AI_MODE_DEFAULT_DECK
,
defaultPassword
:
""
,
defaultMora
:
"
scissors
"
,
isAiMode
:
false
,
isAiFirst
:
false
,
};
const
aiModeConfig
:
AutoMod
eConfig
=
{
const
aiModeConfig
:
Prepar
eConfig
=
{
...
autoModeConfig
,
defaultPlayer
:
`AiKiller
${
Math
.
random
().
toString
(
36
).
slice
(
2
)}
}`
,
defaultPassword
:
"
AI
"
,
defaultMora
:
"
scissors
"
,
isAiMode
:
true
,
isAiFirst
:
VITE_IS_AI_FIRST
,
};
export
function
useAutoMode
():
AutoModeConfig
{
if
(
!
DEV
)
return
{};
if
(
VITE_IS_AI_MODE
)
{
return
aiModeConfig
;
export
function
useConfig
():
PrepareConfig
{
if
(
DEV
)
{
if
(
VITE_IS_AI_MODE
)
{
return
aiModeConfig
;
}
// 待拓展
}
return
autoModeConfig
;
...
...
src/ui/Login.tsx
View file @
ab0861ed
...
...
@@ -11,14 +11,14 @@ import React, { useState, ChangeEvent, useEffect } from "react";
import
{
useNavigate
}
from
"
react-router-dom
"
;
import
"
../styles/core.scss
"
;
import
NeosConfig
from
"
../../neos.config.json
"
;
import
{
use
AutoMode
}
from
"
../hook
"
;
import
{
use
Config
}
from
"
../hook
"
;
const
serverConfig
=
NeosConfig
.
servers
;
const
{
isAiMode
,
defaultPlayer
,
defaultPassword
}
=
use
AutoMode
();
const
{
isAiMode
,
defaultPlayer
,
defaultPassword
}
=
use
Config
();
export
default
function
Login
()
{
const
[
player
,
setPlayer
]
=
useState
(
isAiMode
?
defaultPlayer
:
""
);
const
[
passWd
,
setPasswd
]
=
useState
(
isAiMode
?
defaultPassword
:
""
);
const
[
player
,
setPlayer
]
=
useState
(
defaultPlayer
);
const
[
passWd
,
setPasswd
]
=
useState
(
defaultPassword
);
const
[
ip
,
setIp
]
=
useState
(
`
${
serverConfig
[
0
].
ip
}
:
${
serverConfig
[
0
].
port
}
`
);
const
navigate
=
useNavigate
();
...
...
src/ui/Mora.tsx
View file @
ab0861ed
import
React
from
"
react
"
;
import
{
sendHandResult
,
sendTpResult
}
from
"
../api/ocgcore/ocgHelper
"
;
import
{
useAppSelector
,
use
AutoMode
}
from
"
../hook
"
;
import
{
useAppSelector
,
use
Config
}
from
"
../hook
"
;
import
{
selectHandSelectAble
,
unSelectHandAble
,
...
...
@@ -18,7 +18,7 @@ import {
TableOutlined
,
}
from
"
@ant-design/icons
"
;
const
{
isAiMode
,
isAiFirst
,
defaultMora
}
=
use
AutoMode
();
const
{
isAiMode
,
isAiFirst
,
defaultMora
}
=
use
Config
();
const
Mora
=
()
=>
{
const
dispatch
=
store
.
dispatch
;
...
...
@@ -50,7 +50,7 @@ const Mora = () => {
useEffect
(()
=>
{
if
(
isAiMode
)
{
handleSelectMora
(
defaultMora
!
);
handleSelectMora
(
defaultMora
);
}
},
[
selectHandAble
]);
...
...
src/ui/WaitRoom.tsx
View file @
ab0861ed
...
...
@@ -19,7 +19,7 @@ import {
selectPlayer0
,
selectPlayer1
,
}
from
"
../reducers/playerSlice
"
;
import
{
useAppSelector
,
use
AutoMode
}
from
"
../hook
"
;
import
{
useAppSelector
,
use
Config
}
from
"
../hook
"
;
import
{
selectJoined
}
from
"
../reducers/joinSlice
"
;
import
{
selectChat
}
from
"
../reducers/chatSlice
"
;
import
{
fetchDeck
,
type
IDeck
,
DeckManager
}
from
"
../api/deck
"
;
...
...
@@ -48,7 +48,7 @@ import { initStrings } from "../api/strings";
const
READY_STATE
=
"
ready
"
;
const
{
isAiMode
,
defaultDeck
}
=
use
AutoMode
();
const
{
isAiMode
,
defaultDeck
}
=
use
Config
();
const
WaitRoom
=
()
=>
{
const
params
=
useParams
<
{
...
...
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