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
a80f0ca9
Commit
a80f0ca9
authored
May 09, 2023
by
chechunchi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add focus effect
parent
79611cf5
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
33 additions
and
8 deletions
+33
-8
src/service/duel/move.ts
src/service/duel/move.ts
+8
-1
src/service/duel/timeLimit.ts
src/service/duel/timeLimit.ts
+6
-2
src/stores/matStore/store.ts
src/stores/matStore/store.ts
+3
-1
src/stores/matStore/types.ts
src/stores/matStore/types.ts
+3
-1
src/styles/mat.css
src/styles/mat.css
+1
-1
src/ui/Duel/PlayMat/Card.tsx
src/ui/Duel/PlayMat/Card.tsx
+7
-1
src/ui/Duel/PlayMat/Mat.tsx
src/ui/Duel/PlayMat/Mat.tsx
+5
-1
No files found.
src/service/duel/move.ts
View file @
a80f0ca9
...
@@ -72,10 +72,17 @@ export default (move: MsgMove) => {
...
@@ -72,10 +72,17 @@ export default (move: MsgMove) => {
matStore
matStore
.
in
(
to
.
location
)
.
in
(
to
.
location
)
.
of
(
to
.
controler
)
.
of
(
to
.
controler
)
.
setOccupant
(
to
.
sequence
,
code
,
to
.
position
);
.
setOccupant
(
to
.
sequence
,
code
,
to
.
position
,
true
);
if
(
uuid
)
{
if
(
uuid
)
{
matStore
.
in
(
to
.
location
).
of
(
to
.
controler
)[
to
.
sequence
].
uuid
=
uuid
;
matStore
.
in
(
to
.
location
).
of
(
to
.
controler
)[
to
.
sequence
].
uuid
=
uuid
;
}
}
setTimeout
(
()
=>
(
matStore
.
in
(
to
.
location
).
of
(
to
.
controler
)[
to
.
sequence
].
focus
=
false
),
500
);
break
;
break
;
}
}
case
ygopro
.
CardZone
.
REMOVED
:
case
ygopro
.
CardZone
.
REMOVED
:
...
...
src/service/duel/timeLimit.ts
View file @
a80f0ca9
import
{
sendTimeConfirm
,
ygopro
}
from
"
@/api
"
;
import
{
sendTimeConfirm
,
ygopro
}
from
"
@/api
"
;
import
{
matStore
}
from
"
@/stores
"
;
import
{
matStore
}
from
"
@/stores
"
;
const
TIME_GAP
=
800
;
export
default
function
handleTimeLimit
(
timeLimit
:
ygopro
.
StocTimeLimit
)
{
export
default
function
handleTimeLimit
(
timeLimit
:
ygopro
.
StocTimeLimit
)
{
setTimeout
(()
=>
{
matStore
.
timeLimits
.
set
(
timeLimit
.
player
,
timeLimit
.
left_time
);
matStore
.
timeLimits
.
set
(
timeLimit
.
player
,
timeLimit
.
left_time
);
sendTimeConfirm
();
sendTimeConfirm
();
},
TIME_GAP
);
}
}
src/stores/matStore/store.ts
View file @
a80f0ca9
...
@@ -69,10 +69,12 @@ class CardArray extends Array<CardState> implements ArrayCardState {
...
@@ -69,10 +69,12 @@ class CardArray extends Array<CardState> implements ArrayCardState {
async
setOccupant
(
async
setOccupant
(
sequence
:
number
,
sequence
:
number
,
id
:
number
,
id
:
number
,
position
?:
ygopro
.
CardPosition
position
?:
ygopro
.
CardPosition
,
focus
?:
boolean
)
{
)
{
const
meta
=
await
fetchCard
(
id
);
const
meta
=
await
fetchCard
(
id
);
const
target
=
this
[
sequence
];
const
target
=
this
[
sequence
];
target
.
focus
=
focus
;
target
.
occupant
=
meta
;
target
.
occupant
=
meta
;
if
(
position
)
{
if
(
position
)
{
target
.
location
.
position
=
position
;
target
.
location
.
position
=
position
;
...
...
src/stores/matStore/types.ts
View file @
a80f0ca9
...
@@ -31,7 +31,8 @@ export interface DuelFieldState extends Array<CardState> {
...
@@ -31,7 +31,8 @@ export interface DuelFieldState extends Array<CardState> {
setOccupant
:
(
setOccupant
:
(
sequence
:
number
,
sequence
:
number
,
id
:
number
,
id
:
number
,
position
?:
ygopro
.
CardPosition
position
?:
ygopro
.
CardPosition
,
focus
?:
boolean
)
=>
Promise
<
void
>
;
)
=>
Promise
<
void
>
;
/** 添加 idle 的交互性 */
/** 添加 idle 的交互性 */
addIdleInteractivity
:
(
addIdleInteractivity
:
(
...
@@ -117,6 +118,7 @@ export interface CardState {
...
@@ -117,6 +118,7 @@ export interface CardState {
zone
:
ygopro
.
CardZone
;
// 怪兽区/魔法陷阱区/手牌/卡组/墓地/除外区
zone
:
ygopro
.
CardZone
;
// 怪兽区/魔法陷阱区/手牌/卡组/墓地/除外区
position
?:
ygopro
.
CardPosition
;
// 卡片的姿势:攻击还是守备
position
?:
ygopro
.
CardPosition
;
// 卡片的姿势:攻击还是守备
};
// 位置信息,叫location的原因是为了和ygo对齐
};
// 位置信息,叫location的原因是为了和ygo对齐
focus
?:
boolean
;
idleInteractivities
:
Interactivity
<
number
>
[];
// IDLE状态下的互动信息
idleInteractivities
:
Interactivity
<
number
>
[];
// IDLE状态下的互动信息
placeInteractivity
?:
Interactivity
<
{
placeInteractivity
?:
Interactivity
<
{
controler
:
number
;
controler
:
number
;
...
...
src/styles/mat.css
View file @
a80f0ca9
...
@@ -100,7 +100,7 @@ button:focus-visible {
...
@@ -100,7 +100,7 @@ button:focus-visible {
--x
:
calc
(
var
(
--x-margin-left
)
+
var
(
--x-padding
));
--x
:
calc
(
var
(
--x-margin-left
)
+
var
(
--x-padding
));
--y
:
calc
(
var
(
--r
)
*
calc
(
var
(
--block-height
)
+
var
(
--block-row-gap
)));
--y
:
calc
(
var
(
--r
)
*
calc
(
var
(
--block-height
)
+
var
(
--block-row-gap
)));
--z
:
calc
(
var
(
--h
)
*
1px
);
--z
:
calc
(
var
(
--h
)
*
1px
);
transform
:
translateZ
(
var
(
--z
))
rotateX
(
calc
(
var
(
--hand-rotate
)
*
var
(
--vertical
)));
transform
:
translateZ
(
var
(
--z
))
rotateX
(
calc
(
var
(
--hand-rotate
)
*
var
(
--vertical
)))
scale
(
var
(
--scale-focus
))
;
translate
:
var
(
--x
)
var
(
--y
);
translate
:
var
(
--x
)
var
(
--y
);
rotate
:
calc
(
var
(
--opponent-deg
)
*
(
1
-
var
(
--vertical
)));
rotate
:
calc
(
var
(
--opponent-deg
)
*
(
1
-
var
(
--vertical
)));
transform-style
:
preserve-3d
;
transform-style
:
preserve-3d
;
...
...
src/ui/Duel/PlayMat/Card.tsx
View file @
a80f0ca9
...
@@ -12,6 +12,9 @@ const ASSETS_BASE =
...
@@ -12,6 +12,9 @@ const ASSETS_BASE =
?
NeosConfig
.
assetsPath
?
NeosConfig
.
assetsPath
:
import
.
meta
.
env
.
BASE_URL
+
NeosConfig
.
assetsPath
;
:
import
.
meta
.
env
.
BASE_URL
+
NeosConfig
.
assetsPath
;
const
FOCUS_SCALE
=
2.5
;
const
FOCUS_HIGHT
=
100
;
export
const
Card
:
React
.
FC
<
{
export
const
Card
:
React
.
FC
<
{
code
:
number
;
code
:
number
;
row
:
number
;
row
:
number
;
...
@@ -23,6 +26,7 @@ export const Card: React.FC<{
...
@@ -23,6 +26,7 @@ export const Card: React.FC<{
vertical
?:
boolean
;
vertical
?:
boolean
;
highlight
?:
boolean
;
highlight
?:
boolean
;
fly
?:
boolean
;
fly
?:
boolean
;
focus
?:
boolean
;
transTime
?:
number
;
transTime
?:
number
;
onClick
?:
MouseEventHandler
<
{}
>
;
onClick
?:
MouseEventHandler
<
{}
>
;
style
?:
CSSProperties
;
style
?:
CSSProperties
;
...
@@ -37,6 +41,7 @@ export const Card: React.FC<{
...
@@ -37,6 +41,7 @@ export const Card: React.FC<{
vertical
=
false
,
vertical
=
false
,
highlight
=
false
,
highlight
=
false
,
fly
=
false
,
fly
=
false
,
focus
=
false
,
transTime
=
0.3
,
transTime
=
0.3
,
onClick
,
onClick
,
style
=
{},
style
=
{},
...
@@ -48,7 +53,7 @@ export const Card: React.FC<{
...
@@ -48,7 +53,7 @@ export const Card: React.FC<{
})
}
})
}
style=
{
style=
{
{
{
"
--h
"
:
hight
,
"
--h
"
:
focus
?
FOCUS_HIGHT
:
hight
,
"
--r
"
:
row
,
"
--r
"
:
row
,
"
--c
"
:
col
,
"
--c
"
:
col
,
"
--shadow
"
:
hight
>
0
?
1
:
0
,
"
--shadow
"
:
hight
>
0
?
1
:
0
,
...
@@ -56,6 +61,7 @@ export const Card: React.FC<{
...
@@ -56,6 +61,7 @@ export const Card: React.FC<{
"
--vertical
"
:
vertical
?
1
:
0
,
"
--vertical
"
:
vertical
?
1
:
0
,
"
--trans-time
"
:
`${transTime}s`
,
"
--trans-time
"
:
`${transTime}s`
,
"
--highlight-on
"
:
highlight
?
1
:
0
,
"
--highlight-on
"
:
highlight
?
1
:
0
,
"
--scale-focus
"
:
focus
?
FOCUS_SCALE
:
1
,
"
--card-img
"
:
facedown
"
--card-img
"
:
facedown
?
`url(${ASSETS_BASE + "/card_back.jpg"})`
?
`url(${ASSETS_BASE + "/card_back.jpg"})`
:
`url(${NeosConfig.cardImgUrl + "/" + code + ".jpg"})`
,
:
`url(${NeosConfig.cardImgUrl + "/" + code + ".jpg"})`
,
...
...
src/ui/Duel/PlayMat/Mat.tsx
View file @
a80f0ca9
...
@@ -100,8 +100,9 @@ export const Mat = () => {
...
@@ -100,8 +100,9 @@ export const Mat = () => {
card
.
location
.
position
===
YgoPosition
.
FACEUP_DEFENSE
card
.
location
.
position
===
YgoPosition
.
FACEUP_DEFENSE
}
}
facedown=
{
CardStateToFaceDown
(
card
)
}
facedown=
{
CardStateToFaceDown
(
card
)
}
vertical=
{
card
.
location
.
zone
==
YgoZone
.
HAND
}
vertical=
{
card
.
location
.
zone
==
YgoZone
.
HAND
||
card
.
focus
}
highlight=
{
card
.
idleInteractivities
.
length
>
0
}
highlight=
{
card
.
idleInteractivities
.
length
>
0
}
focus=
{
card
.
focus
&&
card
.
occupant
?.
id
!==
0
}
opponent=
{
card
.
opponent
}
opponent=
{
card
.
opponent
}
onClick=
{
onClick=
{
card
.
location
.
zone
==
YgoZone
.
SZONE
||
card
.
location
.
zone
==
YgoZone
.
SZONE
||
...
@@ -121,6 +122,7 @@ export const Mat = () => {
...
@@ -121,6 +122,7 @@ export const Mat = () => {
};
};
function
cardStateToRow
(
state
:
RenderCard
):
number
{
function
cardStateToRow
(
state
:
RenderCard
):
number
{
if
(
state
.
focus
)
return
2
;
if
(
state
.
opponent
)
{
if
(
state
.
opponent
)
{
switch
(
state
.
location
.
zone
)
{
switch
(
state
.
location
.
zone
)
{
case
YgoZone
.
EXTRA
:
case
YgoZone
.
EXTRA
:
...
@@ -161,6 +163,7 @@ function cardStateToRow(state: RenderCard): number {
...
@@ -161,6 +163,7 @@ function cardStateToRow(state: RenderCard): number {
}
}
function
cardStateToCol
(
state
:
RenderCard
):
number
{
function
cardStateToCol
(
state
:
RenderCard
):
number
{
if
(
state
.
focus
)
return
2
;
if
(
state
.
opponent
)
{
if
(
state
.
opponent
)
{
switch
(
state
.
location
.
zone
)
{
switch
(
state
.
location
.
zone
)
{
case
YgoZone
.
EXTRA
:
case
YgoZone
.
EXTRA
:
...
@@ -223,6 +226,7 @@ function CardStateToHigh(state: RenderCard): number {
...
@@ -223,6 +226,7 @@ function CardStateToHigh(state: RenderCard): number {
}
}
function
CardStateToFaceDown
(
state
:
RenderCard
):
boolean
{
function
CardStateToFaceDown
(
state
:
RenderCard
):
boolean
{
if
(
state
.
focus
&&
state
.
occupant
?.
id
!==
0
)
return
false
;
const
position
=
state
.
location
.
position
;
const
position
=
state
.
location
.
position
;
return
(
return
(
...
...
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