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
5c9a4632
Commit
5c9a4632
authored
Aug 23, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'optimize/chain' into 'main'
改造一下连锁的数据层实现 See merge request
!283
parents
8d38baba
d895da88
Pipeline
#23252
passed with stages
in 11 minutes and 25 seconds
Changes
7
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
52 additions
and
37 deletions
+52
-37
src/service/duel/chainEnd.ts
src/service/duel/chainEnd.ts
+5
-5
src/service/duel/chainSolved.ts
src/service/duel/chainSolved.ts
+5
-5
src/service/duel/chaining.ts
src/service/duel/chaining.ts
+7
-2
src/service/duel/fieldDisabled.ts
src/service/duel/fieldDisabled.ts
+6
-4
src/service/duel/selectPlace.ts
src/service/duel/selectPlace.ts
+5
-5
src/stores/cardStore.ts
src/stores/cardStore.ts
+0
-2
src/stores/placeStore.ts
src/stores/placeStore.ts
+24
-14
No files found.
src/service/duel/chainEnd.ts
View file @
5c9a4632
import
{
ygopro
}
from
"
@/api
"
;
import
{
ygopro
}
from
"
@/api
"
;
import
{
cardStore
,
matStore
}
from
"
@/stores
"
;
import
{
cardStore
,
matStore
,
placeStore
}
from
"
@/stores
"
;
export
default
(
_chainEnd
:
ygopro
.
StocGameMessage
.
MsgChainEnd
)
=>
{
export
default
(
_chainEnd
:
ygopro
.
StocGameMessage
.
MsgChainEnd
)
=>
{
while
(
true
)
{
while
(
true
)
{
...
@@ -8,11 +8,11 @@ export default (_chainEnd: ygopro.StocGameMessage.MsgChainEnd) => {
...
@@ -8,11 +8,11 @@ export default (_chainEnd: ygopro.StocGameMessage.MsgChainEnd) => {
break
;
break
;
}
}
const
target
=
cardStore
.
find
(
chain
);
const
block
=
placeStore
.
of
(
chain
);
if
(
target
)
{
if
(
block
)
{
target
.
chainIndex
=
undefined
;
block
.
chainIndex
.
pop
()
;
}
else
{
}
else
{
console
.
warn
(
`<ChainEnd>
target
from
${
chain
}
is null`
);
console
.
warn
(
`<ChainEnd>
block
from
${
chain
}
is null`
);
}
}
}
}
...
...
src/service/duel/chainSolved.ts
View file @
5c9a4632
import
{
ygopro
}
from
"
@/api
"
;
import
{
ygopro
}
from
"
@/api
"
;
import
{
cardStore
,
mat
Store
}
from
"
@/stores
"
;
import
{
matStore
,
place
Store
}
from
"
@/stores
"
;
// FIXME: 处理连锁会存在三种结果:
// FIXME: 处理连锁会存在三种结果:
// 1. Solved - 已处理;
// 1. Solved - 已处理;
...
@@ -15,11 +15,11 @@ export default async (chainSolved: ygopro.StocGameMessage.MsgChainSolved) => {
...
@@ -15,11 +15,11 @@ export default async (chainSolved: ygopro.StocGameMessage.MsgChainSolved) => {
.
at
(
0
);
.
at
(
0
);
if
(
location
)
{
if
(
location
)
{
// 设置被连锁状态为空,解除连锁
// 设置被连锁状态为空,解除连锁
const
target
=
cardStore
.
find
(
location
);
const
block
=
placeStore
.
of
(
location
);
if
(
target
)
{
if
(
block
)
{
target
.
chainIndex
=
undefined
;
block
.
chainIndex
.
pop
()
;
}
else
{
}
else
{
console
.
warn
(
`<ChainSolved>
target
from
${
location
}
is null`
);
console
.
warn
(
`<ChainSolved>
block
from
${
location
}
is null`
);
}
}
}
else
{
}
else
{
console
.
warn
(
console
.
warn
(
...
...
src/service/duel/chaining.ts
View file @
5c9a4632
import
{
fetchCard
,
ygopro
}
from
"
@/api
"
;
import
{
fetchCard
,
ygopro
}
from
"
@/api
"
;
import
{
cardStore
,
fetchEsHintMeta
,
matStore
}
from
"
@/stores
"
;
import
{
cardStore
,
fetchEsHintMeta
,
matStore
,
placeStore
}
from
"
@/stores
"
;
import
{
callCardFocus
}
from
"
@/ui/Duel/PlayMat/Card
"
;
import
{
callCardFocus
}
from
"
@/ui/Duel/PlayMat/Card
"
;
export
default
async
(
chaining
:
ygopro
.
StocGameMessage
.
MsgChaining
)
=>
{
export
default
async
(
chaining
:
ygopro
.
StocGameMessage
.
MsgChaining
)
=>
{
...
@@ -16,7 +16,12 @@ export default async (chaining: ygopro.StocGameMessage.MsgChaining) => {
...
@@ -16,7 +16,12 @@ export default async (chaining: ygopro.StocGameMessage.MsgChaining) => {
const
target
=
cardStore
.
find
(
location
);
const
target
=
cardStore
.
find
(
location
);
if
(
target
)
{
if
(
target
)
{
// 设置连锁序号
// 设置连锁序号
target
.
chainIndex
=
matStore
.
chains
.
length
;
const
block
=
placeStore
.
of
(
location
);
if
(
block
)
{
block
.
chainIndex
.
push
(
matStore
.
chains
.
length
);
}
else
{
console
.
warn
(
`<Chaining>block from
${
location
}
is null`
);
}
const
meta
=
fetchCard
(
chaining
.
code
);
const
meta
=
fetchCard
(
chaining
.
code
);
// 这里不能设置`code`,因为存在一个场景:
// 这里不能设置`code`,因为存在一个场景:
...
...
src/service/duel/fieldDisabled.ts
View file @
5c9a4632
...
@@ -7,10 +7,12 @@ export default (fieldDisabled: MsgFieldDisabled) => {
...
@@ -7,10 +7,12 @@ export default (fieldDisabled: MsgFieldDisabled) => {
switch
(
action
.
zone
)
{
switch
(
action
.
zone
)
{
case
ygopro
.
CardZone
.
MZONE
:
case
ygopro
.
CardZone
.
MZONE
:
case
ygopro
.
CardZone
.
SZONE
:
case
ygopro
.
CardZone
.
SZONE
:
placeStore
.
set
(
action
.
zone
,
action
.
controller
,
action
.
sequence
,
{
const
block
=
placeStore
.
of
(
action
);
interactivity
:
undefined
,
if
(
block
)
{
disabled
:
action
.
disabled
,
block
.
disabled
=
action
.
disabled
;
});
}
else
{
console
.
warn
(
"
<FieldDisabled>block is undefined
"
);
}
break
;
break
;
default
:
default
:
console
.
warn
(
"
<FieldDisabled>zone is not MZONE nor SZONE!
"
);
console
.
warn
(
"
<FieldDisabled>zone is not MZONE nor SZONE!
"
);
...
...
src/service/duel/selectPlace.ts
View file @
5c9a4632
...
@@ -13,17 +13,17 @@ export default (selectPlace: MsgSelectPlace) => {
...
@@ -13,17 +13,17 @@ export default (selectPlace: MsgSelectPlace) => {
switch
(
place
.
zone
)
{
switch
(
place
.
zone
)
{
case
ygopro
.
CardZone
.
MZONE
:
case
ygopro
.
CardZone
.
MZONE
:
case
ygopro
.
CardZone
.
SZONE
:
case
ygopro
.
CardZone
.
SZONE
:
placeStore
.
set
(
place
.
zone
,
place
.
controller
,
place
.
sequence
,
{
const
block
=
placeStore
.
of
(
place
);
interactivity
:
{
if
(
block
)
{
block
.
interactivity
=
{
interactType
:
InteractType
.
PLACE_SELECTABLE
,
interactType
:
InteractType
.
PLACE_SELECTABLE
,
response
:
{
response
:
{
controller
:
place
.
controller
,
controller
:
place
.
controller
,
zone
:
place
.
zone
,
zone
:
place
.
zone
,
sequence
:
place
.
sequence
,
sequence
:
place
.
sequence
,
},
},
},
};
disabled
:
false
,
}
});
break
;
break
;
}
}
}
}
...
...
src/stores/cardStore.ts
View file @
5c9a4632
...
@@ -22,8 +22,6 @@ export interface CardType {
...
@@ -22,8 +22,6 @@ export interface CardType {
}
>
;
// 选择位置状态下的互动信息
}
>
;
// 选择位置状态下的互动信息
counters
:
{
[
type
:
number
]:
number
};
// 指示器
counters
:
{
[
type
:
number
]:
number
};
// 指示器
isToken
:
boolean
;
// 是否是token
isToken
:
boolean
;
// 是否是token
chainIndex
?:
number
/*连锁的序号,如果为空表示不在连锁
TODO: 目前是妥协的设计,因为其实一张卡是可以在同一个连锁链中被连锁多次的,这里为了避免太过复杂只保存最后的连锁序号*/
;
selected
:
boolean
;
// 当前卡是否被选择成为效果的对象
selected
:
boolean
;
// 当前卡是否被选择成为效果的对象
}
}
...
...
src/stores/placeStore.ts
View file @
5c9a4632
...
@@ -15,17 +15,19 @@ export type PlaceInteractivity =
...
@@ -15,17 +15,19 @@ export type PlaceInteractivity =
}
>
}
>
|
undefined
;
|
undefined
;
const
{
MZONE
,
SZONE
}
=
ygopro
.
CardZone
;
const
{
MZONE
,
SZONE
,
HAND
,
GRAVE
,
REMOVED
}
=
ygopro
.
CardZone
;
export
interface
BlockState
{
export
interface
BlockState
{
interactivity
?:
PlaceInteractivity
;
// 互动性
interactivity
?:
PlaceInteractivity
;
// 互动性
disabled
:
boolean
;
// 是否被禁用
disabled
:
boolean
;
// 是否被禁用
chainIndex
:
number
[];
// 当前位置上的连锁序号。YGOPRO和MASTER DUEL的连锁都是和位置绑定的,因此在`PlaceStore`中记录连锁状态。
}
}
const
genPLaces
=
(
n
:
number
):
BlockState
[]
=>
const
genPLaces
=
(
n
:
number
):
BlockState
[]
=>
Array
.
from
({
length
:
n
}).
map
(()
=>
({
Array
.
from
({
length
:
n
}).
map
(()
=>
({
interactivity
:
undefined
,
interactivity
:
undefined
,
disabled
:
false
,
disabled
:
false
,
chainIndex
:
[],
}));
}));
const
initialState
=
{
const
initialState
=
{
...
@@ -37,27 +39,35 @@ const initialState = {
...
@@ -37,27 +39,35 @@ const initialState = {
me
:
genPLaces
(
6
),
me
:
genPLaces
(
6
),
op
:
genPLaces
(
6
),
op
:
genPLaces
(
6
),
},
},
[
HAND
]:
{
me
:
genPLaces
(
100
),
// 给100个占位
op
:
genPLaces
(
100
),
},
[
GRAVE
]:
{
me
:
genPLaces
(
100
),
op
:
genPLaces
(
100
),
},
[
REMOVED
]:
{
me
:
genPLaces
(
100
),
op
:
genPLaces
(
100
),
},
};
};
class
PlaceStore
implements
NeosStore
{
class
PlaceStore
implements
NeosStore
{
inner
:
{
inner
:
{
[
MZONE
]:
{
[
zone
:
number
]:
{
me
:
BlockState
[];
op
:
BlockState
[];
};
[
SZONE
]:
{
me
:
BlockState
[];
me
:
BlockState
[];
op
:
BlockState
[];
op
:
BlockState
[];
};
};
}
=
initialState
;
}
=
initialState
;
set
(
of
(
location
:
{
zone
:
ygopro
.
CardZone
.
MZONE
|
ygopro
.
CardZone
.
SZONE
,
zone
:
ygopro
.
CardZone
;
controller
:
number
,
controller
:
number
;
sequence
:
number
,
sequence
:
number
;
state
:
BlockState
,
}):
BlockState
|
undefined
{
)
{
return
placeStore
.
inner
[
location
.
zone
][
placeStore
.
inner
[
zone
][
matStore
.
isMe
(
controller
)
?
"
me
"
:
"
op
"
][
sequence
]
=
matStore
.
isMe
(
location
.
controller
)
?
"
me
"
:
"
op
"
state
;
][
location
.
sequence
]
;
}
}
clearAllInteractivity
()
{
clearAllInteractivity
()
{
([
"
me
"
,
"
op
"
]
as
const
).
forEach
((
who
)
=>
{
([
"
me
"
,
"
op
"
]
as
const
).
forEach
((
who
)
=>
{
...
...
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