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
2bab3140
Commit
2bab3140
authored
Jun 22, 2024
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add genPredictReq but remain unimpl
parent
308c696a
Pipeline
#27902
failed with stages
in 9 minutes
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
3 deletions
+32
-3
src/api/ygoAgent/create.ts
src/api/ygoAgent/create.ts
+1
-1
src/api/ygoAgent/predict.ts
src/api/ygoAgent/predict.ts
+1
-1
src/service/duel/agent.ts
src/service/duel/agent.ts
+17
-0
src/service/duel/start.ts
src/service/duel/start.ts
+5
-1
src/stores/matStore/store.ts
src/stores/matStore/store.ts
+5
-0
src/stores/matStore/types.ts
src/stores/matStore/types.ts
+3
-0
No files found.
src/api/ygoAgent/create.ts
View file @
2bab3140
...
@@ -11,7 +11,7 @@ interface CreateResp {
...
@@ -11,7 +11,7 @@ interface CreateResp {
index
:
number
;
index
:
number
;
}
}
export
async
function
crateDuel
():
Promise
<
CreateResp
|
undefined
>
{
export
async
function
cr
e
ateDuel
():
Promise
<
CreateResp
|
undefined
>
{
const
headers
=
agentHeader
();
const
headers
=
agentHeader
();
const
resp
=
await
fetch
(
`
${
agentServer
}
/
${
API_PATH
}
`
,
{
const
resp
=
await
fetch
(
`
${
agentServer
}
/
${
API_PATH
}
`
,
{
...
...
src/api/ygoAgent/predict.ts
View file @
2bab3140
...
@@ -7,7 +7,7 @@ import { agentHeader } from "./util";
...
@@ -7,7 +7,7 @@ import { agentHeader } from "./util";
const
{
agentServer
}
=
useConfig
();
const
{
agentServer
}
=
useConfig
();
const
apiPath
=
(
duelId
:
string
)
=>
`
${
agentServer
}
/v0/duels/
${
duelId
}
/predict`
;
const
apiPath
=
(
duelId
:
string
)
=>
`
${
agentServer
}
/v0/duels/
${
duelId
}
/predict`
;
interface
PredictReq
{
export
interface
PredictReq
{
/**
/**
* The index must be equal to the index from the previous response of the same duelId.
* The index must be equal to the index from the previous response of the same duelId.
*/
*/
...
...
src/service/duel/agent.ts
0 → 100644
View file @
2bab3140
import
{
PredictReq
}
from
"
@/api
"
;
import
{
cardStore
,
matStore
,
placeStore
}
from
"
@/stores
"
;
export
function
genPredictReq
():
PredictReq
{
// 全局信息可以从 `matStore` 里面拿
const
mat
=
matStore
;
// 卡片信息可以从 `cardStore` 里面拿
const
cards
=
cardStore
.
inner
;
// 选择场上位置的可选项可以从 `cardStore` 里面拿
// 也可以从 `selectPlace` msg 里面获取
const
place
=
placeStore
;
const
duelId
=
mat
.
duelId
;
const
index
=
mat
.
agentIndex
;
// TODO: impl
}
src/service/duel/start.ts
View file @
2bab3140
import
{
flatten
}
from
"
lodash-es
"
;
import
{
flatten
}
from
"
lodash-es
"
;
import
{
v4
as
v4uuid
}
from
"
uuid
"
;
import
{
v4
as
v4uuid
}
from
"
uuid
"
;
import
{
ygopro
}
from
"
@/api
"
;
import
{
createDuel
,
ygopro
}
from
"
@/api
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
sleep
}
from
"
@/infra
"
;
import
{
sleep
}
from
"
@/infra
"
;
import
{
import
{
...
@@ -89,6 +89,10 @@ export default async (start: ygopro.StocGameMessage.MsgStart) => {
...
@@ -89,6 +89,10 @@ export default async (start: ygopro.StocGameMessage.MsgStart) => {
// note: 额外卡组的卡会在对局开始后通过`UpdateData` msg更新
// note: 额外卡组的卡会在对局开始后通过`UpdateData` msg更新
const
{
duelId
,
index
}
=
(
await
createDuel
())
!
;
matStore
.
duelId
=
duelId
;
matStore
.
agentIndex
=
index
;
if
(
replayStore
.
isReplay
)
{
if
(
replayStore
.
isReplay
)
{
replayStart
();
replayStart
();
}
}
...
...
src/stores/matStore/store.ts
View file @
2bab3140
...
@@ -93,6 +93,8 @@ const initialState: Omit<MatState, "reset"> = {
...
@@ -93,6 +93,8 @@ const initialState: Omit<MatState, "reset"> = {
duelEnd
:
false
,
duelEnd
:
false
,
// methods
// methods
isMe
,
isMe
,
duelId
:
""
,
agentIndex
:
0
};
};
class
MatStore
implements
MatState
,
NeosStore
{
class
MatStore
implements
MatState
,
NeosStore
{
...
@@ -109,6 +111,9 @@ class MatStore implements MatState, NeosStore {
...
@@ -109,6 +111,9 @@ class MatStore implements MatState, NeosStore {
tossResult
=
initialState
.
tossResult
;
tossResult
=
initialState
.
tossResult
;
selectUnselectInfo
=
initialState
.
selectUnselectInfo
;
selectUnselectInfo
=
initialState
.
selectUnselectInfo
;
duelEnd
=
initialState
.
duelEnd
;
duelEnd
=
initialState
.
duelEnd
;
duelId
=
initialState
.
duelId
;
agentIndex
=
initialState
.
agentIndex
;
// methods
// methods
isMe
=
initialState
.
isMe
;
isMe
=
initialState
.
isMe
;
reset
():
void
{
reset
():
void
{
...
...
src/stores/matStore/types.ts
View file @
2bab3140
...
@@ -49,6 +49,9 @@ export interface MatState {
...
@@ -49,6 +49,9 @@ export interface MatState {
/** 根据自己的先后手判断是否是自己 */
/** 根据自己的先后手判断是否是自己 */
isMe
:
(
player
:
number
)
=>
boolean
;
isMe
:
(
player
:
number
)
=>
boolean
;
duelId
:
string
;
agentIndex
:
number
;
}
}
export
interface
InitInfo
{
export
interface
InitInfo
{
...
...
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