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
e0e5c7a6
Commit
e0e5c7a6
authored
Jul 08, 2024
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix package-lock.json and format code
parent
85196568
Pipeline
#28219
passed with stages
in 10 minutes and 39 seconds
Changes
22
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
1115 additions
and
773 deletions
+1115
-773
package-lock.json
package-lock.json
+834
-583
src/api/ygoAgent/predict.ts
src/api/ygoAgent/predict.ts
+1
-1
src/api/ygoAgent/schema.ts
src/api/ygoAgent/schema.ts
+167
-110
src/service/duel/agent.ts
src/service/duel/agent.ts
+50
-38
src/service/duel/announce.ts
src/service/duel/announce.ts
+5
-3
src/service/duel/selectBattleCmd.ts
src/service/duel/selectBattleCmd.ts
+3
-1
src/service/duel/selectCard.ts
src/service/duel/selectCard.ts
+5
-6
src/service/duel/selectChain.ts
src/service/duel/selectChain.ts
+5
-3
src/service/duel/selectEffectYn.ts
src/service/duel/selectEffectYn.ts
+4
-2
src/service/duel/selectIdleCmd.ts
src/service/duel/selectIdleCmd.ts
+5
-3
src/service/duel/selectOption.ts
src/service/duel/selectOption.ts
+4
-2
src/service/duel/selectPlace.ts
src/service/duel/selectPlace.ts
+4
-2
src/service/duel/selectPosition.ts
src/service/duel/selectPosition.ts
+4
-2
src/service/duel/selectSum.ts
src/service/duel/selectSum.ts
+3
-1
src/service/duel/selectTribute.ts
src/service/duel/selectTribute.ts
+3
-1
src/service/duel/selectUnselectCard.ts
src/service/duel/selectUnselectCard.ts
+3
-1
src/service/duel/selectYesNo.ts
src/service/duel/selectYesNo.ts
+4
-2
src/service/duel/sortCard.ts
src/service/duel/sortCard.ts
+1
-1
src/service/duel/start.ts
src/service/duel/start.ts
+7
-8
src/stores/matStore/types.ts
src/stores/matStore/types.ts
+1
-1
src/ui/Duel/PlayMat/Menu/index.tsx
src/ui/Duel/PlayMat/Menu/index.tsx
+1
-1
src/ui/WaitRoom/index.tsx
src/ui/WaitRoom/index.tsx
+1
-1
No files found.
package-lock.json
View file @
e0e5c7a6
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/api/ygoAgent/predict.ts
View file @
e0e5c7a6
...
...
@@ -30,7 +30,7 @@ export async function predictDuel(
):
Promise
<
PredictResp
|
undefined
>
{
const
headers
=
{
...
agentHeader
(),
'
Content-Type
'
:
'
application/json
'
,
"
Content-Type
"
:
"
application/json
"
,
};
const
resp
=
await
fetch
(
`
${
agentServer
}
/
${
apiPath
(
duelId
)}
`
,
{
...
...
src/api/ygoAgent/schema.ts
View file @
e0e5c7a6
This diff is collapsed.
Click to expand it.
src/service/duel/agent.ts
View file @
e0e5c7a6
import
{
PredictReq
,
ygopro
,
sendSelectBattleCmdResponse
,
sendSelectEffectYnResponse
,
sendSelectIdleCmdResponse
,
sendSelectPlaceResponse
,
sendSelectMultiResponse
,
sendSelectSingleResponse
,
sendSelectEffectYnResponse
,
sendSelectPositionResponse
,
sendSelectOptionResponse
,
sendSelectBattleCmdResponse
,
sendSortCardResponse
,
sendSelectPlaceResponse
,
sendSelectPositionResponse
,
sendSelectSingleResponse
,
ygopro
,
}
from
"
@/api
"
;
import
{
cardStore
,
matStore
}
from
"
@/stores
"
;
import
{
predictDuel
}
from
"
@/api/ygoAgent/predict
"
;
import
{
Global
,
convertPhase
,
convertCard
,
convertDeckCard
,
parsePlayerFromMsg
,
convertActionMsg
,
Input
,
MultiSelectMsg
,
MsgSelectSum
convertActionMsg
,
convertCard
,
convertDeckCard
,
convertPhase
,
Global
,
Input
,
MsgSelectSum
,
MultiSelectMsg
,
parsePlayerFromMsg
,
}
from
"
@/api/ygoAgent/schema
"
;
import
{
predictDuel
}
from
"
@/api/ygoAgent/predict
"
;
import
{
cardStore
,
matStore
}
from
"
@/stores
"
;
function
computeSetDifference
(
a1
:
number
[],
a2
:
number
[]):
number
[]
{
const
freq1
=
new
Map
<
number
,
number
>
();
...
...
@@ -44,7 +50,6 @@ function computeSetDifference(a1: number[], a2: number[]): number[] {
return
difference
;
}
export
function
genInput
(
msg
:
ygopro
.
StocGameMessage
):
Input
{
// 全局信息可以从 `matStore` 里面拿
const
mat
=
matStore
;
...
...
@@ -66,23 +71,29 @@ export function genInput(msg: ygopro.StocGameMessage): Input {
const
opponent
=
1
-
player
;
const
cards
=
cardStore
.
inner
.
filter
((
card
)
=>
zones
.
includes
(
card
.
location
.
zone
)
&&
!
(
card
.
location
.
zone
===
ygopro
.
CardZone
.
DECK
&&
card
.
location
.
controller
===
player
)
.
filter
(
(
card
)
=>
zones
.
includes
(
card
.
location
.
zone
)
&&
!
(
card
.
location
.
zone
===
ygopro
.
CardZone
.
DECK
&&
card
.
location
.
controller
===
player
),
)
.
map
((
card
)
=>
convertCard
(
card
,
player
));
const
cardCodesMe
=
cardStore
.
inner
.
filter
((
card
)
=>
zones
.
includes
(
card
.
location
.
zone
)
&&
card
.
location
.
controller
===
player
.
filter
(
(
card
)
=>
zones
.
includes
(
card
.
location
.
zone
)
&&
card
.
location
.
controller
===
player
,
)
.
map
((
card
)
=>
card
.
code
);
const
cardCodesMeDeck
=
computeSetDifference
(
mat
.
mainDeck
,
cardCodesMe
);
const
mainDeckCardMeta
=
mat
.
mainDeckCardMeta
;
// TODO (ygo-agent): 临时方案,有很多边界情况未考虑
const
deckCardsMe
=
cardCodesMeDeck
.
map
((
code
)
=>
convertDeckCard
(
mainDeckCardMeta
.
get
(
code
)
!
));
const
deckCardsMe
=
cardCodesMeDeck
.
map
((
code
)
=>
convertDeckCard
(
mainDeckCardMeta
.
get
(
code
)
!
),
);
const
turnPlayer
=
mat
.
currentPlayer
;
const
global
:
Global
=
{
...
...
@@ -92,7 +103,7 @@ export function genInput(msg: ygopro.StocGameMessage): Input {
op_lp
:
mat
.
initInfo
.
of
(
opponent
).
life
,
phase
:
convertPhase
(
mat
.
phase
.
currentPhase
),
turn
:
mat
.
turnCount
,
}
}
;
const
actionMsg
=
convertActionMsg
(
msg
);
...
...
@@ -100,10 +111,9 @@ export function genInput(msg: ygopro.StocGameMessage): Input {
global
:
global
,
cards
:
deckCardsMe
.
concat
(
cards
),
action_msg
:
actionMsg
,
}
}
;
}
async
function
sendRequest
(
req
:
PredictReq
)
{
console
.
log
(
"
Sending predict request:
"
,
req
);
const
duelId
=
matStore
.
duelId
;
...
...
@@ -111,8 +121,7 @@ async function sendRequest(req: PredictReq) {
console
.
log
(
"
Got predict response:
"
,
resp
);
if
(
resp
!==
undefined
)
{
matStore
.
agentIndex
=
resp
.
index
;
}
else
{
}
else
{
throw
new
Error
(
"
Failed to get predict response
"
);
}
...
...
@@ -143,11 +152,11 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) {
prev_action_idx
:
matStore
.
prevActionIndex
,
};
const
response
=
(
await
sendRequest
(
req
)).
response
;
if
(
response
!=
-
1
)
{
if
(
response
!=
=
-
1
)
{
selected
.
push
(
matStore
.
prevActionIndex
);
responses
.
push
(
response
);
}
if
(
response
==
-
1
||
selected
.
length
==
msg_
.
max
)
{
if
(
response
==
=
-
1
||
selected
.
length
=
==
msg_
.
max
)
{
sendSelectMultiResponse
(
responses
);
break
;
}
...
...
@@ -169,7 +178,7 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) {
prev_action_idx
:
matStore
.
prevActionIndex
,
};
const
pred
=
await
sendRequest
(
req
);
const
idx
=
matStore
.
prevActionIndex
const
idx
=
matStore
.
prevActionIndex
;
selected
.
push
(
idx
);
responses
.
push
(
pred
.
response
);
if
(
pred
.
can_finish
)
{
...
...
@@ -189,7 +198,7 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) {
switch
(
msgName
)
{
case
"
announce_attrib
"
:
case
"
announce_number
"
:
sendSelectOptionResponse
(
response
);
sendSelectOptionResponse
(
response
);
break
;
case
"
select_battlecmd
"
:
sendSelectBattleCmdResponse
(
response
);
...
...
@@ -211,7 +220,8 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) {
sendSelectPositionResponse
(
convertPositionResponse
(
response
));
break
;
case
"
select_place
"
:
{
const
place
=
(
msg
as
unknown
as
ygopro
.
StocGameMessage
.
MsgSelectPlace
).
places
[
response
];
const
place
=
(
msg
as
unknown
as
ygopro
.
StocGameMessage
.
MsgSelectPlace
)
.
places
[
response
];
sendSelectPlaceResponse
({
controller
:
place
.
controller
,
zone
:
place
.
zone
,
...
...
@@ -220,7 +230,7 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) {
break
;
}
case
"
select_unselect_card
"
:
{
if
(
response
==
-
1
)
{
if
(
response
==
=
-
1
)
{
sendSelectSingleResponse
(
-
1
);
}
else
{
sendSelectMultiResponse
([
response
]);
...
...
@@ -231,7 +241,6 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) {
}
}
function
argmax
<
T
>
(
arr
:
T
[],
getValue
:
(
item
:
T
)
=>
number
):
number
{
if
(
arr
.
length
===
0
)
{
throw
new
Error
(
"
Array is empty
"
);
...
...
@@ -251,14 +260,17 @@ function argmax<T>(arr: T[], getValue: (item: T) => number): number {
return
maxIndex
;
}
function
convertPositionResponse
(
response
:
number
):
ygopro
.
CardPosition
{
switch
(
response
)
{
case
0x1
:
return
ygopro
.
CardPosition
.
FACEUP_ATTACK
;
case
0x2
:
return
ygopro
.
CardPosition
.
FACEDOWN_ATTACK
;
case
0x4
:
return
ygopro
.
CardPosition
.
FACEUP_DEFENSE
;
case
0x8
:
return
ygopro
.
CardPosition
.
FACEDOWN_DEFENSE
;
case
0x1
:
return
ygopro
.
CardPosition
.
FACEUP_ATTACK
;
case
0x2
:
return
ygopro
.
CardPosition
.
FACEDOWN_ATTACK
;
case
0x4
:
return
ygopro
.
CardPosition
.
FACEUP_DEFENSE
;
case
0x8
:
return
ygopro
.
CardPosition
.
FACEDOWN_DEFENSE
;
default
:
throw
new
Error
(
`Invalid position response:
${
response
}
`
);
}
}
\ No newline at end of file
}
src/service/duel/announce.ts
View file @
e0e5c7a6
import
{
fetchStrings
,
Region
,
ygopro
}
from
"
@/api
"
;
import
{
displayOptionModal
}
from
"
@/ui/Duel/Message
"
;
import
MsgAnnounce
=
ygopro
.
StocGameMessage
.
MsgAnnounce
;
import
{
displayAnnounceModal
}
from
"
@/ui/Duel/Message/AnnounceModal
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
{
matStore
}
from
"
@/stores
"
;
import
{
displayAnnounceModal
}
from
"
@/ui/Duel/Message/AnnounceModal
"
;
export
default
async
(
announce
:
MsgAnnounce
)
=>
{
if
(
matStore
.
autoSelect
)
{
console
.
log
(
"
intercept announce
"
);
await
sendAIPredictAsResponse
(
announce
as
unknown
as
ygopro
.
StocGameMessage
);
return
;
await
sendAIPredictAsResponse
(
announce
as
unknown
as
ygopro
.
StocGameMessage
,
);
return
;
}
const
type_
=
announce
.
announce_type
;
...
...
src/service/duel/selectBattleCmd.ts
View file @
e0e5c7a6
...
...
@@ -20,7 +20,9 @@ export default async (selectBattleCmd: MsgSelectBattleCmd) => {
if
(
matStore
.
autoSelect
)
{
console
.
log
(
"
intercept selectBattleCmd
"
);
await
sendAIPredictAsResponse
(
selectBattleCmd
as
unknown
as
ygopro
.
StocGameMessage
);
await
sendAIPredictAsResponse
(
selectBattleCmd
as
unknown
as
ygopro
.
StocGameMessage
,
);
return
;
}
...
...
src/service/duel/selectCard.ts
View file @
e0e5c7a6
import
{
sendSelectMultiResponse
,
ygopro
}
from
"
@/api
"
;
import
MsgSelectCard
=
ygopro
.
StocGameMessage
.
MsgSelectCard
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
{
matStore
}
from
"
@/stores
"
;
import
{
displaySelectActionsModal
}
from
"
@/ui/Duel/Message/SelectActionsModal
"
;
import
{
fetchCheckCardMeta
}
from
"
../utils
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
{
matStore
}
from
"
@/stores
"
;
export
default
async
(
selectCard
:
MsgSelectCard
)
=>
{
const
{
cancelable
,
min
,
max
,
cards
}
=
selectCard
;
// TODO: handle release_param
if
(
matStore
.
autoSelect
)
{
console
.
log
(
"
intercept selectCard
"
);
await
sendAIPredictAsResponse
(
selectCard
as
unknown
as
ygopro
.
StocGameMessage
);
await
sendAIPredictAsResponse
(
selectCard
as
unknown
as
ygopro
.
StocGameMessage
,
);
return
;
}
...
...
@@ -26,7 +26,6 @@ export default async (selectCard: MsgSelectCard) => {
return
;
}
const
{
selecteds
,
mustSelects
,
selectables
}
=
await
fetchCheckCardMeta
(
cards
,
);
...
...
src/service/duel/selectChain.ts
View file @
e0e5c7a6
import
{
sendSelectSingleResponse
,
ygopro
}
from
"
@/api
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
{
ChainSetting
,
fetchSelectHintMeta
,
matStore
}
from
"
@/stores
"
;
import
{
displaySelectActionsModal
}
from
"
@/ui/Duel/Message/SelectActionsModal
"
;
import
{
fetchCheckCardMeta
}
from
"
../utils
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
type
MsgSelectChain
=
ygopro
.
StocGameMessage
.
MsgSelectChain
;
export
default
async
(
selectChain
:
MsgSelectChain
)
=>
{
...
...
@@ -69,10 +69,12 @@ export default async (selectChain: MsgSelectChain) => {
case
3
:
{
if
(
matStore
.
autoSelect
)
{
console
.
log
(
"
intercept selectChain
"
);
await
sendAIPredictAsResponse
(
selectChain
as
unknown
as
ygopro
.
StocGameMessage
);
await
sendAIPredictAsResponse
(
selectChain
as
unknown
as
ygopro
.
StocGameMessage
,
);
return
;
}
// 处理强制发动的卡
fetchSelectHintMeta
({
selectHintData
:
203
,
...
...
src/service/duel/selectEffectYn.ts
View file @
e0e5c7a6
import
{
fetchStrings
,
Region
,
type
ygopro
}
from
"
@/api
"
;
import
{
CardMeta
,
fetchCard
}
from
"
@/api/cards
"
;
import
{
displayYesNoModal
}
from
"
@/ui/Duel/Message
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
{
matStore
}
from
"
@/stores
"
;
import
{
displayYesNoModal
}
from
"
@/ui/Duel/Message
"
;
type
MsgSelectEffectYn
=
ygopro
.
StocGameMessage
.
MsgSelectEffectYn
;
...
...
@@ -10,7 +10,9 @@ type MsgSelectEffectYn = ygopro.StocGameMessage.MsgSelectEffectYn;
export
default
async
(
selectEffectYn
:
MsgSelectEffectYn
)
=>
{
if
(
matStore
.
autoSelect
)
{
console
.
log
(
"
intercept selectEffectYn
"
);
await
sendAIPredictAsResponse
(
selectEffectYn
as
unknown
as
ygopro
.
StocGameMessage
);
await
sendAIPredictAsResponse
(
selectEffectYn
as
unknown
as
ygopro
.
StocGameMessage
,
);
return
;
}
...
...
src/service/duel/selectIdleCmd.ts
View file @
e0e5c7a6
import
{
ygopro
}
from
"
@/api
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
{
cardStore
,
type
Interactivity
,
InteractType
,
matStore
,
}
from
"
@/stores
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
MsgSelectIdleCmd
=
ygopro
.
StocGameMessage
.
MsgSelectIdleCmd
;
...
...
@@ -20,10 +20,12 @@ export default async (selectIdleCmd: MsgSelectIdleCmd) => {
if
(
matStore
.
autoSelect
)
{
console
.
log
(
"
intercept selectIdleCmd
"
);
await
sendAIPredictAsResponse
(
selectIdleCmd
as
unknown
as
ygopro
.
StocGameMessage
);
await
sendAIPredictAsResponse
(
selectIdleCmd
as
unknown
as
ygopro
.
StocGameMessage
,
);
return
;
}
cmds
.
forEach
((
cmd
)
=>
{
const
interactType
=
idleTypeToInteractType
(
cmd
.
idle_type
);
...
...
src/service/duel/selectOption.ts
View file @
e0e5c7a6
...
...
@@ -5,9 +5,9 @@ import {
sendSelectOptionResponse
,
type
ygopro
,
}
from
"
@/api
"
;
import
{
displayOptionModal
}
from
"
@/ui/Duel/Message
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
{
matStore
}
from
"
@/stores
"
;
import
{
displayOptionModal
}
from
"
@/ui/Duel/Message
"
;
export
default
async
(
selectOption
:
ygopro
.
StocGameMessage
.
MsgSelectOption
)
=>
{
const
options
=
selectOption
.
options
;
...
...
@@ -18,7 +18,9 @@ export default async (selectOption: ygopro.StocGameMessage.MsgSelectOption) => {
if
(
matStore
.
autoSelect
)
{
console
.
log
(
"
intercept selectOption
"
);
await
sendAIPredictAsResponse
(
selectOption
as
unknown
as
ygopro
.
StocGameMessage
);
await
sendAIPredictAsResponse
(
selectOption
as
unknown
as
ygopro
.
StocGameMessage
,
);
return
;
}
...
...
src/service/duel/selectPlace.ts
View file @
e0e5c7a6
import
{
sendSelectPlaceResponse
,
ygopro
}
from
"
@/api
"
;
import
{
InteractType
,
placeStore
,
matStore
}
from
"
@/stores
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
{
InteractType
,
matStore
,
placeStore
}
from
"
@/stores
"
;
type
MsgSelectPlace
=
ygopro
.
StocGameMessage
.
MsgSelectPlace
;
...
...
@@ -12,7 +12,9 @@ export default async (selectPlace: MsgSelectPlace) => {
if
(
matStore
.
autoSelect
)
{
console
.
log
(
"
intercept selectPlace
"
);
await
sendAIPredictAsResponse
(
selectPlace
as
unknown
as
ygopro
.
StocGameMessage
);
await
sendAIPredictAsResponse
(
selectPlace
as
unknown
as
ygopro
.
StocGameMessage
,
);
return
;
}
...
...
src/service/duel/selectPosition.ts
View file @
e0e5c7a6
import
{
ygopro
}
from
"
@/api
"
;
import
{
displayPositionModal
}
from
"
@/ui/Duel/Message
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
{
matStore
}
from
"
@/stores
"
;
import
{
displayPositionModal
}
from
"
@/ui/Duel/Message
"
;
type
MsgSelectPosition
=
ygopro
.
StocGameMessage
.
MsgSelectPosition
;
export
default
async
(
selectPosition
:
MsgSelectPosition
)
=>
{
if
(
matStore
.
autoSelect
)
{
console
.
log
(
"
intercept selectPosition
"
);
await
sendAIPredictAsResponse
(
selectPosition
as
unknown
as
ygopro
.
StocGameMessage
);
await
sendAIPredictAsResponse
(
selectPosition
as
unknown
as
ygopro
.
StocGameMessage
,
);
return
;
}
...
...
src/service/duel/selectSum.ts
View file @
e0e5c7a6
...
...
@@ -10,7 +10,9 @@ import { matStore } from "@/stores";
export
default
async
(
selectSum
:
MsgSelectSum
)
=>
{
if
(
matStore
.
autoSelect
)
{
console
.
log
(
"
intercept selectSum
"
);
await
sendAIPredictAsResponse
(
selectSum
as
unknown
as
ygopro
.
StocGameMessage
);
await
sendAIPredictAsResponse
(
selectSum
as
unknown
as
ygopro
.
StocGameMessage
,
);
return
;
}
...
...
src/service/duel/selectTribute.ts
View file @
e0e5c7a6
...
...
@@ -10,7 +10,9 @@ import { matStore } from "@/stores";
export
default
async
(
selectTribute
:
MsgSelectTribute
)
=>
{
if
(
matStore
.
autoSelect
)
{
console
.
log
(
"
intercept selectTribute
"
);
await
sendAIPredictAsResponse
(
selectTribute
as
unknown
as
ygopro
.
StocGameMessage
);
await
sendAIPredictAsResponse
(
selectTribute
as
unknown
as
ygopro
.
StocGameMessage
,
);
return
;
}
...
...
src/service/duel/selectUnselectCard.ts
View file @
e0e5c7a6
...
...
@@ -11,7 +11,9 @@ import { sendAIPredictAsResponse } from "@/service/duel/agent";
export
default
async
(
selectUnselectCards
:
MsgSelectUnselectCard
)
=>
{
if
(
matStore
.
autoSelect
)
{
console
.
log
(
"
intercept selectUnselectCards
"
);
await
sendAIPredictAsResponse
(
selectUnselectCards
as
unknown
as
ygopro
.
StocGameMessage
);
await
sendAIPredictAsResponse
(
selectUnselectCards
as
unknown
as
ygopro
.
StocGameMessage
,
);
return
;
}
...
...
src/service/duel/selectYesNo.ts
View file @
e0e5c7a6
import
{
getStrings
,
ygopro
}
from
"
@/api
"
;
import
{
displayYesNoModal
}
from
"
@/ui/Duel/Message
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
{
matStore
}
from
"
@/stores
"
;
import
{
displayYesNoModal
}
from
"
@/ui/Duel/Message
"
;
type
MsgSelectYesNo
=
ygopro
.
StocGameMessage
.
MsgSelectYesNo
;
export
default
async
(
selectYesNo
:
MsgSelectYesNo
)
=>
{
if
(
matStore
.
autoSelect
)
{
console
.
log
(
"
intercept selectYesNo
"
);
await
sendAIPredictAsResponse
(
selectYesNo
as
unknown
as
ygopro
.
StocGameMessage
);
await
sendAIPredictAsResponse
(
selectYesNo
as
unknown
as
ygopro
.
StocGameMessage
,
);
return
;
}
...
...
src/service/duel/sortCard.ts
View file @
e0e5c7a6
import
{
fetchCard
,
ygopro
}
from
"
@/api
"
;
import
{
displaySortCardModal
}
from
"
@/ui/Duel/Message
"
;
import
{
matStore
}
from
"
@/stores
"
;
import
{
displaySortCardModal
}
from
"
@/ui/Duel/Message
"
;
type
MsgSortCard
=
ygopro
.
StocGameMessage
.
MsgSortCard
;
...
...
src/service/duel/start.ts
View file @
e0e5c7a6
import
{
flatten
}
from
"
lodash-es
"
;
import
{
v4
as
v4uuid
}
from
"
uuid
"
;
import
{
createDuel
,
ygopro
,
fetchCard
}
from
"
@/api
"
;
import
{
createDuel
,
fetchCard
,
ygopro
}
from
"
@/api
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
sleep
}
from
"
@/infra
"
;
import
{
...
...
@@ -92,13 +92,12 @@ export default async (start: ygopro.StocGameMessage.MsgStart) => {
const
{
duelId
,
index
}
=
(
await
createDuel
())
!
;
matStore
.
duelId
=
duelId
;
matStore
.
agentIndex
=
index
;
matStore
.
mainDeckCardMeta
=
matStore
.
mainDeck
.
reduce
((
map
,
item
)
=>
{
if
(
!
map
.
has
(
item
))
{
map
.
set
(
item
,
fetchCard
(
item
));
}
return
map
;
},
new
Map
());
matStore
.
mainDeckCardMeta
=
matStore
.
mainDeck
.
reduce
((
map
,
item
)
=>
{
if
(
!
map
.
has
(
item
))
{
map
.
set
(
item
,
fetchCard
(
item
));
}
return
map
;
},
new
Map
());
if
(
replayStore
.
isReplay
)
{
replayStart
();
...
...
src/stores/matStore/types.ts
View file @
e0e5c7a6
...
...
@@ -50,7 +50,7 @@ export interface MatState {
/** 根据自己的先后手判断是否是自己 */
isMe
:
(
player
:
number
)
=>
boolean
;
turnCount
:
number
,
turnCount
:
number
;
duelId
:
string
;
agentIndex
:
number
;
prevActionIndex
:
number
;
...
...
src/ui/Duel/PlayMat/Menu/index.tsx
View file @
e0e5c7a6
...
...
@@ -3,9 +3,9 @@ import {
CheckOutlined
,
CloseCircleFilled
,
MessageFilled
,
StepForwardFilled
,
RobotFilled
,
RobotOutlined
,
StepForwardFilled
,
}
from
"
@ant-design/icons
"
;
import
{
Button
,
...
...
src/ui/WaitRoom/index.tsx
View file @
e0e5c7a6
...
...
@@ -27,12 +27,12 @@ import {
accountStore
,
deckStore
,
IDeck
,
matStore
,
Player
,
resetUniverse
,
RoomStage
,
roomStore
,
sideStore
,
matStore
,
}
from
"
@/stores
"
;
import
{
Background
,
IconFont
,
Select
,
SpecialButton
}
from
"
@/ui/Shared
"
;
...
...
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