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
love_飞影
Neos
Commits
42d4cf52
Commit
42d4cf52
authored
Jun 03, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix token
parent
fc8963d6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
33 deletions
+39
-33
src/common.ts
src/common.ts
+1
-1
src/service/duel/move.ts
src/service/duel/move.ts
+38
-32
No files found.
src/common.ts
View file @
42d4cf52
...
@@ -16,7 +16,7 @@ const TYPE_UNION = 0x400; //
...
@@ -16,7 +16,7 @@ const TYPE_UNION = 0x400; //
const
TYPE_DUAL
=
0x800
;
//
const
TYPE_DUAL
=
0x800
;
//
const
TYPE_TUNER
=
0x1000
;
//
const
TYPE_TUNER
=
0x1000
;
//
const
TYPE_SYNCHRO
=
0x2000
;
//
const
TYPE_SYNCHRO
=
0x2000
;
//
const
TYPE_TOKEN
=
0x4000
;
//
export
const
TYPE_TOKEN
=
0x4000
;
//
const
TYPE_QUICKPLAY
=
0x10000
;
//
const
TYPE_QUICKPLAY
=
0x10000
;
//
const
TYPE_CONTINUOUS
=
0x20000
;
//
const
TYPE_CONTINUOUS
=
0x20000
;
//
const
TYPE_EQUIP
=
0x40000
;
//
const
TYPE_EQUIP
=
0x40000
;
//
...
...
src/service/duel/move.ts
View file @
42d4cf52
...
@@ -2,7 +2,7 @@ import { fetchCard, ygopro } from "@/api";
...
@@ -2,7 +2,7 @@ import { fetchCard, ygopro } from "@/api";
import
{
eventbus
,
Task
}
from
"
@/infra
"
;
import
{
eventbus
,
Task
}
from
"
@/infra
"
;
import
{
cardStore
,
CardType
}
from
"
@/stores
"
;
import
{
cardStore
,
CardType
}
from
"
@/stores
"
;
import
{
REASON_MATERIAL
}
from
"
../../common
"
;
import
{
REASON_MATERIAL
,
TYPE_TOKEN
}
from
"
../../common
"
;
type
MsgMove
=
ygopro
.
StocGameMessage
.
MsgMove
;
type
MsgMove
=
ygopro
.
StocGameMessage
.
MsgMove
;
const
{
HAND
,
GRAVE
,
REMOVED
,
DECK
,
EXTRA
,
MZONE
,
TZONE
}
=
ygopro
.
CardZone
;
const
{
HAND
,
GRAVE
,
REMOVED
,
DECK
,
EXTRA
,
MZONE
,
TZONE
}
=
ygopro
.
CardZone
;
...
@@ -10,7 +10,7 @@ const { HAND, GRAVE, REMOVED, DECK, EXTRA, MZONE, TZONE } = ygopro.CardZone;
...
@@ -10,7 +10,7 @@ const { HAND, GRAVE, REMOVED, DECK, EXTRA, MZONE, TZONE } = ygopro.CardZone;
const
overlayStack
:
ygopro
.
CardLocation
[]
=
[];
const
overlayStack
:
ygopro
.
CardLocation
[]
=
[];
/*
/*
* 超量素材的`Location`:
*
*
超量素材的`Location`:
* - 位置是跟随超量怪兽的,通过`is_overlay`字段判断是否是超量素材,`overlay_sequence`是在某个超量怪兽下面的超量序列;
* - 位置是跟随超量怪兽的,通过`is_overlay`字段判断是否是超量素材,`overlay_sequence`是在某个超量怪兽下面的超量序列;
* - 超量怪兽移动,超量素材需要跟着移动,并且需要前端自己维护这个关系,因为当超量怪兽移动时,
* - 超量怪兽移动,超量素材需要跟着移动,并且需要前端自己维护这个关系,因为当超量怪兽移动时,
* 后端不会针对超量素材传`MSG_MOVE`;
* 后端不会针对超量素材传`MSG_MOVE`;
...
@@ -20,6 +20,13 @@ const overlayStack: ygopro.CardLocation[] = [];
...
@@ -20,6 +20,13 @@ const overlayStack: ygopro.CardLocation[] = [];
* 因此前端需要自己维护,现在的做法采用了`入栈-出栈`的方式。
* 因此前端需要自己维护,现在的做法采用了`入栈-出栈`的方式。
* - 当场上的超量怪兽离开`MZONE`,比如送墓/除外时,超量素材会跟着超量怪兽移动,这时候它们的`sequence`还是一样的,
* - 当场上的超量怪兽离开`MZONE`,比如送墓/除外时,超量素材会跟着超量怪兽移动,这时候它们的`sequence`还是一样的,
* 然后后端会传`MSG_MOVE`,对超量素材的位置进行修正。
* 然后后端会传`MSG_MOVE`,对超量素材的位置进行修正。
*
* * 衍生物的`Location`
* - 在neos视角中,衍生物放在`TZONE`区域;
* - 在ygopro后端视角中,衍生物放在`DECK`区域;
* - 当衍生物进场和离场的时候,from和to的zone都是`DECK`,因此这里手动修改;
* - 通过`meta.data.type`判断一张卡是否是衍生物。
*
* */
* */
export
default
async
(
move
:
MsgMove
)
=>
{
export
default
async
(
move
:
MsgMove
)
=>
{
const
code
=
move
.
code
;
const
code
=
move
.
code
;
...
@@ -27,24 +34,25 @@ export default async (move: MsgMove) => {
...
@@ -27,24 +34,25 @@ export default async (move: MsgMove) => {
const
to
=
move
.
to
;
const
to
=
move
.
to
;
const
reason
=
move
.
reason
;
const
reason
=
move
.
reason
;
const
fromCards
=
cardStore
.
at
(
from
.
zone
,
from
.
controler
);
const
meta
=
await
fetchCard
(
code
);
const
toCards
=
cardStore
.
at
(
to
.
zone
,
to
.
controler
);
if
(
meta
.
data
.
type
!==
undefined
&&
(
meta
.
data
.
type
&
TYPE_TOKEN
)
>
0
)
{
// 衍生物
// TODO:
if
(
from
.
zone
==
DECK
)
{
// 1. 是否能有更solid的衍生物判断方式?
// 衍生物出场的场景,设置`from.zone`为`TZONE`
// 2. 应该判断是否是`TZONE`应该收敛到`readCardLocation`里面
from
.
zone
=
TZONE
;
const
fromZone
=
}
move
.
from
.
toArray
().
at
(
1
)
===
undefined
?
ygopro
.
CardZone
.
TZONE
:
from
.
zone
;
if
(
to
.
zone
==
DECK
)
{
let
toZone
=
// 衍生物离开场上的场合,设置`to.zone`为`TZONE`
move
.
to
.
toArray
().
at
(
1
)
===
undefined
?
ygopro
.
CardZone
.
TZONE
:
to
.
zone
;
to
.
zone
=
TZONE
;
}
}
// log出来看看,后期删掉即可
// log出来看看,后期删掉即可
await
(
async
()
=>
{
await
(
async
()
=>
{
const
{
text
}
=
await
fetchCard
(
code
);
console
.
color
(
"
green
"
)(
console
.
color
(
"
green
"
)(
`
${
text
.
name
}
${
ygopro
.
CardZone
[
fromZ
one
]}
:
${
from
.
sequence
}
:
${
`
${
meta
.
text
.
name
}
${
ygopro
.
CardZone
[
from
.
z
one
]}
:
${
from
.
sequence
}
:
${
from
.
is_overlay
?
from
.
overlay_sequence
:
""
from
.
is_overlay
?
from
.
overlay_sequence
:
""
}
→
${
ygopro
.
CardZone
[
to
Z
one
]}
:
${
to
.
sequence
}
:
${
}
→
${
ygopro
.
CardZone
[
to
.
z
one
]}
:
${
to
.
sequence
}
:
${
to
.
is_overlay
?
to
.
overlay_sequence
:
""
to
.
is_overlay
?
to
.
overlay_sequence
:
""
}
`
}
`
);
);
...
@@ -52,14 +60,10 @@ export default async (move: MsgMove) => {
...
@@ -52,14 +60,10 @@ export default async (move: MsgMove) => {
let
target
:
CardType
;
let
target
:
CardType
;
// 处理token
if
(
from
.
is_overlay
)
{
if
(
fromZone
===
TZONE
)
{
// 召唤 token
target
=
cardStore
.
at
(
TZONE
,
from
.
controler
)[
0
];
// 必有,随便取一个没用到的token
}
else
if
(
from
.
is_overlay
)
{
// 超量素材的去除
// 超量素材的去除
const
overlayMaterial
=
cardStore
.
at
(
const
overlayMaterial
=
cardStore
.
at
(
from
Z
one
,
from
.
z
one
,
from
.
controler
,
from
.
controler
,
from
.
sequence
,
from
.
sequence
,
from
.
overlay_sequence
from
.
overlay_sequence
...
@@ -68,33 +72,32 @@ export default async (move: MsgMove) => {
...
@@ -68,33 +72,32 @@ export default async (move: MsgMove) => {
target
=
overlayMaterial
;
target
=
overlayMaterial
;
}
else
{
}
else
{
console
.
warn
(
console
.
warn
(
`<Move>overlayMaterial from zone=
${
from
Z
one
}
, controller=
${
from
.
controler
}
,
`<Move>overlayMaterial from zone=
${
from
.
z
one
}
, controller=
${
from
.
controler
}
,
sequence=
${
from
.
sequence
}
, overlay_sequence=
${
from
.
overlay_sequence
}
is null`
sequence=
${
from
.
sequence
}
, overlay_sequence=
${
from
.
overlay_sequence
}
is null`
);
);
return
;
return
;
}
}
}
else
{
}
else
{
const
card
=
cardStore
.
at
(
from
Z
one
,
from
.
controler
,
from
.
sequence
);
const
card
=
cardStore
.
at
(
from
.
z
one
,
from
.
controler
,
from
.
sequence
);
if
(
card
)
{
if
(
card
)
{
target
=
card
;
target
=
card
;
}
else
{
}
else
{
console
.
warn
(
console
.
warn
(
`<Move>card from zone=
${
from
Z
one
}
, controller=
${
from
.
controler
}
sequence=
${
from
.
sequence
}
is null`
`<Move>card from zone=
${
from
.
z
one
}
, controller=
${
from
.
controler
}
sequence=
${
from
.
sequence
}
is null`
);
);
console
.
info
(
cardStore
.
at
(
from
Z
one
,
from
.
controler
));
console
.
info
(
cardStore
.
at
(
from
.
z
one
,
from
.
controler
));
return
;
return
;
}
}
}
}
// 超量
// 超量
if
(
to
.
is_overlay
&&
from
Z
one
==
MZONE
)
{
if
(
to
.
is_overlay
&&
from
.
z
one
==
MZONE
)
{
// 准备超量召唤,超量素材入栈
// 准备超量召唤,超量素材入栈
if
(
reason
==
REASON_MATERIAL
)
{
if
(
reason
==
REASON_MATERIAL
)
{
toZone
=
MZONE
;
to
.
zone
=
MZONE
;
to
.
zone
=
MZONE
;
overlayStack
.
push
(
to
);
overlayStack
.
push
(
to
);
}
}
}
else
if
(
to
Z
one
===
MZONE
&&
overlayStack
.
length
)
{
}
else
if
(
to
.
z
one
===
MZONE
&&
overlayStack
.
length
)
{
// 超量召唤
// 超量召唤
console
.
color
(
"
grey
"
)(
`超量召唤!overlayStack=
${
overlayStack
}
`
);
console
.
color
(
"
grey
"
)(
`超量召唤!overlayStack=
${
overlayStack
}
`
);
...
@@ -123,11 +126,14 @@ export default async (move: MsgMove) => {
...
@@ -123,11 +126,14 @@ export default async (move: MsgMove) => {
}
}
// 维护sequence
// 维护sequence
if
([
HAND
,
GRAVE
,
REMOVED
,
DECK
,
EXTRA
].
includes
(
fromZone
))
const
fromCards
=
cardStore
.
at
(
from
.
zone
,
from
.
controler
);
const
toCards
=
cardStore
.
at
(
to
.
zone
,
to
.
controler
);
if
([
HAND
,
GRAVE
,
REMOVED
,
DECK
,
EXTRA
,
TZONE
].
includes
(
from
.
zone
))
fromCards
.
forEach
(
fromCards
.
forEach
(
(
c
)
=>
c
.
location
.
sequence
>
from
.
sequence
&&
c
.
location
.
sequence
--
(
c
)
=>
c
.
location
.
sequence
>
from
.
sequence
&&
c
.
location
.
sequence
--
);
);
if
([
HAND
,
GRAVE
,
REMOVED
,
DECK
,
EXTRA
].
includes
(
toZ
one
))
if
([
HAND
,
GRAVE
,
REMOVED
,
DECK
,
EXTRA
,
TZONE
].
includes
(
to
.
z
one
))
toCards
.
forEach
(
toCards
.
forEach
(
(
c
)
=>
c
.
location
.
sequence
>=
to
.
sequence
&&
c
.
location
.
sequence
++
(
c
)
=>
c
.
location
.
sequence
>=
to
.
sequence
&&
c
.
location
.
sequence
++
);
);
...
@@ -153,7 +159,7 @@ export default async (move: MsgMove) => {
...
@@ -153,7 +159,7 @@ export default async (move: MsgMove) => {
const
promises
:
Promise
<
unknown
>
[]
=
[];
const
promises
:
Promise
<
unknown
>
[]
=
[];
promises
.
push
(
eventbus
.
call
(
Task
.
Move
,
target
.
uuid
));
promises
.
push
(
eventbus
.
call
(
Task
.
Move
,
target
.
uuid
));
// 如果from或者to是手卡,那么需要刷新除了这张卡之外,这个玩家的所有手卡
// 如果from或者to是手卡,那么需要刷新除了这张卡之外,这个玩家的所有手卡
if
([
from
Zone
,
toZ
one
].
includes
(
HAND
))
{
if
([
from
.
zone
,
to
.
z
one
].
includes
(
HAND
))
{
cardStore
.
at
(
HAND
,
target
.
location
.
controler
).
forEach
((
card
)
=>
{
cardStore
.
at
(
HAND
,
target
.
location
.
controler
).
forEach
((
card
)
=>
{
if
(
card
.
uuid
!==
target
.
uuid
)
if
(
card
.
uuid
!==
target
.
uuid
)
promises
.
push
(
eventbus
.
call
(
Task
.
Move
,
card
.
uuid
));
promises
.
push
(
eventbus
.
call
(
Task
.
Move
,
card
.
uuid
));
...
@@ -168,7 +174,7 @@ export default async (move: MsgMove) => {
...
@@ -168,7 +174,7 @@ export default async (move: MsgMove) => {
from
.
controler
,
from
.
controler
,
from
.
sequence
from
.
sequence
))
{
))
{
overlay
.
location
.
zone
=
to
Z
one
;
overlay
.
location
.
zone
=
to
.
z
one
;
overlay
.
location
.
controler
=
to
.
controler
;
overlay
.
location
.
controler
=
to
.
controler
;
overlay
.
location
.
sequence
=
to
.
sequence
;
overlay
.
location
.
sequence
=
to
.
sequence
;
...
...
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