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
baichixing
Neos
Commits
80533877
Commit
80533877
authored
May 28, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix move
parent
744058e2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
155 deletions
+28
-155
src/service/duel/move.ts
src/service/duel/move.ts
+28
-155
No files found.
src/service/duel/move.ts
View file @
80533877
import
{
v4
as
v4uuid
}
from
"
uuid
"
;
import
{
fetchCard
,
ygopro
}
from
"
@/api
"
;
import
{
fetchCard
,
ygopro
}
from
"
@/api
"
;
import
{
cardStore
,
CardType
,
fetchOverlayMeta
,
store
}
from
"
@/stores
"
;
import
{
cardStore
,
CardType
}
from
"
@/stores
"
;
type
MsgMove
=
ygopro
.
StocGameMessage
.
MsgMove
;
type
MsgMove
=
ygopro
.
StocGameMessage
.
MsgMove
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
sleep
}
from
"
@/infra
"
;
import
{
REASON_MATERIAL
}
from
"
../../common
"
;
import
{
REASON_MATERIAL
}
from
"
../../common
"
;
const
{
matStore
}
=
store
;
const
{
HAND
,
GRAVE
,
REMOVED
,
DECK
,
EXTRA
,
MZONE
,
TZONE
,
OVERLAY
}
=
const
NeosConfig
=
useConfig
();
const
{
HAND
,
GRAVE
,
REMOVED
,
DECK
,
EXTRA
,
MZONE
,
SZONE
,
TZONE
,
OVERLAY
}
=
ygopro
.
CardZone
;
ygopro
.
CardZone
;
const
OVERLAY_STACK
:
{
uuid
:
string
;
code
:
number
;
sequence
:
number
}[]
=
[];
const
overlayStack
:
CardType
[]
=
[];
const
overlayStack
:
CardType
[]
=
[];
export
default
async
(
move
:
MsgMove
)
=>
{
export
default
async
(
move
:
MsgMove
)
=>
{
...
@@ -26,158 +17,24 @@ export default async (move: MsgMove) => {
...
@@ -26,158 +17,24 @@ export default async (move: MsgMove) => {
// FIXME: 考虑超量素材的情况
// FIXME: 考虑超量素材的情况
// FIXME:需要考虑【卡名当作另一张卡】的情况
let
uuid
;
let
chainIndex
;
switch
(
from
.
location
)
{
case
ygopro
.
CardZone
.
MZONE
:
case
ygopro
.
CardZone
.
SZONE
:
{
// 魔陷和怪兽需要清掉占用、清掉超量素材
const
target
=
matStore
.
in
(
from
.
location
).
of
(
from
.
controler
)[
from
.
sequence
];
target
.
occupant
=
undefined
;
target
.
overlay_materials
=
[];
uuid
=
target
.
uuid
;
chainIndex
=
target
.
chainIndex
;
// 需要重新分配UUID
target
.
uuid
=
v4uuid
();
break
;
}
case
ygopro
.
CardZone
.
REMOVED
:
case
ygopro
.
CardZone
.
GRAVE
:
case
ygopro
.
CardZone
.
HAND
:
case
ygopro
.
CardZone
.
DECK
:
case
ygopro
.
CardZone
.
EXTRA
:
{
// 其余区域就是在list删掉这张卡
const
removed
=
matStore
.
in
(
from
.
location
)
.
of
(
from
.
controler
)
.
remove
(
from
.
sequence
);
if
(
removed
===
undefined
)
{
console
.
warn
(
`remove from matStore return undefined, location=
${
from
}
`
);
}
uuid
=
removed
.
uuid
;
chainIndex
=
removed
.
chainIndex
;
break
;
}
// 仅仅去除超量素材
case
ygopro
.
CardZone
.
OVERLAY
:
{
const
target
=
matStore
.
monsters
.
of
(
from
.
controler
)[
from
.
sequence
];
if
(
target
&&
target
.
overlay_materials
)
{
target
.
overlay_materials
.
splice
(
from
.
overlay_sequence
,
1
);
}
// 如果是超量素材的移动,暂时采用妥协的设计,重新生成uuid
// FIXME: 后续需要正确处理超量素材的移动
uuid
=
v4uuid
();
break
;
}
}
if
(
chainIndex
)
{
// 如果`chainIndex`不为空,则连锁位置变了,需要更新连锁栈的状态
matStore
.
chains
[
chainIndex
-
1
]
=
to
;
}
switch
(
to
.
location
)
{
// @ts-ignore
case
ygopro
.
CardZone
.
MZONE
:
{
// 设置超量素材
const
overlayMetarials
=
OVERLAY_STACK
.
splice
(
0
,
OVERLAY_STACK
.
length
);
const
sorted
=
overlayMetarials
.
sort
((
a
,
b
)
=>
a
.
sequence
-
b
.
sequence
)
.
map
((
overlay
)
=>
overlay
.
code
);
fetchOverlayMeta
(
to
.
controler
,
to
.
sequence
,
sorted
);
// 设置Occupant,和魔陷区/其他区共用一个逻辑,特地不写break
}
case
ygopro
.
CardZone
.
SZONE
:
{
matStore
.
in
(
to
.
location
)
.
of
(
to
.
controler
)
.
setOccupant
(
to
.
sequence
,
code
,
to
.
position
,
true
);
if
(
uuid
)
{
// 设置UUID
matStore
.
in
(
to
.
location
).
of
(
to
.
controler
)[
to
.
sequence
].
uuid
=
uuid
;
}
// 设置连锁序号
matStore
.
in
(
to
.
location
).
of
(
to
.
controler
)[
to
.
sequence
].
chainIndex
=
chainIndex
;
await
sleep
(
NeosConfig
.
ui
.
moveDelay
);
matStore
.
setFocus
(
to
,
false
);
break
;
}
case
ygopro
.
CardZone
.
REMOVED
:
case
ygopro
.
CardZone
.
GRAVE
:
case
ygopro
.
CardZone
.
DECK
:
case
ygopro
.
CardZone
.
EXTRA
:
{
if
(
uuid
)
{
matStore
.
in
(
to
.
location
)
.
of
(
to
.
controler
)
.
insert
(
uuid
,
code
,
to
.
sequence
,
to
.
position
,
false
,
chainIndex
);
}
break
;
}
case
ygopro
.
CardZone
.
HAND
:
{
if
(
uuid
)
{
matStore
.
in
(
to
.
location
)
.
of
(
to
.
controler
)
.
insert
(
uuid
,
code
,
to
.
sequence
,
ygopro
.
CardPosition
.
FACEUP_ATTACK
,
true
,
chainIndex
);
await
sleep
(
NeosConfig
.
ui
.
moveDelay
);
matStore
.
setFocus
(
to
,
false
);
}
break
;
}
case
ygopro
.
CardZone
.
OVERLAY
:
{
if
(
reason
==
REASON_MATERIAL
&&
uuid
)
{
// 超量素材在进行超量召唤时,若玩家未选择超量怪兽的位置,会“沉到决斗盘下面”,`reason`字段值是`REASON_MATERIAL`
// 这时候将它们放到一个栈中,待超量怪兽的Move消息到来时从栈中获取超量素材补充到状态中
OVERLAY_STACK
.
push
({
uuid
,
code
,
sequence
:
to
.
overlay_sequence
});
}
else
{
// 其他情况下,比如“宵星的机神 丁吉尔苏”的“补充超量素材”效果,直接更新状态中
fetchOverlayMeta
(
to
.
controler
,
to
.
sequence
,
[
code
],
true
);
}
break
;
}
default
:
{
console
.
log
(
`Unhandled zone type
${
to
.
location
}
`
);
break
;
}
}
// card store
const
fromCards
=
cardStore
.
at
(
from
.
location
,
from
.
controler
);
const
fromCards
=
cardStore
.
at
(
from
.
location
,
from
.
controler
);
const
toCards
=
cardStore
.
at
(
to
.
location
,
to
.
controler
);
const
toCards
=
cardStore
.
at
(
to
.
location
,
to
.
controler
);
// TODO: 这段逻辑有点迷惑,后面问问作者
const
fromZone
=
const
fromZone
=
move
.
from
.
toArray
()
[
1
]
===
undefined
move
.
from
.
toArray
()
.
at
(
1
)
===
undefined
?
ygopro
.
CardZone
.
TZONE
?
ygopro
.
CardZone
.
TZONE
:
from
.
location
;
:
from
.
location
;
const
toZone
=
const
toZone
=
move
.
to
.
toArray
()
[
1
]
===
undefined
?
ygopro
.
CardZone
.
TZONE
:
to
.
location
;
move
.
to
.
toArray
()
.
at
(
1
)
===
undefined
?
ygopro
.
CardZone
.
TZONE
:
to
.
location
;
// log出来看看,后期删掉即可
// log出来看看,后期删掉即可
(
async
()
=>
{
(
async
()
=>
{
const
{
text
}
=
await
fetchCard
(
code
);
const
{
text
}
=
await
fetchCard
(
code
);
console
.
warn
(
console
.
info
(
`
${
text
.
name
}
${
ygopro
.
CardZone
[
fromZone
]}
:
${
from
.
sequence
}
→
${
ygopro
.
CardZone
[
toZone
]}
:
${
to
.
sequence
}
`
`
${
text
.
name
}
${
ygopro
.
CardZone
[
fromZone
]}
:
${
from
.
sequence
}
→
${
ygopro
.
CardZone
[
toZone
]}
:
${
to
.
sequence
}
`
);
);
// console.
warn
("overlay", from.overlay_sequence, to.overlay_sequence);
// console.
info
("overlay", from.overlay_sequence, to.overlay_sequence);
})();
})();
let
target
:
CardType
;
let
target
:
CardType
;
...
@@ -188,11 +45,26 @@ export default async (move: MsgMove) => {
...
@@ -188,11 +45,26 @@ export default async (move: MsgMove) => {
target
=
cardStore
.
at
(
TZONE
,
from
.
controler
)[
0
];
// 必有,随便取一个没用到的token
target
=
cardStore
.
at
(
TZONE
,
from
.
controler
)[
0
];
// 必有,随便取一个没用到的token
}
else
if
(
fromZone
===
OVERLAY
)
{
}
else
if
(
fromZone
===
OVERLAY
)
{
// 超量素材的去除
// 超量素材的去除
const
xyzMoster
=
cardStore
.
at
(
MZONE
,
from
.
controler
,
from
.
sequence
);
const
xyzMonster
=
cardStore
.
at
(
MZONE
,
from
.
controler
,
from
.
sequence
);
target
=
xyzMoster
.
overlayMaterials
.
splice
(
from
.
overlay_sequence
,
1
)[
0
];
if
(
xyzMonster
)
{
target
.
xyzMonster
=
undefined
;
target
=
xyzMonster
.
overlayMaterials
.
splice
(
from
.
overlay_sequence
,
1
)[
0
];
target
.
xyzMonster
=
undefined
;
}
else
{
console
.
warn
(
`<Move>xyzMonster from zone=
${
MZONE
}
, controller=
${
from
.
controler
}
, sequence=
${
from
.
sequence
}
is null`
);
return
;
}
}
else
{
}
else
{
target
=
cardStore
.
at
(
fromZone
,
from
.
controler
,
from
.
sequence
);
const
card
=
cardStore
.
at
(
fromZone
,
from
.
controler
,
from
.
sequence
);
if
(
card
)
{
target
=
card
;
}
else
{
console
.
warn
(
`<Move>card from zone=
${
fromZone
}
, controller=
${
from
.
controler
}
sequence=
${
from
.
sequence
}
is null`
);
return
;
}
}
}
// 超量
// 超量
...
@@ -212,6 +84,7 @@ export default async (move: MsgMove) => {
...
@@ -212,6 +84,7 @@ export default async (move: MsgMove) => {
}
}
// 维护sequence
// 维护sequence
// TODO: 这些逻辑是不是可以考虑沉淀到store里面
if
([
HAND
,
GRAVE
,
REMOVED
,
DECK
,
EXTRA
].
includes
(
fromZone
))
if
([
HAND
,
GRAVE
,
REMOVED
,
DECK
,
EXTRA
].
includes
(
fromZone
))
fromCards
.
forEach
((
c
)
=>
c
.
sequence
>
from
.
sequence
&&
c
.
sequence
--
);
fromCards
.
forEach
((
c
)
=>
c
.
sequence
>
from
.
sequence
&&
c
.
sequence
--
);
if
([
HAND
,
GRAVE
,
REMOVED
,
DECK
,
EXTRA
].
includes
(
toZone
))
if
([
HAND
,
GRAVE
,
REMOVED
,
DECK
,
EXTRA
].
includes
(
toZone
))
...
@@ -252,7 +125,7 @@ export default async (move: MsgMove) => {
...
@@ -252,7 +125,7 @@ export default async (move: MsgMove) => {
// 超量怪兽失去超量素材
// 超量怪兽失去超量素材
// - 超量素材:fromZone === OVERLAY
// - 超量素材:fromZone === OVERLAY
// 超量怪兽(xyzMonster)是cardStore.at(MZONE, from.controler, from.sequence)
// 超量怪兽(xyzMonster)是cardStore.at(MZONE, from.controler, from.sequence)
// 超量素材(target)是xyzMoster.overlayMaterials[from.overlay_sequence]
// 超量素材(target)是xyzMo
n
ster.overlayMaterials[from.overlay_sequence]
// 在超量召唤/超量素材更改时候,target是超量素材,但同时也要维护超量怪兽的overlayMaterials
// 在超量召唤/超量素材更改时候,target是超量素材,但同时也要维护超量怪兽的overlayMaterials
...
...
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