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
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
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
Biluo Shen
Neos
Commits
bde80f6a
Commit
bde80f6a
authored
Jul 05, 2024
by
biluo.shen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use msg_type to replace msg_name
parent
437233f8
Pipeline
#28122
failed with stages
in 26 seconds
Changes
16
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
168 additions
and
154 deletions
+168
-154
src/api/ygoAgent/schema.ts
src/api/ygoAgent/schema.ts
+54
-37
src/service/duel/agent.ts
src/service/duel/agent.ts
+33
-23
src/service/duel/announce.ts
src/service/duel/announce.ts
+5
-0
src/service/duel/gameMsg.ts
src/service/duel/gameMsg.ts
+1
-69
src/service/duel/newTurn.ts
src/service/duel/newTurn.ts
+1
-0
src/service/duel/selectBattleCmd.ts
src/service/duel/selectBattleCmd.ts
+6
-1
src/service/duel/selectCard.ts
src/service/duel/selectCard.ts
+8
-0
src/service/duel/selectChain.ts
src/service/duel/selectChain.ts
+5
-0
src/service/duel/selectEffectYn.ts
src/service/duel/selectEffectYn.ts
+5
-0
src/service/duel/selectIdleCmd.ts
src/service/duel/selectIdleCmd.ts
+6
-5
src/service/duel/selectOption.ts
src/service/duel/selectOption.ts
+5
-0
src/service/duel/selectPlace.ts
src/service/duel/selectPlace.ts
+24
-19
src/service/duel/selectPosition.ts
src/service/duel/selectPosition.ts
+5
-0
src/service/duel/selectYesNo.ts
src/service/duel/selectYesNo.ts
+5
-0
src/stores/matStore/store.ts
src/stores/matStore/store.ts
+3
-0
src/stores/matStore/types.ts
src/stores/matStore/types.ts
+2
-0
No files found.
src/api/ygoAgent/schema.ts
View file @
bde80f6a
...
...
@@ -470,6 +470,7 @@ interface SelectAbleCard {
}
interface
MsgSelectCard
{
msg_type
:
"
select_card
"
;
cancelable
:
boolean
;
min
:
number
;
max
:
number
;
...
...
@@ -478,8 +479,9 @@ interface MsgSelectCard {
}
function
convertMsgSelectCard
(
msg
:
GM
.
MsgSelectCard
):
MsgSelectCard
{
// response is -1 for finish
return
{
// response is -1 for finish
return
{
msg_type
:
"
select_card
"
,
cancelable
:
msg
.
cancelable
,
min
:
msg
.
min
,
max
:
msg
.
max
,
...
...
@@ -499,6 +501,7 @@ interface SelectTributeCard {
}
interface
MsgSelectTribute
{
msg_type
:
"
select_tribute
"
;
cancelable
:
boolean
;
min
:
number
;
max
:
number
;
...
...
@@ -508,6 +511,7 @@ interface MsgSelectTribute {
function
convertMsgSelectTribute
(
msg
:
GM
.
MsgSelectTribute
):
MsgSelectTribute
{
return
{
msg_type
:
"
select_tribute
"
,
cancelable
:
msg
.
cancelable
,
min
:
msg
.
min
,
max
:
msg
.
max
,
...
...
@@ -529,6 +533,7 @@ interface SelectSumCard {
}
interface
MsgSelectSum
{
msg_type
:
"
select_sum
"
;
overflow
:
boolean
;
level_sum
:
number
;
min
:
number
;
...
...
@@ -540,6 +545,7 @@ interface MsgSelectSum {
function
convertMsgSelectSum
(
msg
:
GM
.
MsgSelectSum
):
MsgSelectSum
{
return
{
msg_type
:
"
select_sum
"
,
overflow
:
msg
.
overflow
!=
0
,
level_sum
:
msg
.
level_sum
,
min
:
msg
.
min
,
...
...
@@ -625,6 +631,7 @@ interface IdleCmd {
}
interface
MsgSelectIdleCmd
{
msg_type
:
"
select_idlecmd
"
;
idle_cmds
:
IdleCmd
[];
}
...
...
@@ -662,7 +669,10 @@ function convertMsgSelectIdleCmd(msg: GM.MsgSelectIdleCmd): MsgSelectIdleCmd {
// response will be 7
idle_cmds
.
push
({
cmd_type
:
IdleCmdType
.
ToEp
});
}
return
{
idle_cmds
};
return
{
msg_type
:
"
select_idlecmd
"
,
idle_cmds
:
idle_cmds
,
};
}
interface
Chain
{
...
...
@@ -673,6 +683,7 @@ interface Chain {
}
interface
MsgSelectChain
{
msg_type
:
"
select_chain
"
;
forced
:
boolean
;
chains
:
Chain
[];
}
...
...
@@ -689,18 +700,21 @@ function convertChain(chain: GM.MsgSelectChain.Chain, player: number): Chain {
function
convertMsgSelectChain
(
msg
:
GM
.
MsgSelectChain
):
MsgSelectChain
{
// response is -1 for cancel
return
{
msg_type
:
"
select_chain
"
,
forced
:
msg
.
forced
,
chains
:
msg
.
chains
.
map
(
c
=>
convertChain
(
c
,
msg
.
player
)),
};
}
interface
MsgSelectPosition
{
msg_type
:
"
select_position
"
;
code
:
number
;
positions
:
Position
[];
}
function
convertMsgSelectPosition
(
msg
:
GM
.
MsgSelectPosition
):
MsgSelectPosition
{
return
{
msg_type
:
"
select_position
"
,
code
:
msg
.
code
,
// response will be equal to POS_* from ocgcore
// POS_FACEUP_ATTACK: 0x1, POS_FACEDOWN_ATTACK: 0x2,
...
...
@@ -710,17 +724,20 @@ function convertMsgSelectPosition(msg: GM.MsgSelectPosition): MsgSelectPosition
}
interface
MsgSelectYesNo
{
msg_type
:
"
select_yes_no
"
;
effect_description
:
number
;
}
function
convertMsgSelectYesNo
(
msg
:
GM
.
MsgSelectYesNo
):
MsgSelectYesNo
{
// response is 1 for yes and 0 for no
return
{
msg_type
:
"
select_yes_no
"
,
effect_description
:
msg
.
effect_description
,
};
}
interface
MsgSelectEffectYn
{
msg_type
:
"
select_effect_yn
"
;
code
:
number
;
location
:
CardLocation
;
effect_description
:
number
;
...
...
@@ -729,6 +746,7 @@ interface MsgSelectEffectYn {
function
convertMsgSelectEffectYn
(
msg
:
GM
.
MsgSelectEffectYn
):
MsgSelectEffectYn
{
// response is 1 for yes and 0 for no
return
{
msg_type
:
"
select_effect_yn
"
,
code
:
msg
.
code
,
location
:
convertCardLocation
(
msg
.
location
,
msg
.
player
),
effect_description
:
msg
.
effect_description
,
...
...
@@ -767,6 +785,7 @@ interface BattleCmd {
}
interface
MsgSelectBattleCmd
{
msg_type
:
"
select_battlecmd
"
;
battle_cmds
:
BattleCmd
[];
}
...
...
@@ -792,7 +811,10 @@ function convertMsgSelectBattleCmd(msg: GM.MsgSelectBattleCmd): MsgSelectBattleC
// response will be 3
battle_cmds
.
push
({
cmd_type
:
BattleCmdType
.
ToEp
});
}
return
{
battle_cmds
};
return
{
msg_type
:
"
select_battlecmd
"
,
battle_cmds
,
};
}
...
...
@@ -803,6 +825,7 @@ interface SelectUnselectCard {
interface
MsgSelectUnselectCard
{
msg_type
:
"
select_unselect_card
"
;
finishable
:
boolean
;
cancelable
:
boolean
;
min
:
number
;
...
...
@@ -813,6 +836,7 @@ interface MsgSelectUnselectCard {
function
convertMsgSelectUnselectCard
(
msg
:
GM
.
MsgSelectUnselectCard
):
MsgSelectUnselectCard
{
return
{
msg_type
:
"
select_unselect_card
"
,
// response is -1 for finish
finishable
:
msg
.
finishable
,
cancelable
:
msg
.
cancelable
,
...
...
@@ -835,11 +859,13 @@ interface Option {
}
interface
MsgSelectOption
{
msg_type
:
"
select_option
"
;
options
:
Option
[];
}
function
convertMsgSelectOption
(
msg
:
GM
.
MsgSelectOption
):
MsgSelectOption
{
return
{
msg_type
:
"
select_option
"
,
options
:
msg
.
options
.
map
(
o
=>
({
code
:
o
.
code
,
response
:
o
.
response
,
...
...
@@ -855,15 +881,17 @@ interface Place {
}
interface
MsgSelectPlace
{
msg_type
:
"
select_place
"
;
count
:
number
;
places
:
Place
[];
}
function
convertMsgSelectPlace
(
msg
:
GM
.
MsgSelectPlace
):
MsgSelectPlace
{
return
{
msg_type
:
"
select_place
"
,
count
:
msg
.
count
,
places
:
msg
.
places
.
map
(
p
=>
({
// NOTICE: the response is
all -1
// NOTICE: the response is
the index of the place in the places array
controller
:
convertController
(
p
.
controller
,
msg
.
player
),
location
:
cardZoneToLocation
(
p
.
zone
),
sequence
:
p
.
sequence
,
...
...
@@ -879,12 +907,14 @@ interface AnnounceAttrib {
}
interface
MsgAnnounceAttrib
{
msg_type
:
"
announce_attrib
"
;
count
:
number
;
attributes
:
AnnounceAttrib
[];
}
function
convertMsgAnnounceAttrib
(
msg
:
GM
.
MsgAnnounce
):
MsgAnnounceAttrib
{
return
{
msg_type
:
"
announce_attrib
"
,
count
:
msg
.
min
,
// from api/ocgcore/ocgAdapter/stoc/stocGameMsg/announceAttrib.ts
attributes
:
msg
.
options
.
map
(
a
=>
({
...
...
@@ -900,12 +930,14 @@ interface AnnounceNumber {
}
interface
MsgAnnounceNumber
{
msg_type
:
"
announce_number
"
;
count
:
number
;
numbers
:
AnnounceNumber
[];
}
function
convertMsgAnnounceNumber
(
msg
:
GM
.
MsgAnnounce
):
MsgAnnounceNumber
{
return
{
msg_type
:
"
announce_number
"
,
count
:
msg
.
min
,
numbers
:
msg
.
options
.
map
(
o
=>
({
number
:
o
.
code
,
...
...
@@ -930,99 +962,84 @@ type ActionMsgData =
MsgAnnounceAttrib
|
MsgAnnounceNumber
;
export
enum
ActionMsgName
{
AnnounceAttrib
=
"
announce_attrib
"
,
AnnounceNumber
=
"
announce_number
"
,
SelectBattlecmd
=
"
select_battlecmd
"
,
SelectCard
=
"
select_card
"
,
SelectChain
=
"
select_chain
"
,
SelectDisfield
=
"
select_disfield
"
,
SelectEffectyn
=
"
select_effectyn
"
,
SelectIdlecmd
=
"
select_idlecmd
"
,
SelectOption
=
"
select_option
"
,
SelectPlace
=
"
select_place
"
,
SelectPosition
=
"
select_position
"
,
SelectSum
=
"
select_sum
"
,
SelectTribute
=
"
select_tribute
"
,
SelectUnselectCard
=
"
select_unselect_card
"
,
SelectYesno
=
"
select_yesno
"
,
}
//
export enum ActionMsgName {
//
AnnounceAttrib = "announce_attrib",
//
AnnounceNumber = "announce_number",
//
SelectBattlecmd = "select_battlecmd",
//
SelectCard = "select_card",
//
SelectChain = "select_chain",
//
SelectDisfield = "select_disfield",
//
SelectEffectyn = "select_effectyn",
//
SelectIdlecmd = "select_idlecmd",
//
SelectOption = "select_option",
//
SelectPlace = "select_place",
//
SelectPosition = "select_position",
//
SelectSum = "select_sum",
//
SelectTribute = "select_tribute",
//
SelectUnselectCard = "select_unselect_card",
//
SelectYesno = "select_yesno",
//
}
interface
ActionMsg
{
data
:
ActionMsgData
;
name
:
ActionMsgName
;
}
export
function
convertActionMsg
(
msg
:
ygopro
.
StocGameMessage
):
ActionMsg
{
if
(
msg
instanceof
GM
.
MsgSelectCard
)
{
return
{
name
:
ActionMsgName
.
SelectCard
,
data
:
convertMsgSelectCard
(
msg
),
};
}
else
if
(
msg
instanceof
GM
.
MsgSelectTribute
)
{
return
{
name
:
ActionMsgName
.
SelectTribute
,
data
:
convertMsgSelectTribute
(
msg
),
};
}
else
if
(
msg
instanceof
GM
.
MsgSelectSum
)
{
return
{
name
:
ActionMsgName
.
SelectSum
,
data
:
convertMsgSelectSum
(
msg
),
};
}
else
if
(
msg
instanceof
GM
.
MsgSelectIdleCmd
)
{
return
{
name
:
ActionMsgName
.
SelectIdlecmd
,
data
:
convertMsgSelectIdleCmd
(
msg
),
};
}
else
if
(
msg
instanceof
GM
.
MsgSelectChain
)
{
return
{
name
:
ActionMsgName
.
SelectChain
,
data
:
convertMsgSelectChain
(
msg
),
};
}
else
if
(
msg
instanceof
GM
.
MsgSelectPosition
)
{
return
{
name
:
ActionMsgName
.
SelectPosition
,
data
:
convertMsgSelectPosition
(
msg
),
};
}
else
if
(
msg
instanceof
GM
.
MsgSelectEffectYn
)
{
return
{
name
:
ActionMsgName
.
SelectEffectyn
,
data
:
convertMsgSelectEffectYn
(
msg
),
};
}
else
if
(
msg
instanceof
GM
.
MsgSelectYesNo
)
{
return
{
name
:
ActionMsgName
.
SelectYesno
,
data
:
convertMsgSelectYesNo
(
msg
),
};
}
else
if
(
msg
instanceof
GM
.
MsgSelectBattleCmd
)
{
return
{
name
:
ActionMsgName
.
SelectBattlecmd
,
data
:
convertMsgSelectBattleCmd
(
msg
),
};
}
else
if
(
msg
instanceof
GM
.
MsgSelectUnselectCard
)
{
return
{
name
:
ActionMsgName
.
SelectUnselectCard
,
data
:
convertMsgSelectUnselectCard
(
msg
),
};
}
else
if
(
msg
instanceof
GM
.
MsgSelectOption
)
{
return
{
name
:
ActionMsgName
.
SelectOption
,
data
:
convertMsgSelectOption
(
msg
),
};
}
else
if
(
msg
instanceof
GM
.
MsgSelectPlace
)
{
return
{
name
:
ActionMsgName
.
SelectPlace
,
data
:
convertMsgSelectPlace
(
msg
),
};
}
else
if
(
msg
instanceof
GM
.
MsgAnnounce
)
{
if
(
msg
.
announce_type
==
GM
.
MsgAnnounce
.
AnnounceType
.
Attribute
)
{
return
{
name
:
ActionMsgName
.
AnnounceAttrib
,
data
:
convertMsgAnnounceAttrib
(
msg
),
};
}
else
if
(
msg
.
announce_type
==
GM
.
MsgAnnounce
.
AnnounceType
.
Number
)
{
return
{
name
:
ActionMsgName
.
AnnounceNumber
,
data
:
convertMsgAnnounceNumber
(
msg
),
};
}
else
{
...
...
src/service/duel/agent.ts
View file @
bde80f6a
...
...
@@ -12,7 +12,7 @@ import {
sendSortCardResponse
,
}
from
"
@/api
"
;
import
{
cardStore
,
matStore
}
from
"
@/stores
"
;
import
{
ActionMsgName
,
Global
,
convertPhase
,
convertCard
,
convertDeckCard
,
parsePlayerFromMsg
,
convertActionMsg
,
Input
}
from
"
@/api/ygoAgent/schema
"
;
import
{
Global
,
convertPhase
,
convertCard
,
convertDeckCard
,
parsePlayerFromMsg
,
convertActionMsg
,
Input
}
from
"
@/api/ygoAgent/schema
"
;
import
{
predictDuel
}
from
"
@/api/ygoAgent/predict
"
;
function
computeSetDifference
(
a1
:
number
[],
a2
:
number
[]):
number
[]
{
...
...
@@ -89,8 +89,7 @@ export function genPredictReq(msg: ygopro.StocGameMessage): PredictReq {
my_lp
:
mat
.
initInfo
.
of
(
player
).
life
,
op_lp
:
mat
.
initInfo
.
of
(
opponent
).
life
,
phase
:
convertPhase
(
mat
.
phase
.
currentPhase
),
// TODO (ygo-agent): use real turn
turn
:
1
,
turn
:
mat
.
turn_count
,
}
const
actionMsg
=
convertActionMsg
(
msg
);
...
...
@@ -104,14 +103,13 @@ export function genPredictReq(msg: ygopro.StocGameMessage): PredictReq {
return
{
index
:
mat
.
agentIndex
,
input
:
input
,
// TODO (ygo-agent): use real value
prev_action_idx
:
mat
.
prevActionIndex
,
}
}
export
async
function
sendAIPredictAsResponse
()
{
const
msg
=
matStore
.
actionMsg
;
export
async
function
sendAIPredictAsResponse
(
msg
:
ygopro
.
StocGameMessage
)
{
//
const msg = matStore.actionMsg;
const
req
=
genPredictReq
(
msg
);
console
.
log
(
"
Sending predict request:
"
,
req
);
const
duelId
=
matStore
.
duelId
;
...
...
@@ -129,38 +127,50 @@ export async function sendAIPredictAsResponse() {
const
action_idx
=
argmax
(
preds
,
(
r
)
=>
r
.
prob
);
matStore
.
prevActionIndex
=
action_idx
;
const
response
=
preds
[
action_idx
].
response
;
const
msg_name
=
req
.
input
.
action_msg
.
nam
e
;
const
msg_name
=
req
.
input
.
action_msg
.
data
.
msg_typ
e
;
switch
(
msg_name
)
{
case
ActionMsgName
.
AnnounceAttrib
:
case
ActionMsgName
.
AnnounceNumber
:
case
"
announce_attrib
"
:
case
"
announce_number
"
:
sendSelectOptionResponse
(
response
);
break
;
case
ActionMsgName
.
SelectBattlecmd
:
case
"
select_battle_cmd
"
:
sendSelectBattleCmdResponse
(
response
);
break
;
case
ActionMsgName
.
SelectChain
:
case
"
select_chain
"
:
sendSelectSingleResponse
(
response
);
break
;
case
ActionMsgName
.
SelectYesno
:
case
ActionMsgName
.
SelectEffectyn
:
case
"
select_yes_no
"
:
case
"
select_effect_yn
"
:
sendSelectEffectYnResponse
(
response
===
1
);
break
;
case
ActionMsgName
.
SelectIdlecmd
:
case
"
select_idle_cmd
"
:
sendSelectIdleCmdResponse
(
response
);
break
;
case
ActionMsgName
.
SelectOption
:
case
"
select_option
"
:
sendSelectOptionResponse
(
response
);
break
;
case
ActionMsgName
.
SelectPosition
:
case
"
select_position
"
:
sendSelectPositionResponse
(
convertPositionResponse
(
response
));
break
;
case
ActionMsgName
.
SelectUnselectCard
:
case
ActionMsgName
.
SelectDisfield
:
case
ActionMsgName
.
SelectPlace
:
case
ActionMsgName
.
SelectCard
:
case
ActionMsgName
.
SelectSum
:
case
ActionMsgName
.
SelectTribute
:
default
:
case
"
select_place
"
:
const
place
=
(
msg
as
unknown
as
ygopro
.
StocGameMessage
.
MsgSelectPlace
).
places
[
response
];
sendSelectPlaceResponse
({
controller
:
place
.
controller
,
zone
:
place
.
zone
,
sequence
:
place
.
sequence
,
});
break
;
case
"
select_unselect_card
"
:
case
"
select_card
"
:
const
msg_
=
msg
as
unknown
as
ygopro
.
StocGameMessage
.
MsgSelectCard
;
if
(
msg_
.
min
===
1
&&
msg_
.
max
===
1
)
{
sendSelectMultiResponse
([
response
]);
}
else
{
throw
new
Error
(
`Unsupported select_card for min=
${
msg_
.
min
}
, max=
${
msg_
.
max
}
`
);
}
break
;
case
"
select_sum
"
:
case
"
select_tribute
"
:
throw
new
Error
(
`Unsupported msg_name:
${
msg_name
}
`
);
}
}
...
...
src/service/duel/announce.ts
View file @
bde80f6a
...
...
@@ -2,8 +2,13 @@ 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
"
;
export
default
async
(
announce
:
MsgAnnounce
)
=>
{
console
.
log
(
"
intercept announce
"
);
await
sendAIPredictAsResponse
(
announce
as
unknown
as
ygopro
.
StocGameMessage
);
return
;
const
type_
=
announce
.
announce_type
;
let
min
=
announce
.
min
;
if
(
...
...
src/service/duel/gameMsg.ts
View file @
bde80f6a
import
{
ygopro
}
from
"
@/api
"
;
import
{
matStore
,
replayStore
}
from
"
@/stores
"
;
import
{
replayStore
}
from
"
@/stores
"
;
import
{
showWaiting
}
from
"
@/ui/Duel/Message
"
;
import
onAnnounce
from
"
./announce
"
;
...
...
@@ -100,74 +100,6 @@ export default async function handleGameMsg(
if
(
replayStore
.
isReplay
&&
ReplayIgnoreMsg
.
includes
(
msg
.
gameMsg
))
return
;
console
.
log
(
"
Got
"
+
msg
.
gameMsg
);
switch
(
msg
.
gameMsg
)
{
case
"
announce
"
:
{
matStore
.
actionMsg
=
msg
.
announce
;
console
.
log
(
"
intercept announce
"
);
return
;
}
case
"
select_battle_cmd
"
:
{
matStore
.
actionMsg
=
msg
.
select_battle_cmd
;
console
.
log
(
"
intercept select_battle_cmd
"
);
return
;
}
case
"
select_chain
"
:
{
matStore
.
actionMsg
=
msg
.
select_chain
;
console
.
log
(
"
intercept select_chain
"
);
return
;
}
case
"
select_yes_no
"
:
{
matStore
.
actionMsg
=
msg
.
select_yes_no
;
console
.
log
(
"
intercept select_yes_no
"
);
return
;
}
case
"
select_effect_yn
"
:
{
matStore
.
actionMsg
=
msg
.
select_effect_yn
;
console
.
log
(
"
intercept select_effect_yn
"
);
return
;
}
case
"
select_idle_cmd
"
:
{
matStore
.
actionMsg
=
msg
.
select_idle_cmd
;
console
.
log
(
"
intercept select_idle_cmd
"
);
return
;
}
case
"
select_option
"
:
{
matStore
.
actionMsg
=
msg
.
select_option
;
console
.
log
(
"
intercept select_option
"
);
return
;
}
case
"
select_position
"
:
{
matStore
.
actionMsg
=
msg
.
select_position
;
console
.
log
(
"
intercept select_position
"
);
return
;
}
case
"
select_unselect_card
"
:
{
matStore
.
actionMsg
=
msg
.
select_unselect_card
;
break
;
}
case
"
select_place
"
:
{
matStore
.
actionMsg
=
msg
.
select_place
;
break
;
}
case
"
select_card
"
:
{
matStore
.
actionMsg
=
msg
.
select_card
;
break
;
}
case
"
select_sum
"
:
{
matStore
.
actionMsg
=
msg
.
select_sum
;
break
;
}
case
"
select_tribute
"
:
{
matStore
.
actionMsg
=
msg
.
select_tribute
;
break
;
}
default
:
{
break
;
}
}
switch
(
msg
.
gameMsg
)
{
case
"
start
"
:
{
await
onMsgStart
(
msg
.
start
);
...
...
src/service/duel/newTurn.ts
View file @
bde80f6a
...
...
@@ -6,4 +6,5 @@ export default (newTurn: ygopro.StocGameMessage.MsgNewTurn) => {
playEffect
(
AudioActionType
.
SOUND_NEXT_TURN
);
const
player
=
newTurn
.
player
;
matStore
.
currentPlayer
=
player
;
matStore
.
turn_count
=
matStore
.
turn_count
+
1
;
};
src/service/duel/selectBattleCmd.ts
View file @
bde80f6a
...
...
@@ -7,8 +7,9 @@ import {
}
from
"
@/stores
"
;
import
MsgSelectBattleCmd
=
ygopro
.
StocGameMessage
.
MsgSelectBattleCmd
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
export
default
(
selectBattleCmd
:
MsgSelectBattleCmd
)
=>
{
export
default
async
(
selectBattleCmd
:
MsgSelectBattleCmd
)
=>
{
const
player
=
selectBattleCmd
.
player
;
const
cmds
=
selectBattleCmd
.
battle_cmds
;
...
...
@@ -17,6 +18,10 @@ export default (selectBattleCmd: MsgSelectBattleCmd) => {
card
.
idleInteractivities
=
[];
});
console
.
log
(
"
intercept selectBattleCmd
"
);
await
sendAIPredictAsResponse
(
selectBattleCmd
as
unknown
as
ygopro
.
StocGameMessage
);
return
;
cmds
.
forEach
((
cmd
)
=>
{
const
interactType
=
battleTypeToInteracType
(
cmd
.
battle_type
);
...
...
src/service/duel/selectCard.ts
View file @
bde80f6a
...
...
@@ -5,6 +5,8 @@ import { displaySelectActionsModal } from "@/ui/Duel/Message/SelectActionsModal"
import
{
fetchCheckCardMeta
}
from
"
../utils
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
export
default
async
(
selectCard
:
MsgSelectCard
)
=>
{
const
{
cancelable
,
min
,
max
,
cards
}
=
selectCard
;
...
...
@@ -16,6 +18,12 @@ export default async (selectCard: MsgSelectCard) => {
return
;
}
if
(
min
===
1
&&
max
===
1
)
{
console
.
log
(
"
intercept selectCard
"
);
await
sendAIPredictAsResponse
(
selectCard
as
unknown
as
ygopro
.
StocGameMessage
);
return
;
}
const
{
selecteds
,
mustSelects
,
selectables
}
=
await
fetchCheckCardMeta
(
cards
,
);
...
...
src/service/duel/selectChain.ts
View file @
bde80f6a
...
...
@@ -3,6 +3,7 @@ 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
)
=>
{
...
...
@@ -66,6 +67,10 @@ export default async (selectChain: MsgSelectChain) => {
}
case
2
:
// 处理多张
case
3
:
{
console
.
log
(
"
intercept selectChain
"
);
await
sendAIPredictAsResponse
(
selectChain
as
unknown
as
ygopro
.
StocGameMessage
);
return
;
// 处理强制发动的卡
fetchSelectHintMeta
({
selectHintData
:
203
,
...
...
src/service/duel/selectEffectYn.ts
View file @
bde80f6a
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
"
;
type
MsgSelectEffectYn
=
ygopro
.
StocGameMessage
.
MsgSelectEffectYn
;
// 这里改成了 async 不知道有没有影响
export
default
async
(
selectEffectYn
:
MsgSelectEffectYn
)
=>
{
console
.
log
(
"
intercept announce
"
);
await
sendAIPredictAsResponse
(
selectEffectYn
as
unknown
as
ygopro
.
StocGameMessage
);
return
;
const
code
=
selectEffectYn
.
code
;
const
location
=
selectEffectYn
.
location
;
const
effect_description
=
selectEffectYn
.
effect_description
;
...
...
src/service/duel/selectIdleCmd.ts
View file @
bde80f6a
...
...
@@ -5,11 +5,11 @@ import {
InteractType
,
matStore
,
}
from
"
@/stores
"
;
//
import { sendAIPredictAsResponse } from "@/service/duel/agent";
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
MsgSelectIdleCmd
=
ygopro
.
StocGameMessage
.
MsgSelectIdleCmd
;
export
default
(
selectIdleCmd
:
MsgSelectIdleCmd
)
=>
{
export
default
async
(
selectIdleCmd
:
MsgSelectIdleCmd
)
=>
{
const
player
=
selectIdleCmd
.
player
;
const
cmds
=
selectIdleCmd
.
idle_cmds
;
...
...
@@ -18,9 +18,10 @@ export default (selectIdleCmd: MsgSelectIdleCmd) => {
card
.
idleInteractivities
=
[];
});
// sendAIPredictAsResponse(selectIdleCmd as unknown as ygopro.StocGameMessage);
// return;
console
.
log
(
"
intercept selectIdleCmd
"
);
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 @
bde80f6a
...
...
@@ -6,6 +6,7 @@ import {
type
ygopro
,
}
from
"
@/api
"
;
import
{
displayOptionModal
}
from
"
@/ui/Duel/Message
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
export
default
async
(
selectOption
:
ygopro
.
StocGameMessage
.
MsgSelectOption
)
=>
{
const
options
=
selectOption
.
options
;
...
...
@@ -18,6 +19,10 @@ export default async (selectOption: ygopro.StocGameMessage.MsgSelectOption) => {
return
;
}
console
.
log
(
"
intercept selectOption
"
);
await
sendAIPredictAsResponse
(
selectOption
as
unknown
as
ygopro
.
StocGameMessage
);
return
;
await
displayOptionModal
(
fetchStrings
(
Region
.
System
,
556
),
options
.
map
(({
code
,
response
})
=>
({
...
...
src/service/duel/selectPlace.ts
View file @
bde80f6a
import
{
sendSelectPlaceResponse
,
ygopro
}
from
"
@/api
"
;
import
{
InteractType
,
placeStore
}
from
"
@/stores
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
type
MsgSelectPlace
=
ygopro
.
StocGameMessage
.
MsgSelectPlace
;
export
default
(
selectPlace
:
MsgSelectPlace
)
=>
{
export
default
async
(
selectPlace
:
MsgSelectPlace
)
=>
{
if
(
selectPlace
.
count
!==
1
)
{
console
.
warn
(
`Unhandled case:
${
selectPlace
}
`
);
return
;
...
...
@@ -20,22 +21,26 @@ export default (selectPlace: MsgSelectPlace) => {
return
;
}
for
(
const
place
of
selectPlace
.
places
)
{
switch
(
place
.
zone
)
{
case
ygopro
.
CardZone
.
MZONE
:
case
ygopro
.
CardZone
.
SZONE
:
const
block
=
placeStore
.
of
(
place
);
if
(
block
)
{
block
.
interactivity
=
{
interactType
:
InteractType
.
PLACE_SELECTABLE
,
response
:
{
controller
:
place
.
controller
,
zone
:
place
.
zone
,
sequence
:
place
.
sequence
,
},
};
}
break
;
}
}
console
.
log
(
"
intercept announce
"
);
await
sendAIPredictAsResponse
(
selectPlace
as
unknown
as
ygopro
.
StocGameMessage
);
return
;
// for (const place of selectPlace.places) {
// switch (place.zone) {
// case ygopro.CardZone.MZONE:
// case ygopro.CardZone.SZONE:
// const block = placeStore.of(place);
// if (block) {
// block.interactivity = {
// interactType: InteractType.PLACE_SELECTABLE,
// response: {
// controller: place.controller,
// zone: place.zone,
// sequence: place.sequence,
// },
// };
// }
// break;
// }
// }
};
src/service/duel/selectPosition.ts
View file @
bde80f6a
import
{
ygopro
}
from
"
@/api
"
;
import
{
displayPositionModal
}
from
"
@/ui/Duel/Message
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
type
MsgSelectPosition
=
ygopro
.
StocGameMessage
.
MsgSelectPosition
;
export
default
async
(
selectPosition
:
MsgSelectPosition
)
=>
{
console
.
log
(
"
intercept announce
"
);
await
sendAIPredictAsResponse
(
selectPosition
as
unknown
as
ygopro
.
StocGameMessage
);
return
;
const
_player
=
selectPosition
.
player
;
const
positions
=
selectPosition
.
positions
.
map
(
(
position
)
=>
position
.
position
,
...
...
src/service/duel/selectYesNo.ts
View file @
bde80f6a
import
{
getStrings
,
ygopro
}
from
"
@/api
"
;
import
{
displayYesNoModal
}
from
"
@/ui/Duel/Message
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
type
MsgSelectYesNo
=
ygopro
.
StocGameMessage
.
MsgSelectYesNo
;
export
default
async
(
selectYesNo
:
MsgSelectYesNo
)
=>
{
console
.
log
(
"
intercept selectYesNo
"
);
await
sendAIPredictAsResponse
(
selectYesNo
as
unknown
as
ygopro
.
StocGameMessage
);
return
;
const
_player
=
selectYesNo
.
player
;
const
effect_description
=
selectYesNo
.
effect_description
;
...
...
src/stores/matStore/store.ts
View file @
bde80f6a
...
...
@@ -93,6 +93,7 @@ const initialState: Omit<MatState, "reset"> = {
duelEnd
:
false
,
// methods
isMe
,
turn_count
:
0
,
duelId
:
""
,
agentIndex
:
0
,
prevActionIndex
:
0
,
...
...
@@ -115,6 +116,7 @@ class MatStore implements MatState, NeosStore {
tossResult
=
initialState
.
tossResult
;
selectUnselectInfo
=
initialState
.
selectUnselectInfo
;
duelEnd
=
initialState
.
duelEnd
;
turn_count
=
initialState
.
turn_count
;
duelId
=
initialState
.
duelId
;
agentIndex
=
initialState
.
agentIndex
;
prevActionIndex
=
initialState
.
prevActionIndex
;
...
...
@@ -150,6 +152,7 @@ class MatStore implements MatState, NeosStore {
selectedList
:
[],
};
this
.
duelEnd
=
false
;
this
.
turn_count
=
0
;
this
.
duelId
=
""
;
this
.
agentIndex
=
0
;
this
.
prevActionIndex
=
0
;
...
...
src/stores/matStore/types.ts
View file @
bde80f6a
...
...
@@ -50,6 +50,8 @@ export interface MatState {
/** 根据自己的先后手判断是否是自己 */
isMe
:
(
player
:
number
)
=>
boolean
;
// TODO (ygo-agent): 检查实现是否正确
turn_count
:
number
,
duelId
:
string
;
agentIndex
:
number
;
prevActionIndex
:
number
;
...
...
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