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
9e5c6f5c
Commit
9e5c6f5c
authored
Jun 03, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use location in CardType
parent
4eda5276
Pipeline
#22068
failed with stages
in 8 minutes and 34 seconds
Changes
14
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
76 additions
and
62 deletions
+76
-62
src/service/duel/confirmCards.ts
src/service/duel/confirmCards.ts
+1
-1
src/service/duel/draw.ts
src/service/duel/draw.ts
+2
-2
src/service/duel/move.ts
src/service/duel/move.ts
+11
-7
src/service/duel/posChange.ts
src/service/duel/posChange.ts
+1
-1
src/service/duel/shuffleHand.ts
src/service/duel/shuffleHand.ts
+1
-1
src/service/duel/start.ts
src/service/duel/start.ts
+10
-8
src/service/duel/updateData.ts
src/service/duel/updateData.ts
+4
-2
src/stores/cardStore.ts
src/stores/cardStore.ts
+8
-10
src/ui/Duel/PlayMat/Card/index.tsx
src/ui/Duel/PlayMat/Card/index.tsx
+8
-5
src/ui/Duel/PlayMat/Card/springs/focus.ts
src/ui/Duel/PlayMat/Card/springs/focus.ts
+2
-2
src/ui/Duel/PlayMat/Card/springs/moveToDeck.ts
src/ui/Duel/PlayMat/Card/springs/moveToDeck.ts
+7
-6
src/ui/Duel/PlayMat/Card/springs/moveToGround.ts
src/ui/Duel/PlayMat/Card/springs/moveToGround.ts
+10
-6
src/ui/Duel/PlayMat/Card/springs/moveToHand.ts
src/ui/Duel/PlayMat/Card/springs/moveToHand.ts
+7
-7
src/ui/Duel/PlayMat/Card/springs/moveToOutside.ts
src/ui/Duel/PlayMat/Card/springs/moveToOutside.ts
+4
-4
No files found.
src/service/duel/confirmCards.ts
View file @
9e5c6f5c
...
...
@@ -13,7 +13,7 @@ export default async (confirmCards: ygopro.StocGameMessage.MsgConfirmCards) => {
const
meta
=
await
fetchCard
(
card
.
code
);
target
.
meta
=
meta
;
// 设置`position`,否则会横放
target
.
position
=
ygopro
.
CardPosition
.
ATTACK
;
target
.
location
.
position
=
ygopro
.
CardPosition
.
ATTACK
;
}
else
{
console
.
warn
(
`card of
${
card
}
is null`
);
}
...
...
src/service/duel/draw.ts
View file @
9e5c6f5c
...
...
@@ -21,8 +21,8 @@ export default async (draw: ygopro.StocGameMessage.MsgDraw) => {
const
meta
=
await
fetchCard
(
code
);
card
.
code
=
code
;
card
.
meta
=
meta
;
card
.
zone
=
ygopro
.
CardZone
.
HAND
;
card
.
sequence
=
Number
(
idx
)
+
handsLength
;
card
.
location
.
zone
=
ygopro
.
CardZone
.
HAND
;
card
.
location
.
sequence
=
Number
(
idx
)
+
handsLength
;
}
if
(
cnt
++
<
2
)
{
...
...
src/service/duel/move.ts
View file @
9e5c6f5c
...
...
@@ -95,23 +95,27 @@ export default async (move: MsgMove) => {
// 维护sequence
// TODO: 这些逻辑是不是可以考虑沉淀到store里面
if
([
HAND
,
GRAVE
,
REMOVED
,
DECK
,
EXTRA
].
includes
(
fromZone
))
fromCards
.
forEach
((
c
)
=>
c
.
sequence
>
from
.
sequence
&&
c
.
sequence
--
);
fromCards
.
forEach
(
(
c
)
=>
c
.
location
.
sequence
>
from
.
sequence
&&
c
.
location
.
sequence
--
);
if
([
HAND
,
GRAVE
,
REMOVED
,
DECK
,
EXTRA
].
includes
(
toZone
))
toCards
.
forEach
((
c
)
=>
c
.
sequence
>=
to
.
sequence
&&
c
.
sequence
++
);
toCards
.
forEach
(
(
c
)
=>
c
.
location
.
sequence
>=
to
.
sequence
&&
c
.
location
.
sequence
++
);
// 更新信息
target
.
zone
=
toZone
;
target
.
control
ler
=
to
.
controler
;
target
.
sequence
=
to
.
sequence
;
target
.
location
.
zone
=
toZone
;
target
.
location
.
contro
ler
=
to
.
controler
;
target
.
location
.
sequence
=
to
.
sequence
;
target
.
code
=
code
;
target
.
position
=
to
.
position
;
target
.
location
.
position
=
to
.
position
;
// 维护完了之后,开始动画
const
promises
:
Promise
<
unknown
>
[]
=
[];
promises
.
push
(
eventbus
.
call
(
Task
.
Move
,
target
.
uuid
));
// 如果from或者to是手卡,那么需要刷新除了这张卡之外,这个玩家的所有手卡
if
([
fromZone
,
toZone
].
includes
(
HAND
))
{
cardStore
.
at
(
HAND
,
target
.
control
ler
).
forEach
((
card
)
=>
{
cardStore
.
at
(
HAND
,
target
.
location
.
contro
ler
).
forEach
((
card
)
=>
{
if
(
card
.
uuid
!==
target
.
uuid
)
promises
.
push
(
eventbus
.
call
(
Task
.
Move
,
card
.
uuid
));
});
...
...
src/service/duel/posChange.ts
View file @
9e5c6f5c
...
...
@@ -7,7 +7,7 @@ export default async (posChange: MsgPosChange) => {
const
target
=
cardStore
.
at
(
location
,
controler
,
sequence
);
if
(
target
)
{
target
.
position
=
posChange
.
cur_position
;
target
.
location
.
position
=
posChange
.
cur_position
;
// TODO: 暂时用`Move`动画,后续可以单独实现一个改变表示形式的动画
await
eventbus
.
call
(
Task
.
Move
,
target
.
uuid
);
...
...
src/service/duel/shuffleHand.ts
View file @
9e5c6f5c
...
...
@@ -17,7 +17,7 @@ export default (shuffleHand: MsgShuffleHand) => {
const
sequence
=
hash
.
get
(
hand
.
code
);
if
(
sequence
!==
undefined
)
{
if
(
sequence
>=
0
)
{
hand
.
sequence
=
sequence
;
hand
.
location
.
sequence
=
sequence
;
hash
.
set
(
hand
.
code
,
sequence
-
1
);
}
else
{
console
.
warn
(
...
...
src/service/duel/start.ts
View file @
9e5c6f5c
...
...
@@ -42,16 +42,19 @@ export default (start: ygopro.StocGameMessage.MsgStart) => {
genCard
({
uuid
:
v4uuid
(),
code
:
0
,
controller
:
i
<
3
?
0
:
1
,
originControl
ler
:
i
<
3
?
0
:
1
,
location
:
new
ygopro
.
CardLocation
({
contro
ler
:
i
<
3
?
0
:
1
,
zone
:
[
ygopro
.
CardZone
.
DECK
,
ygopro
.
CardZone
.
EXTRA
,
ygopro
.
CardZone
.
TZONE
,
][
i
%
3
],
sequence
,
position
:
ygopro
.
CardPosition
.
FACEDOWN
,
}),
originController
:
i
<
3
?
0
:
1
,
counters
:
{},
idleInteractivities
:
[],
sequence
,
meta
:
{
id
:
0
,
data
:
{},
...
...
@@ -59,7 +62,6 @@ export default (start: ygopro.StocGameMessage.MsgStart) => {
},
isToken
:
!
((
i
+
1
)
%
3
),
overlayMaterials
:
[],
position
:
ygopro
.
CardPosition
.
FACEDOWN
,
chaining
:
false
,
directAttack
:
false
,
})
...
...
src/service/duel/updateData.ts
View file @
9e5c6f5c
...
...
@@ -10,7 +10,9 @@ export default (updateData: MsgUpdateData) => {
actions
.
forEach
((
action
)
=>
{
const
sequence
=
action
.
location
?.
sequence
;
if
(
typeof
sequence
!==
"
undefined
"
)
{
const
target
=
field
.
filter
((
card
)
=>
card
.
sequence
==
sequence
).
at
(
0
);
const
target
=
field
.
filter
((
card
)
=>
card
.
location
.
sequence
==
sequence
)
.
at
(
0
);
if
(
target
)
{
const
meta
=
target
.
meta
;
// 目前只更新以下字段
...
...
@@ -19,7 +21,7 @@ export default (updateData: MsgUpdateData) => {
meta
.
text
.
id
=
action
.
code
;
}
if
(
action
.
location
!==
undefined
)
{
target
.
position
=
action
.
location
.
position
;
target
.
location
.
position
=
action
.
location
.
position
;
}
if
(
action
?.
type_
>=
0
)
{
meta
.
data
.
type
=
action
.
type_
;
...
...
src/stores/cardStore.ts
View file @
9e5c6f5c
...
...
@@ -11,11 +11,8 @@ export interface CardType {
uuid
:
string
;
// 一张卡的唯一标识
code
:
number
;
// 卡号
meta
:
CardMeta
;
// 卡片元数据
controller
:
number
;
// 控制这个位置的玩家,0或1
location
:
ygopro
.
CardLocation
;
originController
:
number
;
// 在卡组构建之中持有这张卡的玩家,方便reloadField的使用
zone
:
ygopro
.
CardZone
;
// 怪兽区/魔法陷阱区/手牌/卡组/墓地/除外区
position
:
ygopro
.
CardPosition
;
// 卡片的姿势:攻击还是守备
sequence
:
number
;
// 卡片在区域中的序号
idleInteractivities
:
Interactivity
<
number
>
[];
// IDLE状态下的互动信息
placeInteractivity
?:
Interactivity
<
{
controler
:
number
;
...
...
@@ -49,14 +46,15 @@ class CardStore {
return
this
.
inner
.
filter
(
(
card
)
=>
card
.
zone
===
zone
&&
card
.
control
ler
===
controller
&&
card
.
sequence
===
sequence
card
.
location
.
zone
===
zone
&&
card
.
location
.
contro
ler
===
controller
&&
card
.
location
.
sequence
===
sequence
)
.
at
(
0
);
}
else
{
return
this
.
inner
.
filter
(
(
card
)
=>
card
.
zone
===
zone
&&
card
.
controller
===
controller
(
card
)
=>
card
.
location
.
zone
===
zone
&&
card
.
location
.
controler
===
controller
);
}
}
...
...
@@ -80,8 +78,8 @@ class CardStore {
// target.code = meta.id;
target
.
meta
=
meta
;
}
if
(
target
.
zone
==
ygopro
.
CardZone
.
HAND
)
{
target
.
position
=
isChaining
if
(
target
.
location
.
zone
==
ygopro
.
CardZone
.
HAND
)
{
target
.
location
.
position
=
isChaining
?
ygopro
.
CardPosition
.
FACEUP_ATTACK
:
ygopro
.
CardPosition
.
FACEDOWN_ATTACK
;
}
...
...
src/ui/Duel/PlayMat/Card/index.tsx
View file @
9e5c6f5c
...
...
@@ -63,7 +63,7 @@ export const Card: FC<{ idx: number }> = React.memo(({ idx }) => {
};
useEffect
(()
=>
{
move
(
state
.
zone
);
move
(
state
.
location
.
zone
);
},
[]);
const
[
highlight
,
setHighlight
]
=
useState
(
false
);
...
...
@@ -80,7 +80,7 @@ export const Card: FC<{ idx: number }> = React.memo(({ idx }) => {
eventbus
.
register
(
Task
.
Move
,
async
(
uuid
:
string
)
=>
{
if
(
uuid
===
state
.
uuid
)
{
await
addToAnimation
(()
=>
move
(
state
.
zone
));
await
addToAnimation
(()
=>
move
(
state
.
location
.
zone
));
}
});
...
...
@@ -112,9 +112,9 @@ export const Card: FC<{ idx: number }> = React.memo(({ idx }) => {
}
as
any
as
CSSProperties
}
onClick=
{
()
=>
{
if
([
MZONE
,
SZONE
,
HAND
].
includes
(
state
.
zone
))
{
if
([
MZONE
,
SZONE
,
HAND
].
includes
(
state
.
location
.
zone
))
{
onCardClick
(
state
);
}
else
if
([
EXTRA
,
GRAVE
,
REMOVED
].
includes
(
state
.
zone
))
{
}
else
if
([
EXTRA
,
GRAVE
,
REMOVED
].
includes
(
state
.
location
.
zone
))
{
onFieldClick
(
state
);
}
}
}
...
...
@@ -177,7 +177,10 @@ const onCardClick = (card: CardType) => {
};
const
onFieldClick
=
(
card
:
CardType
)
=>
{
const
displayStates
=
cardStore
.
at
(
card
.
zone
,
card
.
controller
);
const
displayStates
=
cardStore
.
at
(
card
.
location
.
zone
,
card
.
location
.
controler
);
messageStore
.
cardListModal
.
list
=
displayStates
.
map
((
item
)
=>
({
meta
:
{
id
:
item
.
code
,
...
...
src/ui/Duel/PlayMat/Card/springs/focus.ts
View file @
9e5c6f5c
...
...
@@ -11,9 +11,9 @@ import { asyncStart } from "./utils";
export
const
focus
=
async
(
props
:
{
card
:
CardType
;
api
:
SpringApi
})
=>
{
const
{
card
,
api
}
=
props
;
const
current
=
api
.
current
[
0
].
get
();
if
(
card
.
zone
===
ygopro
.
CardZone
.
HAND
)
{
if
(
card
.
location
.
zone
===
ygopro
.
CardZone
.
HAND
)
{
await
asyncStart
(
api
)({
y
:
current
.
y
+
(
matStore
.
isMe
(
card
.
control
ler
)
?
-
1
:
1
)
*
200
,
// TODO: 放到config之中
y
:
current
.
y
+
(
matStore
.
isMe
(
card
.
location
.
contro
ler
)
?
-
1
:
1
)
*
200
,
// TODO: 放到config之中
rz
:
0
,
});
await
asyncStart
(
api
)({
y
:
current
.
y
,
rz
:
current
.
rz
});
...
...
src/ui/Duel/PlayMat/Card/springs/moveToDeck.ts
View file @
9e5c6f5c
...
...
@@ -30,7 +30,8 @@ const { HAND, GRAVE, REMOVED, DECK, EXTRA, MZONE, SZONE, TZONE } =
export
const
moveToDeck
=
async
(
props
:
{
card
:
CardType
;
api
:
SpringApi
})
=>
{
const
{
card
,
api
}
=
props
;
// report
const
{
zone
,
sequence
,
controller
,
xyzMonster
,
position
}
=
card
;
const
{
location
,
xyzMonster
}
=
card
;
const
{
controler
,
zone
,
sequence
,
position
}
=
location
;
const
rightX
=
DECK_OFFSET_X
.
value
+
2
*
(
BLOCK_WIDTH
.
value
+
COL_GAP
.
value
);
const
leftX
=
-
rightX
;
...
...
@@ -41,20 +42,20 @@ export const moveToDeck = async (props: { card: CardType; api: SpringApi }) => {
2
*
ROW_GAP
.
value
-
BLOCK_HEIGHT_S
.
value
;
const
topY
=
-
bottomY
;
let
x
=
isMe
(
control
l
er
)
?
rightX
:
leftX
;
let
y
=
isMe
(
control
l
er
)
?
bottomY
:
topY
;
let
x
=
isMe
(
controler
)
?
rightX
:
leftX
;
let
y
=
isMe
(
controler
)
?
bottomY
:
topY
;
if
(
zone
===
EXTRA
)
{
x
=
isMe
(
control
l
er
)
?
leftX
:
rightX
;
x
=
isMe
(
controler
)
?
leftX
:
rightX
;
}
let
rz
=
zone
===
EXTRA
?
DECK_ROTATE_Z
.
value
:
-
DECK_ROTATE_Z
.
value
;
rz
+=
isMe
(
control
l
er
)
?
0
:
180
;
rz
+=
isMe
(
controler
)
?
0
:
180
;
const
z
=
sequence
;
api
.
start
({
x
,
y
,
z
,
rz
,
ry
:
isMe
(
control
l
er
)
?
(
zone
===
DECK
?
180
:
0
)
:
180
,
ry
:
isMe
(
controler
)
?
(
zone
===
DECK
?
180
:
0
)
:
180
,
zIndex
:
z
,
height
:
DECK_CARD_HEIGHT
.
value
,
});
...
...
src/ui/Duel/PlayMat/Card/springs/moveToGround.ts
View file @
9e5c6f5c
...
...
@@ -33,11 +33,15 @@ export const moveToGround = async (props: {
const
{
card
,
api
}
=
props
;
// 如果是超量素材,那么,应该看超量素材所属的xyzMonster
const
targetCard
=
card
.
zone
===
OVERLAY
?
(
card
.
xyzMonster
?
card
.
xyzMonster
:
card
)
:
card
;
const
targetCard
=
card
.
location
.
is_overlay
?
card
.
xyzMonster
?
card
.
xyzMonster
:
card
:
card
;
const
{
zone
,
sequence
,
controller
,
xyzMonster
,
position
,
overlayMaterials
}
=
targetCard
;
const
{
location
,
xyzMonster
,
overlayMaterials
}
=
targetCard
;
const
{
controler
,
zone
,
sequence
,
position
}
=
location
;
// 根据zone计算卡片的宽度
const
cardWidth
=
...
...
@@ -80,7 +84,7 @@ export const moveToGround = async (props: {
}
}
if
(
!
isMe
(
control
l
er
))
{
if
(
!
isMe
(
controler
))
{
x
=
-
x
;
y
=
-
y
;
}
...
...
@@ -92,7 +96,7 @@ export const moveToGround = async (props: {
ygopro
.
CardPosition
.
FACEUP_DEFENSE
,
].
includes
(
position
??
5
);
height
=
defence
?
BLOCK_WIDTH
.
value
:
height
;
let
rz
=
isMe
(
control
l
er
)
?
0
:
180
;
let
rz
=
isMe
(
controler
)
?
0
:
180
;
rz
+=
defence
?
90
:
0
;
// 动画
...
...
src/ui/Duel/PlayMat/Card/springs/moveToHand.ts
View file @
9e5c6f5c
...
...
@@ -28,7 +28,7 @@ const { HAND, GRAVE, REMOVED, DECK, EXTRA, MZONE, SZONE, TZONE } =
export
const
moveToHand
=
async
(
props
:
{
card
:
CardType
;
api
:
SpringApi
})
=>
{
const
{
card
,
api
}
=
props
;
const
{
zone
,
sequence
,
control
ler
}
=
card
;
const
{
zone
,
sequence
,
control
er
}
=
card
.
location
;
// 手卡会有很复杂的计算...
const
hand_circle_center_x
=
0
;
const
hand_circle_center_y
=
...
...
@@ -48,22 +48,22 @@ export const moveToHand = async (props: { card: CardType; api: SpringApi }) => {
)
*
0.9
;
// 接下来计算每一张手卡
const
hands_length
=
cardStore
.
at
(
HAND
,
control
l
er
).
length
;
const
hands_length
=
cardStore
.
at
(
HAND
,
controler
).
length
;
const
angle
=
(
sequence
-
(
hands_length
-
1
)
/
2
)
*
THETA
;
const
r
=
HAND_CIRCLE_CENTER_OFFSET_Y
.
value
+
HAND_CARD_HEIGHT
.
value
/
2
;
const
negativeX
=
Math
.
sin
(
angle
)
*
r
;
const
negativeY
=
Math
.
cos
(
angle
)
*
r
+
HAND_CARD_HEIGHT
.
value
/
2
;
const
x
=
hand_circle_center_x
+
negativeX
*
(
isMe
(
control
l
er
)
?
1
:
-
1
);
const
x
=
hand_circle_center_x
+
negativeX
*
(
isMe
(
controler
)
?
1
:
-
1
);
const
y
=
hand_circle_center_y
-
negativeY
+
130
;
// 常量 是手动调的 这里肯定有问题 有空来修
const
_rz
=
(
angle
*
180
)
/
Math
.
PI
;
api
.
start
({
x
:
isMe
(
control
l
er
)
?
x
:
-
x
,
y
:
isMe
(
control
l
er
)
?
y
:
-
y
,
x
:
isMe
(
controler
)
?
x
:
-
x
,
y
:
isMe
(
controler
)
?
y
:
-
y
,
z
:
0
,
rz
:
isMe
(
control
l
er
)
?
_rz
:
180
-
_rz
,
ry
:
isMe
(
control
l
er
)
?
0
:
180
,
rz
:
isMe
(
controler
)
?
_rz
:
180
-
_rz
,
ry
:
isMe
(
controler
)
?
0
:
180
,
height
:
HAND_CARD_HEIGHT
.
value
,
zIndex
:
sequence
,
// rx: -PLANE_ROTATE_X.value,
...
...
src/ui/Duel/PlayMat/Card/springs/moveToOutside.ts
View file @
9e5c6f5c
...
...
@@ -32,12 +32,12 @@ export const moveToOutside = async (props: {
})
=>
{
const
{
card
,
api
}
=
props
;
// report
const
{
zone
,
sequence
,
controller
,
xyzMonster
,
position
,
overlayMaterials
}
=
card
;
const
{
xyzMonster
,
overlayMaterials
}
=
card
;
const
{
zone
,
sequence
,
controler
,
position
}
=
card
.
location
;
let
x
=
(
BLOCK_WIDTH
.
value
+
COL_GAP
.
value
)
*
3
,
y
=
zone
===
GRAVE
?
BLOCK_HEIGHT_M
.
value
+
ROW_GAP
.
value
:
0
;
if
(
!
isMe
(
control
l
er
))
{
if
(
!
isMe
(
controler
))
{
x
=
-
x
;
y
=
-
y
;
}
...
...
@@ -46,7 +46,7 @@ export const moveToOutside = async (props: {
y
,
z
:
0
,
height
:
BLOCK_HEIGHT_S
.
value
,
rz
:
isMe
(
control
l
er
)
?
0
:
180
,
rz
:
isMe
(
controler
)
?
0
:
180
,
ry
:
[
ygopro
.
CardPosition
.
FACEDOWN
].
includes
(
position
)
?
180
:
0
,
});
};
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