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
Show 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(
...
@@ -30,7 +30,7 @@ export async function predictDuel(
):
Promise
<
PredictResp
|
undefined
>
{
):
Promise
<
PredictResp
|
undefined
>
{
const
headers
=
{
const
headers
=
{
...
agentHeader
(),
...
agentHeader
(),
'
Content-Type
'
:
'
application/json
'
,
"
Content-Type
"
:
"
application/json
"
,
};
};
const
resp
=
await
fetch
(
`
${
agentServer
}
/
${
apiPath
(
duelId
)}
`
,
{
const
resp
=
await
fetch
(
`
${
agentServer
}
/
${
apiPath
(
duelId
)}
`
,
{
...
...
src/api/ygoAgent/schema.ts
View file @
e0e5c7a6
import
{
ygopro
,
CardMeta
}
from
"
@/api
"
;
import
{
CardMeta
,
ygopro
}
from
"
@/api
"
;
import
{
CardType
}
from
"
@/stores/cardStore
"
;
import
{
extraCardTypes
}
from
"
@/common
"
;
import
{
extraCardTypes
}
from
"
@/common
"
;
import
{
CardType
}
from
"
@/stores/cardStore
"
;
import
GM
=
ygopro
.
StocGameMessage
;
import
GM
=
ygopro
.
StocGameMessage
;
...
@@ -114,7 +114,10 @@ function convertOverlaySequence(cl: ygopro.CardLocation): number {
...
@@ -114,7 +114,10 @@ function convertOverlaySequence(cl: ygopro.CardLocation): number {
return
cl
.
is_overlay
?
cl
.
overlay_sequence
:
-
1
;
return
cl
.
is_overlay
?
cl
.
overlay_sequence
:
-
1
;
}
}
function
convertCardLocation
(
cl
:
ygopro
.
CardLocation
,
player
:
number
):
CardLocation
{
function
convertCardLocation
(
cl
:
ygopro
.
CardLocation
,
player
:
number
,
):
CardLocation
{
return
{
return
{
controller
:
convertController
(
cl
.
controller
,
player
),
controller
:
convertController
(
cl
.
controller
,
player
),
location
:
cardZoneToLocation
(
cl
.
zone
),
location
:
cardZoneToLocation
(
cl
.
zone
),
...
@@ -138,7 +141,6 @@ enum Position {
...
@@ -138,7 +141,6 @@ enum Position {
Defense
=
"
defense
"
,
Defense
=
"
defense
"
,
}
}
function
convertPosition
(
position
:
ygopro
.
CardPosition
):
Position
{
function
convertPosition
(
position
:
ygopro
.
CardPosition
):
Position
{
switch
(
position
)
{
switch
(
position
)
{
case
ygopro
.
CardPosition
.
FACEUP_ATTACK
:
case
ygopro
.
CardPosition
.
FACEUP_ATTACK
:
...
@@ -162,7 +164,6 @@ function convertPosition(position: ygopro.CardPosition): Position {
...
@@ -162,7 +164,6 @@ function convertPosition(position: ygopro.CardPosition): Position {
}
}
}
}
/**
/**
* none for N/A or unknown or token.
* none for N/A or unknown or token.
*/
*/
...
@@ -200,32 +201,58 @@ enum Race {
...
@@ -200,32 +201,58 @@ enum Race {
// TODO (ygo-agent): replace literal numbers with constants
// TODO (ygo-agent): replace literal numbers with constants
function
numberToRace
(
raceNumber
:
number
):
Race
{
function
numberToRace
(
raceNumber
:
number
):
Race
{
switch
(
raceNumber
)
{
switch
(
raceNumber
)
{
case
0x0
:
return
Race
.
None
;
case
0x0
:
case
0x1
:
return
Race
.
Warrior
;
return
Race
.
None
;
case
0x2
:
return
Race
.
Spellcaster
;
case
0x1
:
case
0x4
:
return
Race
.
Fairy
;
return
Race
.
Warrior
;
case
0x8
:
return
Race
.
Fiend
;
case
0x2
:
case
0x10
:
return
Race
.
Zombie
;
return
Race
.
Spellcaster
;
case
0x20
:
return
Race
.
Machine
;
case
0x4
:
case
0x40
:
return
Race
.
Aqua
;
return
Race
.
Fairy
;
case
0x80
:
return
Race
.
Pyro
;
case
0x8
:
case
0x100
:
return
Race
.
Rock
;
return
Race
.
Fiend
;
case
0x200
:
return
Race
.
Windbeast
;
case
0x10
:
case
0x400
:
return
Race
.
Plant
;
return
Race
.
Zombie
;
case
0x800
:
return
Race
.
Insect
;
case
0x20
:
case
0x1000
:
return
Race
.
Thunder
;
return
Race
.
Machine
;
case
0x2000
:
return
Race
.
Dragon
;
case
0x40
:
case
0x4000
:
return
Race
.
Beast
;
return
Race
.
Aqua
;
case
0x8000
:
return
Race
.
BeastWarrior
;
case
0x80
:
case
0x10000
:
return
Race
.
Dinosaur
;
return
Race
.
Pyro
;
case
0x20000
:
return
Race
.
Fish
;
case
0x100
:
case
0x40000
:
return
Race
.
SeaSerpent
;
return
Race
.
Rock
;
case
0x80000
:
return
Race
.
Reptile
;
case
0x200
:
case
0x100000
:
return
Race
.
Psycho
;
return
Race
.
Windbeast
;
case
0x200000
:
return
Race
.
Devine
;
case
0x400
:
case
0x400000
:
return
Race
.
CreatorGod
;
return
Race
.
Plant
;
case
0x800000
:
return
Race
.
Wyrm
;
case
0x800
:
case
0x1000000
:
return
Race
.
Cyberse
;
return
Race
.
Insect
;
case
0x1000
:
return
Race
.
Thunder
;
case
0x2000
:
return
Race
.
Dragon
;
case
0x4000
:
return
Race
.
Beast
;
case
0x8000
:
return
Race
.
BeastWarrior
;
case
0x10000
:
return
Race
.
Dinosaur
;
case
0x20000
:
return
Race
.
Fish
;
case
0x40000
:
return
Race
.
SeaSerpent
;
case
0x80000
:
return
Race
.
Reptile
;
case
0x100000
:
return
Race
.
Psycho
;
case
0x200000
:
return
Race
.
Devine
;
case
0x400000
:
return
Race
.
CreatorGod
;
case
0x800000
:
return
Race
.
Wyrm
;
case
0x1000000
:
return
Race
.
Cyberse
;
default
:
default
:
throw
new
Error
(
`Unknown race number:
${
raceNumber
}
`
);
throw
new
Error
(
`Unknown race number:
${
raceNumber
}
`
);
}
}
...
@@ -263,36 +290,61 @@ enum Type {
...
@@ -263,36 +290,61 @@ enum Type {
// TODO (ygo-agent): replace literal numbers with constants
// TODO (ygo-agent): replace literal numbers with constants
function
numberToType
(
typeNumber
:
number
):
Type
{
function
numberToType
(
typeNumber
:
number
):
Type
{
switch
(
typeNumber
)
{
switch
(
typeNumber
)
{
case
0x1
:
return
Type
.
Monster
;
case
0x1
:
case
0x2
:
return
Type
.
Spell
;
return
Type
.
Monster
;
case
0x4
:
return
Type
.
Trap
;
case
0x2
:
case
0x10
:
return
Type
.
Normal
;
return
Type
.
Spell
;
case
0x20
:
return
Type
.
Effect
;
case
0x4
:
case
0x40
:
return
Type
.
Fusion
;
return
Type
.
Trap
;
case
0x80
:
return
Type
.
Ritual
;
case
0x10
:
case
0x100
:
return
Type
.
TrapMonster
;
return
Type
.
Normal
;
case
0x200
:
return
Type
.
Spirit
;
case
0x20
:
case
0x400
:
return
Type
.
Union
;
return
Type
.
Effect
;
case
0x800
:
return
Type
.
Dual
;
case
0x40
:
case
0x1000
:
return
Type
.
Tuner
;
return
Type
.
Fusion
;
case
0x2000
:
return
Type
.
Synchro
;
case
0x80
:
case
0x4000
:
return
Type
.
Token
;
return
Type
.
Ritual
;
case
0x10000
:
return
Type
.
QuickPlay
;
case
0x100
:
case
0x20000
:
return
Type
.
Continuous
;
return
Type
.
TrapMonster
;
case
0x40000
:
return
Type
.
Equip
;
case
0x200
:
case
0x80000
:
return
Type
.
Field
;
return
Type
.
Spirit
;
case
0x100000
:
return
Type
.
Counter
;
case
0x400
:
case
0x200000
:
return
Type
.
Flip
;
return
Type
.
Union
;
case
0x400000
:
return
Type
.
Toon
;
case
0x800
:
case
0x800000
:
return
Type
.
Xyz
;
return
Type
.
Dual
;
case
0x1000000
:
return
Type
.
Pendulum
;
case
0x1000
:
case
0x2000000
:
return
Type
.
Special
;
return
Type
.
Tuner
;
case
0x4000000
:
return
Type
.
Link
;
case
0x2000
:
default
:
throw
new
Error
(
`Unknown type number:
${
typeNumber
}
`
);
return
Type
.
Synchro
;
case
0x4000
:
return
Type
.
Token
;
case
0x10000
:
return
Type
.
QuickPlay
;
case
0x20000
:
return
Type
.
Continuous
;
case
0x40000
:
return
Type
.
Equip
;
case
0x80000
:
return
Type
.
Field
;
case
0x100000
:
return
Type
.
Counter
;
case
0x200000
:
return
Type
.
Flip
;
case
0x400000
:
return
Type
.
Toon
;
case
0x800000
:
return
Type
.
Xyz
;
case
0x1000000
:
return
Type
.
Pendulum
;
case
0x2000000
:
return
Type
.
Special
;
case
0x4000000
:
return
Type
.
Link
;
default
:
throw
new
Error
(
`Unknown type number:
${
typeNumber
}
`
);
}
}
}
}
interface
Card
{
interface
Card
{
/**
/**
* Card code from cards.cdb
* Card code from cards.cdb
...
@@ -365,7 +417,7 @@ export function convertDeckCard(meta: CardMeta): Card {
...
@@ -365,7 +417,7 @@ export function convertDeckCard(meta: CardMeta): Card {
attack
:
meta
.
data
.
atk
??
0
,
attack
:
meta
.
data
.
atk
??
0
,
defense
:
meta
.
data
.
def
??
0
,
defense
:
meta
.
data
.
def
??
0
,
types
:
extraCardTypes
(
meta
.
data
.
type
??
0
).
map
(
numberToType
),
types
:
extraCardTypes
(
meta
.
data
.
type
??
0
).
map
(
numberToType
),
}
}
;
}
}
export
function
convertCard
(
card
:
CardType
,
player
:
number
):
Card
{
export
function
convertCard
(
card
:
CardType
,
player
:
number
):
Card
{
...
@@ -386,7 +438,7 @@ export function convertCard(card: CardType, player: number): Card {
...
@@ -386,7 +438,7 @@ export function convertCard(card: CardType, player: number): Card {
attack
:
card
.
meta
.
data
.
atk
??
0
,
attack
:
card
.
meta
.
data
.
atk
??
0
,
defense
:
card
.
meta
.
data
.
def
??
0
,
defense
:
card
.
meta
.
data
.
def
??
0
,
types
:
extraCardTypes
(
card
.
meta
.
data
.
type
??
0
).
map
(
numberToType
),
types
:
extraCardTypes
(
card
.
meta
.
data
.
type
??
0
).
map
(
numberToType
),
}
}
;
}
}
enum
Phase
{
enum
Phase
{
...
@@ -487,9 +539,9 @@ function convertMsgSelectCard(msg: GM.MsgSelectCard): MsgSelectCard {
...
@@ -487,9 +539,9 @@ function convertMsgSelectCard(msg: GM.MsgSelectCard): MsgSelectCard {
cancelable
:
msg
.
cancelable
,
cancelable
:
msg
.
cancelable
,
min
:
msg
.
min
,
min
:
msg
.
min
,
max
:
msg
.
max
,
max
:
msg
.
max
,
cards
:
msg
.
cards
.
map
(
c
=>
({
cards
:
msg
.
cards
.
map
(
(
c
)
=>
({
location
:
convertCardLocation
(
c
.
location
,
msg
.
player
),
location
:
convertCardLocation
(
c
.
location
,
msg
.
player
),
response
:
c
.
response
response
:
c
.
response
,
})),
})),
selected
:
[],
selected
:
[],
};
};
...
@@ -516,7 +568,7 @@ function convertMsgSelectTribute(msg: GM.MsgSelectTribute): MsgSelectTribute {
...
@@ -516,7 +568,7 @@ function convertMsgSelectTribute(msg: GM.MsgSelectTribute): MsgSelectTribute {
cancelable
:
msg
.
cancelable
,
cancelable
:
msg
.
cancelable
,
min
:
msg
.
min
,
min
:
msg
.
min
,
max
:
msg
.
max
,
max
:
msg
.
max
,
cards
:
msg
.
selectable_cards
.
map
(
c
=>
({
cards
:
msg
.
selectable_cards
.
map
(
(
c
)
=>
({
location
:
convertCardLocation
(
c
.
location
,
msg
.
player
),
location
:
convertCardLocation
(
c
.
location
,
msg
.
player
),
level
:
c
.
level
,
level
:
c
.
level
,
response
:
c
.
response
,
response
:
c
.
response
,
...
@@ -546,24 +598,24 @@ export interface MsgSelectSum {
...
@@ -546,24 +598,24 @@ export interface MsgSelectSum {
function
convertMsgSelectSum
(
msg
:
GM
.
MsgSelectSum
):
MsgSelectSum
{
function
convertMsgSelectSum
(
msg
:
GM
.
MsgSelectSum
):
MsgSelectSum
{
return
{
return
{
msg_type
:
"
select_sum
"
,
msg_type
:
"
select_sum
"
,
overflow
:
msg
.
overflow
!=
0
,
overflow
:
msg
.
overflow
!=
=
0
,
level_sum
:
msg
.
level_sum
,
level_sum
:
msg
.
level_sum
,
min
:
msg
.
min
,
min
:
msg
.
min
,
max
:
msg
.
max
,
max
:
msg
.
max
,
cards
:
msg
.
selectable_cards
.
map
(
c
=>
({
cards
:
msg
.
selectable_cards
.
map
(
(
c
)
=>
({
location
:
convertCardLocation
(
c
.
location
,
msg
.
player
),
location
:
convertCardLocation
(
c
.
location
,
msg
.
player
),
level1
:
c
.
level1
,
level1
:
c
.
level1
,
level2
:
c
.
level2
,
level2
:
c
.
level2
,
response
:
c
.
response
,
response
:
c
.
response
,
})),
})),
must_cards
:
msg
.
must_select_cards
.
map
(
c
=>
({
must_cards
:
msg
.
must_select_cards
.
map
(
(
c
)
=>
({
location
:
convertCardLocation
(
c
.
location
,
msg
.
player
),
location
:
convertCardLocation
(
c
.
location
,
msg
.
player
),
level1
:
c
.
level1
,
level1
:
c
.
level1
,
level2
:
c
.
level2
,
level2
:
c
.
level2
,
response
:
c
.
response
,
response
:
c
.
response
,
})),
})),
selected
:
[],
selected
:
[],
}
}
;
}
}
interface
CardInfo
{
interface
CardInfo
{
...
@@ -640,18 +692,19 @@ function convertMsgSelectIdleCmd(msg: GM.MsgSelectIdleCmd): MsgSelectIdleCmd {
...
@@ -640,18 +692,19 @@ function convertMsgSelectIdleCmd(msg: GM.MsgSelectIdleCmd): MsgSelectIdleCmd {
for
(
const
data
of
cmd
.
idle_datas
)
{
for
(
const
data
of
cmd
.
idle_datas
)
{
const
cmd_type
=
convertIdleCmdType
(
cmd
.
idle_type
);
const
cmd_type
=
convertIdleCmdType
(
cmd
.
idle_type
);
if
(
if
(
cmd_type
==
IdleCmdType
.
Summon
||
cmd_type
==
=
IdleCmdType
.
Summon
||
cmd_type
==
IdleCmdType
.
SpSummon
||
cmd_type
==
=
IdleCmdType
.
SpSummon
||
cmd_type
==
IdleCmdType
.
Reposition
||
cmd_type
==
=
IdleCmdType
.
Reposition
||
cmd_type
==
IdleCmdType
.
Mset
||
cmd_type
==
=
IdleCmdType
.
Mset
||
cmd_type
==
IdleCmdType
.
Set
||
cmd_type
==
=
IdleCmdType
.
Set
||
cmd_type
==
IdleCmdType
.
Activate
cmd_type
==
=
IdleCmdType
.
Activate
)
{
)
{
idle_cmds
.
push
({
idle_cmds
.
push
({
cmd_type
,
cmd_type
,
data
:
{
data
:
{
card_info
:
convertCardInfo
(
data
.
card_info
,
msg
.
player
),
card_info
:
convertCardInfo
(
data
.
card_info
,
msg
.
player
),
effect_description
:
cmd_type
==
IdleCmdType
.
Activate
?
data
.
effect_description
:
0
,
effect_description
:
cmd_type
===
IdleCmdType
.
Activate
?
data
.
effect_description
:
0
,
response
:
data
.
response
,
response
:
data
.
response
,
},
},
});
});
...
@@ -702,7 +755,7 @@ function convertMsgSelectChain(msg: GM.MsgSelectChain): MsgSelectChain {
...
@@ -702,7 +755,7 @@ function convertMsgSelectChain(msg: GM.MsgSelectChain): MsgSelectChain {
return
{
return
{
msg_type
:
"
select_chain
"
,
msg_type
:
"
select_chain
"
,
forced
:
msg
.
forced
,
forced
:
msg
.
forced
,
chains
:
msg
.
chains
.
map
(
c
=>
convertChain
(
c
,
msg
.
player
)),
chains
:
msg
.
chains
.
map
(
(
c
)
=>
convertChain
(
c
,
msg
.
player
)),
};
};
}
}
...
@@ -712,14 +765,16 @@ interface MsgSelectPosition {
...
@@ -712,14 +765,16 @@ interface MsgSelectPosition {
positions
:
Position
[];
positions
:
Position
[];
}
}
function
convertMsgSelectPosition
(
msg
:
GM
.
MsgSelectPosition
):
MsgSelectPosition
{
function
convertMsgSelectPosition
(
msg
:
GM
.
MsgSelectPosition
,
):
MsgSelectPosition
{
return
{
return
{
msg_type
:
"
select_position
"
,
msg_type
:
"
select_position
"
,
code
:
msg
.
code
,
code
:
msg
.
code
,
// response will be equal to POS_* from ocgcore
// response will be equal to POS_* from ocgcore
// POS_FACEUP_ATTACK: 0x1, POS_FACEDOWN_ATTACK: 0x2,
// POS_FACEUP_ATTACK: 0x1, POS_FACEDOWN_ATTACK: 0x2,
// POS_FACEUP_DEFENSE: 0x4, POS_FACEDOWN_DEFENSE: 0x8
// POS_FACEUP_DEFENSE: 0x4, POS_FACEDOWN_DEFENSE: 0x8
positions
:
msg
.
positions
.
map
(
p
=>
convertPosition
(
p
.
position
)),
positions
:
msg
.
positions
.
map
(
(
p
)
=>
convertPosition
(
p
.
position
)),
};
};
}
}
...
@@ -743,7 +798,9 @@ interface MsgSelectEffectYn {
...
@@ -743,7 +798,9 @@ interface MsgSelectEffectYn {
effect_description
:
number
;
effect_description
:
number
;
}
}
function
convertMsgSelectEffectYn
(
msg
:
GM
.
MsgSelectEffectYn
):
MsgSelectEffectYn
{
function
convertMsgSelectEffectYn
(
msg
:
GM
.
MsgSelectEffectYn
,
):
MsgSelectEffectYn
{
// response is 1 for yes and 0 for no
// response is 1 for yes and 0 for no
return
{
return
{
msg_type
:
"
select_effectyn
"
,
msg_type
:
"
select_effectyn
"
,
...
@@ -789,7 +846,9 @@ interface MsgSelectBattleCmd {
...
@@ -789,7 +846,9 @@ interface MsgSelectBattleCmd {
battle_cmds
:
BattleCmd
[];
battle_cmds
:
BattleCmd
[];
}
}
function
convertMsgSelectBattleCmd
(
msg
:
GM
.
MsgSelectBattleCmd
):
MsgSelectBattleCmd
{
function
convertMsgSelectBattleCmd
(
msg
:
GM
.
MsgSelectBattleCmd
,
):
MsgSelectBattleCmd
{
const
battle_cmds
:
BattleCmd
[]
=
[];
const
battle_cmds
:
BattleCmd
[]
=
[];
for
(
const
cmd
of
msg
.
battle_cmds
)
{
for
(
const
cmd
of
msg
.
battle_cmds
)
{
const
cmd_type
=
convertBattleCmdType
(
cmd
.
battle_type
);
const
cmd_type
=
convertBattleCmdType
(
cmd
.
battle_type
);
...
@@ -818,13 +877,11 @@ function convertMsgSelectBattleCmd(msg: GM.MsgSelectBattleCmd): MsgSelectBattleC
...
@@ -818,13 +877,11 @@ function convertMsgSelectBattleCmd(msg: GM.MsgSelectBattleCmd): MsgSelectBattleC
};
};
}
}
interface
SelectUnselectCard
{
interface
SelectUnselectCard
{
location
:
CardLocation
;
location
:
CardLocation
;
response
:
number
;
response
:
number
;
}
}
interface
MsgSelectUnselectCard
{
interface
MsgSelectUnselectCard
{
msg_type
:
"
select_unselect_card
"
;
msg_type
:
"
select_unselect_card
"
;
finishable
:
boolean
;
finishable
:
boolean
;
...
@@ -835,7 +892,9 @@ interface MsgSelectUnselectCard {
...
@@ -835,7 +892,9 @@ interface MsgSelectUnselectCard {
selectable_cards
:
SelectUnselectCard
[];
selectable_cards
:
SelectUnselectCard
[];
}
}
function
convertMsgSelectUnselectCard
(
msg
:
GM
.
MsgSelectUnselectCard
):
MsgSelectUnselectCard
{
function
convertMsgSelectUnselectCard
(
msg
:
GM
.
MsgSelectUnselectCard
,
):
MsgSelectUnselectCard
{
return
{
return
{
msg_type
:
"
select_unselect_card
"
,
msg_type
:
"
select_unselect_card
"
,
// response is -1 for finish
// response is -1 for finish
...
@@ -843,11 +902,11 @@ function convertMsgSelectUnselectCard(msg: GM.MsgSelectUnselectCard): MsgSelectU
...
@@ -843,11 +902,11 @@ function convertMsgSelectUnselectCard(msg: GM.MsgSelectUnselectCard): MsgSelectU
cancelable
:
msg
.
cancelable
,
cancelable
:
msg
.
cancelable
,
min
:
msg
.
min
,
min
:
msg
.
min
,
max
:
msg
.
max
,
max
:
msg
.
max
,
selected_cards
:
msg
.
selected_cards
.
map
(
c
=>
({
selected_cards
:
msg
.
selected_cards
.
map
(
(
c
)
=>
({
location
:
convertCardLocation
(
c
.
location
,
msg
.
player
),
location
:
convertCardLocation
(
c
.
location
,
msg
.
player
),
response
:
c
.
response
,
response
:
c
.
response
,
})),
})),
selectable_cards
:
msg
.
selectable_cards
.
map
(
c
=>
({
selectable_cards
:
msg
.
selectable_cards
.
map
(
(
c
)
=>
({
location
:
convertCardLocation
(
c
.
location
,
msg
.
player
),
location
:
convertCardLocation
(
c
.
location
,
msg
.
player
),
response
:
c
.
response
,
response
:
c
.
response
,
})),
})),
...
@@ -867,14 +926,13 @@ interface MsgSelectOption {
...
@@ -867,14 +926,13 @@ interface MsgSelectOption {
function
convertMsgSelectOption
(
msg
:
GM
.
MsgSelectOption
):
MsgSelectOption
{
function
convertMsgSelectOption
(
msg
:
GM
.
MsgSelectOption
):
MsgSelectOption
{
return
{
return
{
msg_type
:
"
select_option
"
,
msg_type
:
"
select_option
"
,
options
:
msg
.
options
.
map
(
o
=>
({
options
:
msg
.
options
.
map
(
(
o
)
=>
({
code
:
o
.
code
,
code
:
o
.
code
,
response
:
o
.
response
,
response
:
o
.
response
,
})),
})),
};
};
}
}
interface
Place
{
interface
Place
{
controller
:
Controller
;
controller
:
Controller
;
location
:
Location
;
location
:
Location
;
...
@@ -892,7 +950,7 @@ function convertMsgSelectPlace(msg: GM.MsgSelectPlace): MsgSelectPlace {
...
@@ -892,7 +950,7 @@ function convertMsgSelectPlace(msg: GM.MsgSelectPlace): MsgSelectPlace {
return
{
return
{
msg_type
:
"
select_place
"
,
msg_type
:
"
select_place
"
,
count
:
msg
.
count
,
count
:
msg
.
count
,
places
:
msg
.
places
.
map
(
p
=>
({
places
:
msg
.
places
.
map
(
(
p
)
=>
({
// NOTICE: the response is the index of the place in the places array
// NOTICE: the response is the index of the place in the places array
controller
:
convertController
(
p
.
controller
,
msg
.
player
),
controller
:
convertController
(
p
.
controller
,
msg
.
player
),
location
:
cardZoneToLocation
(
p
.
zone
),
location
:
cardZoneToLocation
(
p
.
zone
),
...
@@ -917,7 +975,7 @@ function convertMsgAnnounceAttrib(msg: GM.MsgAnnounce): MsgAnnounceAttrib {
...
@@ -917,7 +975,7 @@ function convertMsgAnnounceAttrib(msg: GM.MsgAnnounce): MsgAnnounceAttrib {
msg_type
:
"
announce_attrib
"
,
msg_type
:
"
announce_attrib
"
,
count
:
msg
.
min
,
count
:
msg
.
min
,
// from api/ocgcore/ocgAdapter/stoc/stocGameMsg/announceAttrib.ts
// from api/ocgcore/ocgAdapter/stoc/stocGameMsg/announceAttrib.ts
attributes
:
msg
.
options
.
map
(
a
=>
({
attributes
:
msg
.
options
.
map
(
(
a
)
=>
({
attribute
:
numberToAttribute
(
1
<<
a
.
code
),
attribute
:
numberToAttribute
(
1
<<
a
.
code
),
response
:
a
.
response
,
response
:
a
.
response
,
})),
})),
...
@@ -939,7 +997,7 @@ function convertMsgAnnounceNumber(msg: GM.MsgAnnounce): MsgAnnounceNumber {
...
@@ -939,7 +997,7 @@ function convertMsgAnnounceNumber(msg: GM.MsgAnnounce): MsgAnnounceNumber {
return
{
return
{
msg_type
:
"
announce_number
"
,
msg_type
:
"
announce_number
"
,
count
:
msg
.
min
,
count
:
msg
.
min
,
numbers
:
msg
.
options
.
map
(
o
=>
({
numbers
:
msg
.
options
.
map
(
(
o
)
=>
({
number
:
o
.
code
,
number
:
o
.
code
,
response
:
o
.
response
,
response
:
o
.
response
,
})),
})),
...
@@ -947,21 +1005,20 @@ function convertMsgAnnounceNumber(msg: GM.MsgAnnounce): MsgAnnounceNumber {
...
@@ -947,21 +1005,20 @@ function convertMsgAnnounceNumber(msg: GM.MsgAnnounce): MsgAnnounceNumber {
}
}
type
ActionMsgData
=
type
ActionMsgData
=
MsgSelectCard
|
|
MsgSelectCard
MsgSelectTribute
|
|
MsgSelectTribute
MsgSelectSum
|
|
MsgSelectSum
MsgSelectIdleCmd
|
|
MsgSelectIdleCmd
MsgSelectChain
|
|
MsgSelectChain
MsgSelectPosition
|
|
MsgSelectPosition
MsgSelectYesNo
|
|
MsgSelectYesNo
MsgSelectEffectYn
|
|
MsgSelectEffectYn
MsgSelectBattleCmd
|
|
MsgSelectBattleCmd
MsgSelectUnselectCard
|
|
MsgSelectUnselectCard
MsgSelectOption
|
|
MsgSelectOption
MsgSelectPlace
|
|
MsgSelectPlace
MsgAnnounceAttrib
|
|
MsgAnnounceAttrib
MsgAnnounceNumber
;
|
MsgAnnounceNumber
;
interface
ActionMsg
{
interface
ActionMsg
{
data
:
ActionMsgData
;
data
:
ActionMsgData
;
...
@@ -1017,11 +1074,11 @@ export function convertActionMsg(msg: ygopro.StocGameMessage): ActionMsg {
...
@@ -1017,11 +1074,11 @@ export function convertActionMsg(msg: ygopro.StocGameMessage): ActionMsg {
data
:
convertMsgSelectPlace
(
msg
),
data
:
convertMsgSelectPlace
(
msg
),
};
};
}
else
if
(
msg
instanceof
GM
.
MsgAnnounce
)
{
}
else
if
(
msg
instanceof
GM
.
MsgAnnounce
)
{
if
(
msg
.
announce_type
==
GM
.
MsgAnnounce
.
AnnounceType
.
Attribute
)
{
if
(
msg
.
announce_type
==
=
GM
.
MsgAnnounce
.
AnnounceType
.
Attribute
)
{
return
{
return
{
data
:
convertMsgAnnounceAttrib
(
msg
),
data
:
convertMsgAnnounceAttrib
(
msg
),
};
};
}
else
if
(
msg
.
announce_type
==
GM
.
MsgAnnounce
.
AnnounceType
.
Number
)
{
}
else
if
(
msg
.
announce_type
==
=
GM
.
MsgAnnounce
.
AnnounceType
.
Number
)
{
return
{
return
{
data
:
convertMsgAnnounceNumber
(
msg
),
data
:
convertMsgAnnounceNumber
(
msg
),
};
};
...
...
src/service/duel/agent.ts
View file @
e0e5c7a6
import
{
import
{
PredictReq
,
PredictReq
,
ygopro
,
sendSelectBattleCmdResponse
,
sendSelectEffectYnResponse
,
sendSelectIdleCmdResponse
,
sendSelectIdleCmdResponse
,
sendSelectPlaceResponse
,
sendSelectMultiResponse
,
sendSelectMultiResponse
,
sendSelectSingleResponse
,
sendSelectEffectYnResponse
,
sendSelectPositionResponse
,
sendSelectOptionResponse
,
sendSelectOptionResponse
,
sendSelectBattleCmdResponse
,
sendSelectPlaceResponse
,
sendSortCardResponse
,
sendSelectPositionResponse
,
sendSelectSingleResponse
,
ygopro
,
}
from
"
@/api
"
;
}
from
"
@/api
"
;
import
{
cardStore
,
matStore
}
from
"
@/stores
"
;
import
{
predictDuel
}
from
"
@/api/ygoAgent/predict
"
;
import
{
import
{
Global
,
convertPhase
,
convertCard
,
convertDeckCard
,
convertActionMsg
,
parsePlayerFromMsg
,
convertActionMsg
,
Input
,
MultiSelectMsg
,
MsgSelectSum
convertCard
,
convertDeckCard
,
convertPhase
,
Global
,
Input
,
MsgSelectSum
,
MultiSelectMsg
,
parsePlayerFromMsg
,
}
from
"
@/api/ygoAgent/schema
"
;
}
from
"
@/api/ygoAgent/schema
"
;
import
{
predictDuel
}
from
"
@/api/ygoAgent/predict
"
;
import
{
cardStore
,
matStore
}
from
"
@/stores
"
;
function
computeSetDifference
(
a1
:
number
[],
a2
:
number
[]):
number
[]
{
function
computeSetDifference
(
a1
:
number
[],
a2
:
number
[]):
number
[]
{
const
freq1
=
new
Map
<
number
,
number
>
();
const
freq1
=
new
Map
<
number
,
number
>
();
...
@@ -44,7 +50,6 @@ function computeSetDifference(a1: number[], a2: number[]): number[] {
...
@@ -44,7 +50,6 @@ function computeSetDifference(a1: number[], a2: number[]): number[] {
return
difference
;
return
difference
;
}
}
export
function
genInput
(
msg
:
ygopro
.
StocGameMessage
):
Input
{
export
function
genInput
(
msg
:
ygopro
.
StocGameMessage
):
Input
{
// 全局信息可以从 `matStore` 里面拿
// 全局信息可以从 `matStore` 里面拿
const
mat
=
matStore
;
const
mat
=
matStore
;
...
@@ -66,23 +71,29 @@ export function genInput(msg: ygopro.StocGameMessage): Input {
...
@@ -66,23 +71,29 @@ export function genInput(msg: ygopro.StocGameMessage): Input {
const
opponent
=
1
-
player
;
const
opponent
=
1
-
player
;
const
cards
=
cardStore
.
inner
const
cards
=
cardStore
.
inner
.
filter
((
card
)
=>
.
filter
(
(
card
)
=>
zones
.
includes
(
card
.
location
.
zone
)
&&
zones
.
includes
(
card
.
location
.
zone
)
&&
!
(
card
.
location
.
zone
===
ygopro
.
CardZone
.
DECK
!
(
&&
card
.
location
.
controller
===
player
card
.
location
.
zone
===
ygopro
.
CardZone
.
DECK
&&
)
card
.
location
.
controller
===
player
),
)
)
.
map
((
card
)
=>
convertCard
(
card
,
player
));
.
map
((
card
)
=>
convertCard
(
card
,
player
));
const
cardCodesMe
=
cardStore
.
inner
const
cardCodesMe
=
cardStore
.
inner
.
filter
((
card
)
=>
.
filter
(
zones
.
includes
(
card
.
location
.
zone
)
&&
card
.
location
.
controller
===
player
(
card
)
=>
zones
.
includes
(
card
.
location
.
zone
)
&&
card
.
location
.
controller
===
player
,
)
)
.
map
((
card
)
=>
card
.
code
);
.
map
((
card
)
=>
card
.
code
);
const
cardCodesMeDeck
=
computeSetDifference
(
mat
.
mainDeck
,
cardCodesMe
);
const
cardCodesMeDeck
=
computeSetDifference
(
mat
.
mainDeck
,
cardCodesMe
);
const
mainDeckCardMeta
=
mat
.
mainDeckCardMeta
;
const
mainDeckCardMeta
=
mat
.
mainDeckCardMeta
;
// TODO (ygo-agent): 临时方案,有很多边界情况未考虑
// 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
turnPlayer
=
mat
.
currentPlayer
;
const
global
:
Global
=
{
const
global
:
Global
=
{
...
@@ -92,7 +103,7 @@ export function genInput(msg: ygopro.StocGameMessage): Input {
...
@@ -92,7 +103,7 @@ export function genInput(msg: ygopro.StocGameMessage): Input {
op_lp
:
mat
.
initInfo
.
of
(
opponent
).
life
,
op_lp
:
mat
.
initInfo
.
of
(
opponent
).
life
,
phase
:
convertPhase
(
mat
.
phase
.
currentPhase
),
phase
:
convertPhase
(
mat
.
phase
.
currentPhase
),
turn
:
mat
.
turnCount
,
turn
:
mat
.
turnCount
,
}
}
;
const
actionMsg
=
convertActionMsg
(
msg
);
const
actionMsg
=
convertActionMsg
(
msg
);
...
@@ -100,10 +111,9 @@ export function genInput(msg: ygopro.StocGameMessage): Input {
...
@@ -100,10 +111,9 @@ export function genInput(msg: ygopro.StocGameMessage): Input {
global
:
global
,
global
:
global
,
cards
:
deckCardsMe
.
concat
(
cards
),
cards
:
deckCardsMe
.
concat
(
cards
),
action_msg
:
actionMsg
,
action_msg
:
actionMsg
,
}
}
;
}
}
async
function
sendRequest
(
req
:
PredictReq
)
{
async
function
sendRequest
(
req
:
PredictReq
)
{
console
.
log
(
"
Sending predict request:
"
,
req
);
console
.
log
(
"
Sending predict request:
"
,
req
);
const
duelId
=
matStore
.
duelId
;
const
duelId
=
matStore
.
duelId
;
...
@@ -111,8 +121,7 @@ async function sendRequest(req: PredictReq) {
...
@@ -111,8 +121,7 @@ async function sendRequest(req: PredictReq) {
console
.
log
(
"
Got predict response:
"
,
resp
);
console
.
log
(
"
Got predict response:
"
,
resp
);
if
(
resp
!==
undefined
)
{
if
(
resp
!==
undefined
)
{
matStore
.
agentIndex
=
resp
.
index
;
matStore
.
agentIndex
=
resp
.
index
;
}
}
else
{
else
{
throw
new
Error
(
"
Failed to get predict response
"
);
throw
new
Error
(
"
Failed to get predict response
"
);
}
}
...
@@ -143,11 +152,11 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) {
...
@@ -143,11 +152,11 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) {
prev_action_idx
:
matStore
.
prevActionIndex
,
prev_action_idx
:
matStore
.
prevActionIndex
,
};
};
const
response
=
(
await
sendRequest
(
req
)).
response
;
const
response
=
(
await
sendRequest
(
req
)).
response
;
if
(
response
!=
-
1
)
{
if
(
response
!=
=
-
1
)
{
selected
.
push
(
matStore
.
prevActionIndex
);
selected
.
push
(
matStore
.
prevActionIndex
);
responses
.
push
(
response
);
responses
.
push
(
response
);
}
}
if
(
response
==
-
1
||
selected
.
length
==
msg_
.
max
)
{
if
(
response
==
=
-
1
||
selected
.
length
=
==
msg_
.
max
)
{
sendSelectMultiResponse
(
responses
);
sendSelectMultiResponse
(
responses
);
break
;
break
;
}
}
...
@@ -169,7 +178,7 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) {
...
@@ -169,7 +178,7 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) {
prev_action_idx
:
matStore
.
prevActionIndex
,
prev_action_idx
:
matStore
.
prevActionIndex
,
};
};
const
pred
=
await
sendRequest
(
req
);
const
pred
=
await
sendRequest
(
req
);
const
idx
=
matStore
.
prevActionIndex
const
idx
=
matStore
.
prevActionIndex
;
selected
.
push
(
idx
);
selected
.
push
(
idx
);
responses
.
push
(
pred
.
response
);
responses
.
push
(
pred
.
response
);
if
(
pred
.
can_finish
)
{
if
(
pred
.
can_finish
)
{
...
@@ -211,7 +220,8 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) {
...
@@ -211,7 +220,8 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) {
sendSelectPositionResponse
(
convertPositionResponse
(
response
));
sendSelectPositionResponse
(
convertPositionResponse
(
response
));
break
;
break
;
case
"
select_place
"
:
{
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
({
sendSelectPlaceResponse
({
controller
:
place
.
controller
,
controller
:
place
.
controller
,
zone
:
place
.
zone
,
zone
:
place
.
zone
,
...
@@ -220,7 +230,7 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) {
...
@@ -220,7 +230,7 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) {
break
;
break
;
}
}
case
"
select_unselect_card
"
:
{
case
"
select_unselect_card
"
:
{
if
(
response
==
-
1
)
{
if
(
response
==
=
-
1
)
{
sendSelectSingleResponse
(
-
1
);
sendSelectSingleResponse
(
-
1
);
}
else
{
}
else
{
sendSelectMultiResponse
([
response
]);
sendSelectMultiResponse
([
response
]);
...
@@ -231,7 +241,6 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) {
...
@@ -231,7 +241,6 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) {
}
}
}
}
function
argmax
<
T
>
(
arr
:
T
[],
getValue
:
(
item
:
T
)
=>
number
):
number
{
function
argmax
<
T
>
(
arr
:
T
[],
getValue
:
(
item
:
T
)
=>
number
):
number
{
if
(
arr
.
length
===
0
)
{
if
(
arr
.
length
===
0
)
{
throw
new
Error
(
"
Array is empty
"
);
throw
new
Error
(
"
Array is empty
"
);
...
@@ -251,13 +260,16 @@ function argmax<T>(arr: T[], getValue: (item: T) => number): number {
...
@@ -251,13 +260,16 @@ function argmax<T>(arr: T[], getValue: (item: T) => number): number {
return
maxIndex
;
return
maxIndex
;
}
}
function
convertPositionResponse
(
response
:
number
):
ygopro
.
CardPosition
{
function
convertPositionResponse
(
response
:
number
):
ygopro
.
CardPosition
{
switch
(
response
)
{
switch
(
response
)
{
case
0x1
:
return
ygopro
.
CardPosition
.
FACEUP_ATTACK
;
case
0x1
:
case
0x2
:
return
ygopro
.
CardPosition
.
FACEDOWN_ATTACK
;
return
ygopro
.
CardPosition
.
FACEUP_ATTACK
;
case
0x4
:
return
ygopro
.
CardPosition
.
FACEUP_DEFENSE
;
case
0x2
:
case
0x8
:
return
ygopro
.
CardPosition
.
FACEDOWN_DEFENSE
;
return
ygopro
.
CardPosition
.
FACEDOWN_ATTACK
;
case
0x4
:
return
ygopro
.
CardPosition
.
FACEUP_DEFENSE
;
case
0x8
:
return
ygopro
.
CardPosition
.
FACEDOWN_DEFENSE
;
default
:
default
:
throw
new
Error
(
`Invalid position response:
${
response
}
`
);
throw
new
Error
(
`Invalid position response:
${
response
}
`
);
}
}
...
...
src/service/duel/announce.ts
View file @
e0e5c7a6
import
{
fetchStrings
,
Region
,
ygopro
}
from
"
@/api
"
;
import
{
fetchStrings
,
Region
,
ygopro
}
from
"
@/api
"
;
import
{
displayOptionModal
}
from
"
@/ui/Duel/Message
"
;
import
{
displayOptionModal
}
from
"
@/ui/Duel/Message
"
;
import
MsgAnnounce
=
ygopro
.
StocGameMessage
.
MsgAnnounce
;
import
MsgAnnounce
=
ygopro
.
StocGameMessage
.
MsgAnnounce
;
import
{
displayAnnounceModal
}
from
"
@/ui/Duel/Message/AnnounceModal
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
{
matStore
}
from
"
@/stores
"
;
import
{
matStore
}
from
"
@/stores
"
;
import
{
displayAnnounceModal
}
from
"
@/ui/Duel/Message/AnnounceModal
"
;
export
default
async
(
announce
:
MsgAnnounce
)
=>
{
export
default
async
(
announce
:
MsgAnnounce
)
=>
{
if
(
matStore
.
autoSelect
)
{
if
(
matStore
.
autoSelect
)
{
console
.
log
(
"
intercept announce
"
);
console
.
log
(
"
intercept announce
"
);
await
sendAIPredictAsResponse
(
announce
as
unknown
as
ygopro
.
StocGameMessage
);
await
sendAIPredictAsResponse
(
announce
as
unknown
as
ygopro
.
StocGameMessage
,
);
return
;
return
;
}
}
...
...
src/service/duel/selectBattleCmd.ts
View file @
e0e5c7a6
...
@@ -20,7 +20,9 @@ export default async (selectBattleCmd: MsgSelectBattleCmd) => {
...
@@ -20,7 +20,9 @@ export default async (selectBattleCmd: MsgSelectBattleCmd) => {
if
(
matStore
.
autoSelect
)
{
if
(
matStore
.
autoSelect
)
{
console
.
log
(
"
intercept selectBattleCmd
"
);
console
.
log
(
"
intercept selectBattleCmd
"
);
await
sendAIPredictAsResponse
(
selectBattleCmd
as
unknown
as
ygopro
.
StocGameMessage
);
await
sendAIPredictAsResponse
(
selectBattleCmd
as
unknown
as
ygopro
.
StocGameMessage
,
);
return
;
return
;
}
}
...
...
src/service/duel/selectCard.ts
View file @
e0e5c7a6
import
{
sendSelectMultiResponse
,
ygopro
}
from
"
@/api
"
;
import
{
sendSelectMultiResponse
,
ygopro
}
from
"
@/api
"
;
import
MsgSelectCard
=
ygopro
.
StocGameMessage
.
MsgSelectCard
;
import
MsgSelectCard
=
ygopro
.
StocGameMessage
.
MsgSelectCard
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
{
matStore
}
from
"
@/stores
"
;
import
{
displaySelectActionsModal
}
from
"
@/ui/Duel/Message/SelectActionsModal
"
;
import
{
displaySelectActionsModal
}
from
"
@/ui/Duel/Message/SelectActionsModal
"
;
import
{
fetchCheckCardMeta
}
from
"
../utils
"
;
import
{
fetchCheckCardMeta
}
from
"
../utils
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
{
matStore
}
from
"
@/stores
"
;
export
default
async
(
selectCard
:
MsgSelectCard
)
=>
{
export
default
async
(
selectCard
:
MsgSelectCard
)
=>
{
const
{
cancelable
,
min
,
max
,
cards
}
=
selectCard
;
const
{
cancelable
,
min
,
max
,
cards
}
=
selectCard
;
// TODO: handle release_param
// TODO: handle release_param
if
(
matStore
.
autoSelect
)
{
if
(
matStore
.
autoSelect
)
{
console
.
log
(
"
intercept selectCard
"
);
console
.
log
(
"
intercept selectCard
"
);
await
sendAIPredictAsResponse
(
selectCard
as
unknown
as
ygopro
.
StocGameMessage
);
await
sendAIPredictAsResponse
(
selectCard
as
unknown
as
ygopro
.
StocGameMessage
,
);
return
;
return
;
}
}
...
@@ -26,7 +26,6 @@ export default async (selectCard: MsgSelectCard) => {
...
@@ -26,7 +26,6 @@ export default async (selectCard: MsgSelectCard) => {
return
;
return
;
}
}
const
{
selecteds
,
mustSelects
,
selectables
}
=
await
fetchCheckCardMeta
(
const
{
selecteds
,
mustSelects
,
selectables
}
=
await
fetchCheckCardMeta
(
cards
,
cards
,
);
);
...
...
src/service/duel/selectChain.ts
View file @
e0e5c7a6
import
{
sendSelectSingleResponse
,
ygopro
}
from
"
@/api
"
;
import
{
sendSelectSingleResponse
,
ygopro
}
from
"
@/api
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
{
ChainSetting
,
fetchSelectHintMeta
,
matStore
}
from
"
@/stores
"
;
import
{
ChainSetting
,
fetchSelectHintMeta
,
matStore
}
from
"
@/stores
"
;
import
{
displaySelectActionsModal
}
from
"
@/ui/Duel/Message/SelectActionsModal
"
;
import
{
displaySelectActionsModal
}
from
"
@/ui/Duel/Message/SelectActionsModal
"
;
import
{
fetchCheckCardMeta
}
from
"
../utils
"
;
import
{
fetchCheckCardMeta
}
from
"
../utils
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
type
MsgSelectChain
=
ygopro
.
StocGameMessage
.
MsgSelectChain
;
type
MsgSelectChain
=
ygopro
.
StocGameMessage
.
MsgSelectChain
;
export
default
async
(
selectChain
:
MsgSelectChain
)
=>
{
export
default
async
(
selectChain
:
MsgSelectChain
)
=>
{
...
@@ -69,7 +69,9 @@ export default async (selectChain: MsgSelectChain) => {
...
@@ -69,7 +69,9 @@ export default async (selectChain: MsgSelectChain) => {
case
3
:
{
case
3
:
{
if
(
matStore
.
autoSelect
)
{
if
(
matStore
.
autoSelect
)
{
console
.
log
(
"
intercept selectChain
"
);
console
.
log
(
"
intercept selectChain
"
);
await
sendAIPredictAsResponse
(
selectChain
as
unknown
as
ygopro
.
StocGameMessage
);
await
sendAIPredictAsResponse
(
selectChain
as
unknown
as
ygopro
.
StocGameMessage
,
);
return
;
return
;
}
}
...
...
src/service/duel/selectEffectYn.ts
View file @
e0e5c7a6
import
{
fetchStrings
,
Region
,
type
ygopro
}
from
"
@/api
"
;
import
{
fetchStrings
,
Region
,
type
ygopro
}
from
"
@/api
"
;
import
{
CardMeta
,
fetchCard
}
from
"
@/api/cards
"
;
import
{
CardMeta
,
fetchCard
}
from
"
@/api/cards
"
;
import
{
displayYesNoModal
}
from
"
@/ui/Duel/Message
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
{
matStore
}
from
"
@/stores
"
;
import
{
matStore
}
from
"
@/stores
"
;
import
{
displayYesNoModal
}
from
"
@/ui/Duel/Message
"
;
type
MsgSelectEffectYn
=
ygopro
.
StocGameMessage
.
MsgSelectEffectYn
;
type
MsgSelectEffectYn
=
ygopro
.
StocGameMessage
.
MsgSelectEffectYn
;
...
@@ -10,7 +10,9 @@ type MsgSelectEffectYn = ygopro.StocGameMessage.MsgSelectEffectYn;
...
@@ -10,7 +10,9 @@ type MsgSelectEffectYn = ygopro.StocGameMessage.MsgSelectEffectYn;
export
default
async
(
selectEffectYn
:
MsgSelectEffectYn
)
=>
{
export
default
async
(
selectEffectYn
:
MsgSelectEffectYn
)
=>
{
if
(
matStore
.
autoSelect
)
{
if
(
matStore
.
autoSelect
)
{
console
.
log
(
"
intercept selectEffectYn
"
);
console
.
log
(
"
intercept selectEffectYn
"
);
await
sendAIPredictAsResponse
(
selectEffectYn
as
unknown
as
ygopro
.
StocGameMessage
);
await
sendAIPredictAsResponse
(
selectEffectYn
as
unknown
as
ygopro
.
StocGameMessage
,
);
return
;
return
;
}
}
...
...
src/service/duel/selectIdleCmd.ts
View file @
e0e5c7a6
import
{
ygopro
}
from
"
@/api
"
;
import
{
ygopro
}
from
"
@/api
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
{
import
{
cardStore
,
cardStore
,
type
Interactivity
,
type
Interactivity
,
InteractType
,
InteractType
,
matStore
,
matStore
,
}
from
"
@/stores
"
;
}
from
"
@/stores
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
MsgSelectIdleCmd
=
ygopro
.
StocGameMessage
.
MsgSelectIdleCmd
;
import
MsgSelectIdleCmd
=
ygopro
.
StocGameMessage
.
MsgSelectIdleCmd
;
...
@@ -20,7 +20,9 @@ export default async (selectIdleCmd: MsgSelectIdleCmd) => {
...
@@ -20,7 +20,9 @@ export default async (selectIdleCmd: MsgSelectIdleCmd) => {
if
(
matStore
.
autoSelect
)
{
if
(
matStore
.
autoSelect
)
{
console
.
log
(
"
intercept selectIdleCmd
"
);
console
.
log
(
"
intercept selectIdleCmd
"
);
await
sendAIPredictAsResponse
(
selectIdleCmd
as
unknown
as
ygopro
.
StocGameMessage
);
await
sendAIPredictAsResponse
(
selectIdleCmd
as
unknown
as
ygopro
.
StocGameMessage
,
);
return
;
return
;
}
}
...
...
src/service/duel/selectOption.ts
View file @
e0e5c7a6
...
@@ -5,9 +5,9 @@ import {
...
@@ -5,9 +5,9 @@ import {
sendSelectOptionResponse
,
sendSelectOptionResponse
,
type
ygopro
,
type
ygopro
,
}
from
"
@/api
"
;
}
from
"
@/api
"
;
import
{
displayOptionModal
}
from
"
@/ui/Duel/Message
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
{
matStore
}
from
"
@/stores
"
;
import
{
matStore
}
from
"
@/stores
"
;
import
{
displayOptionModal
}
from
"
@/ui/Duel/Message
"
;
export
default
async
(
selectOption
:
ygopro
.
StocGameMessage
.
MsgSelectOption
)
=>
{
export
default
async
(
selectOption
:
ygopro
.
StocGameMessage
.
MsgSelectOption
)
=>
{
const
options
=
selectOption
.
options
;
const
options
=
selectOption
.
options
;
...
@@ -18,7 +18,9 @@ export default async (selectOption: ygopro.StocGameMessage.MsgSelectOption) => {
...
@@ -18,7 +18,9 @@ export default async (selectOption: ygopro.StocGameMessage.MsgSelectOption) => {
if
(
matStore
.
autoSelect
)
{
if
(
matStore
.
autoSelect
)
{
console
.
log
(
"
intercept selectOption
"
);
console
.
log
(
"
intercept selectOption
"
);
await
sendAIPredictAsResponse
(
selectOption
as
unknown
as
ygopro
.
StocGameMessage
);
await
sendAIPredictAsResponse
(
selectOption
as
unknown
as
ygopro
.
StocGameMessage
,
);
return
;
return
;
}
}
...
...
src/service/duel/selectPlace.ts
View file @
e0e5c7a6
import
{
sendSelectPlaceResponse
,
ygopro
}
from
"
@/api
"
;
import
{
sendSelectPlaceResponse
,
ygopro
}
from
"
@/api
"
;
import
{
InteractType
,
placeStore
,
matStore
}
from
"
@/stores
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
{
InteractType
,
matStore
,
placeStore
}
from
"
@/stores
"
;
type
MsgSelectPlace
=
ygopro
.
StocGameMessage
.
MsgSelectPlace
;
type
MsgSelectPlace
=
ygopro
.
StocGameMessage
.
MsgSelectPlace
;
...
@@ -12,7 +12,9 @@ export default async (selectPlace: MsgSelectPlace) => {
...
@@ -12,7 +12,9 @@ export default async (selectPlace: MsgSelectPlace) => {
if
(
matStore
.
autoSelect
)
{
if
(
matStore
.
autoSelect
)
{
console
.
log
(
"
intercept selectPlace
"
);
console
.
log
(
"
intercept selectPlace
"
);
await
sendAIPredictAsResponse
(
selectPlace
as
unknown
as
ygopro
.
StocGameMessage
);
await
sendAIPredictAsResponse
(
selectPlace
as
unknown
as
ygopro
.
StocGameMessage
,
);
return
;
return
;
}
}
...
...
src/service/duel/selectPosition.ts
View file @
e0e5c7a6
import
{
ygopro
}
from
"
@/api
"
;
import
{
ygopro
}
from
"
@/api
"
;
import
{
displayPositionModal
}
from
"
@/ui/Duel/Message
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
{
matStore
}
from
"
@/stores
"
;
import
{
matStore
}
from
"
@/stores
"
;
import
{
displayPositionModal
}
from
"
@/ui/Duel/Message
"
;
type
MsgSelectPosition
=
ygopro
.
StocGameMessage
.
MsgSelectPosition
;
type
MsgSelectPosition
=
ygopro
.
StocGameMessage
.
MsgSelectPosition
;
export
default
async
(
selectPosition
:
MsgSelectPosition
)
=>
{
export
default
async
(
selectPosition
:
MsgSelectPosition
)
=>
{
if
(
matStore
.
autoSelect
)
{
if
(
matStore
.
autoSelect
)
{
console
.
log
(
"
intercept selectPosition
"
);
console
.
log
(
"
intercept selectPosition
"
);
await
sendAIPredictAsResponse
(
selectPosition
as
unknown
as
ygopro
.
StocGameMessage
);
await
sendAIPredictAsResponse
(
selectPosition
as
unknown
as
ygopro
.
StocGameMessage
,
);
return
;
return
;
}
}
...
...
src/service/duel/selectSum.ts
View file @
e0e5c7a6
...
@@ -10,7 +10,9 @@ import { matStore } from "@/stores";
...
@@ -10,7 +10,9 @@ import { matStore } from "@/stores";
export
default
async
(
selectSum
:
MsgSelectSum
)
=>
{
export
default
async
(
selectSum
:
MsgSelectSum
)
=>
{
if
(
matStore
.
autoSelect
)
{
if
(
matStore
.
autoSelect
)
{
console
.
log
(
"
intercept selectSum
"
);
console
.
log
(
"
intercept selectSum
"
);
await
sendAIPredictAsResponse
(
selectSum
as
unknown
as
ygopro
.
StocGameMessage
);
await
sendAIPredictAsResponse
(
selectSum
as
unknown
as
ygopro
.
StocGameMessage
,
);
return
;
return
;
}
}
...
...
src/service/duel/selectTribute.ts
View file @
e0e5c7a6
...
@@ -10,7 +10,9 @@ import { matStore } from "@/stores";
...
@@ -10,7 +10,9 @@ import { matStore } from "@/stores";
export
default
async
(
selectTribute
:
MsgSelectTribute
)
=>
{
export
default
async
(
selectTribute
:
MsgSelectTribute
)
=>
{
if
(
matStore
.
autoSelect
)
{
if
(
matStore
.
autoSelect
)
{
console
.
log
(
"
intercept selectTribute
"
);
console
.
log
(
"
intercept selectTribute
"
);
await
sendAIPredictAsResponse
(
selectTribute
as
unknown
as
ygopro
.
StocGameMessage
);
await
sendAIPredictAsResponse
(
selectTribute
as
unknown
as
ygopro
.
StocGameMessage
,
);
return
;
return
;
}
}
...
...
src/service/duel/selectUnselectCard.ts
View file @
e0e5c7a6
...
@@ -11,7 +11,9 @@ import { sendAIPredictAsResponse } from "@/service/duel/agent";
...
@@ -11,7 +11,9 @@ import { sendAIPredictAsResponse } from "@/service/duel/agent";
export
default
async
(
selectUnselectCards
:
MsgSelectUnselectCard
)
=>
{
export
default
async
(
selectUnselectCards
:
MsgSelectUnselectCard
)
=>
{
if
(
matStore
.
autoSelect
)
{
if
(
matStore
.
autoSelect
)
{
console
.
log
(
"
intercept selectUnselectCards
"
);
console
.
log
(
"
intercept selectUnselectCards
"
);
await
sendAIPredictAsResponse
(
selectUnselectCards
as
unknown
as
ygopro
.
StocGameMessage
);
await
sendAIPredictAsResponse
(
selectUnselectCards
as
unknown
as
ygopro
.
StocGameMessage
,
);
return
;
return
;
}
}
...
...
src/service/duel/selectYesNo.ts
View file @
e0e5c7a6
import
{
getStrings
,
ygopro
}
from
"
@/api
"
;
import
{
getStrings
,
ygopro
}
from
"
@/api
"
;
import
{
displayYesNoModal
}
from
"
@/ui/Duel/Message
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
{
sendAIPredictAsResponse
}
from
"
@/service/duel/agent
"
;
import
{
matStore
}
from
"
@/stores
"
;
import
{
matStore
}
from
"
@/stores
"
;
import
{
displayYesNoModal
}
from
"
@/ui/Duel/Message
"
;
type
MsgSelectYesNo
=
ygopro
.
StocGameMessage
.
MsgSelectYesNo
;
type
MsgSelectYesNo
=
ygopro
.
StocGameMessage
.
MsgSelectYesNo
;
export
default
async
(
selectYesNo
:
MsgSelectYesNo
)
=>
{
export
default
async
(
selectYesNo
:
MsgSelectYesNo
)
=>
{
if
(
matStore
.
autoSelect
)
{
if
(
matStore
.
autoSelect
)
{
console
.
log
(
"
intercept selectYesNo
"
);
console
.
log
(
"
intercept selectYesNo
"
);
await
sendAIPredictAsResponse
(
selectYesNo
as
unknown
as
ygopro
.
StocGameMessage
);
await
sendAIPredictAsResponse
(
selectYesNo
as
unknown
as
ygopro
.
StocGameMessage
,
);
return
;
return
;
}
}
...
...
src/service/duel/sortCard.ts
View file @
e0e5c7a6
import
{
fetchCard
,
ygopro
}
from
"
@/api
"
;
import
{
fetchCard
,
ygopro
}
from
"
@/api
"
;
import
{
displaySortCardModal
}
from
"
@/ui/Duel/Message
"
;
import
{
matStore
}
from
"
@/stores
"
;
import
{
matStore
}
from
"
@/stores
"
;
import
{
displaySortCardModal
}
from
"
@/ui/Duel/Message
"
;
type
MsgSortCard
=
ygopro
.
StocGameMessage
.
MsgSortCard
;
type
MsgSortCard
=
ygopro
.
StocGameMessage
.
MsgSortCard
;
...
...
src/service/duel/start.ts
View file @
e0e5c7a6
import
{
flatten
}
from
"
lodash-es
"
;
import
{
flatten
}
from
"
lodash-es
"
;
import
{
v4
as
v4uuid
}
from
"
uuid
"
;
import
{
v4
as
v4uuid
}
from
"
uuid
"
;
import
{
createDuel
,
ygopro
,
fetchCard
}
from
"
@/api
"
;
import
{
createDuel
,
fetchCard
,
ygopro
}
from
"
@/api
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
sleep
}
from
"
@/infra
"
;
import
{
sleep
}
from
"
@/infra
"
;
import
{
import
{
...
@@ -92,8 +92,7 @@ export default async (start: ygopro.StocGameMessage.MsgStart) => {
...
@@ -92,8 +92,7 @@ export default async (start: ygopro.StocGameMessage.MsgStart) => {
const
{
duelId
,
index
}
=
(
await
createDuel
())
!
;
const
{
duelId
,
index
}
=
(
await
createDuel
())
!
;
matStore
.
duelId
=
duelId
;
matStore
.
duelId
=
duelId
;
matStore
.
agentIndex
=
index
;
matStore
.
agentIndex
=
index
;
matStore
.
mainDeckCardMeta
=
matStore
.
mainDeck
matStore
.
mainDeckCardMeta
=
matStore
.
mainDeck
.
reduce
((
map
,
item
)
=>
{
.
reduce
((
map
,
item
)
=>
{
if
(
!
map
.
has
(
item
))
{
if
(
!
map
.
has
(
item
))
{
map
.
set
(
item
,
fetchCard
(
item
));
map
.
set
(
item
,
fetchCard
(
item
));
}
}
...
...
src/stores/matStore/types.ts
View file @
e0e5c7a6
...
@@ -50,7 +50,7 @@ export interface MatState {
...
@@ -50,7 +50,7 @@ export interface MatState {
/** 根据自己的先后手判断是否是自己 */
/** 根据自己的先后手判断是否是自己 */
isMe
:
(
player
:
number
)
=>
boolean
;
isMe
:
(
player
:
number
)
=>
boolean
;
turnCount
:
number
,
turnCount
:
number
;
duelId
:
string
;
duelId
:
string
;
agentIndex
:
number
;
agentIndex
:
number
;
prevActionIndex
:
number
;
prevActionIndex
:
number
;
...
...
src/ui/Duel/PlayMat/Menu/index.tsx
View file @
e0e5c7a6
...
@@ -3,9 +3,9 @@ import {
...
@@ -3,9 +3,9 @@ import {
CheckOutlined
,
CheckOutlined
,
CloseCircleFilled
,
CloseCircleFilled
,
MessageFilled
,
MessageFilled
,
StepForwardFilled
,
RobotFilled
,
RobotFilled
,
RobotOutlined
,
RobotOutlined
,
StepForwardFilled
,
}
from
"
@ant-design/icons
"
;
}
from
"
@ant-design/icons
"
;
import
{
import
{
Button
,
Button
,
...
...
src/ui/WaitRoom/index.tsx
View file @
e0e5c7a6
...
@@ -27,12 +27,12 @@ import {
...
@@ -27,12 +27,12 @@ import {
accountStore
,
accountStore
,
deckStore
,
deckStore
,
IDeck
,
IDeck
,
matStore
,
Player
,
Player
,
resetUniverse
,
resetUniverse
,
RoomStage
,
RoomStage
,
roomStore
,
roomStore
,
sideStore
,
sideStore
,
matStore
,
}
from
"
@/stores
"
;
}
from
"
@/stores
"
;
import
{
Background
,
IconFont
,
Select
,
SpecialButton
}
from
"
@/ui/Shared
"
;
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