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
{
cardStore
,
matStore
}
from
"
@/stores
"
;
import
{
cardStore
,
matStore
,
placeStore
}
from
"
@/stores
"
;
export
default
(
_chainEnd
:
ygopro
.
StocGameMessage
.
MsgChainEnd
)
=>
{
while
(
true
)
{
...
...
@@ -8,11 +8,11 @@ export default (_chainEnd: ygopro.StocGameMessage.MsgChainEnd) => {
break
;
}
const
target
=
cardStore
.
find
(
chain
);
if
(
target
)
{
target
.
chainIndex
=
undefined
;
const
block
=
placeStore
.
of
(
chain
);
if
(
block
)
{
block
.
chainIndex
.
pop
()
;
}
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
{
cardStore
,
mat
Store
}
from
"
@/stores
"
;
import
{
matStore
,
place
Store
}
from
"
@/stores
"
;
// FIXME: 处理连锁会存在三种结果:
// 1. Solved - 已处理;
...
...
@@ -15,11 +15,11 @@ export default async (chainSolved: ygopro.StocGameMessage.MsgChainSolved) => {
.
at
(
0
);
if
(
location
)
{
// 设置被连锁状态为空,解除连锁
const
target
=
cardStore
.
find
(
location
);
if
(
target
)
{
target
.
chainIndex
=
undefined
;
const
block
=
placeStore
.
of
(
location
);
if
(
block
)
{
block
.
chainIndex
.
pop
()
;
}
else
{
console
.
warn
(
`<ChainSolved>
target
from
${
location
}
is null`
);
console
.
warn
(
`<ChainSolved>
block
from
${
location
}
is null`
);
}
}
else
{
console
.
warn
(
...
...
src/service/duel/chaining.ts
View file @
5c9a4632
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
"
;
export
default
async
(
chaining
:
ygopro
.
StocGameMessage
.
MsgChaining
)
=>
{
...
...
@@ -16,7 +16,12 @@ export default async (chaining: ygopro.StocGameMessage.MsgChaining) => {
const
target
=
cardStore
.
find
(
location
);
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
);
// 这里不能设置`code`,因为存在一个场景:
...
...
src/service/duel/fieldDisabled.ts
View file @
5c9a4632
...
...
@@ -7,10 +7,12 @@ export default (fieldDisabled: MsgFieldDisabled) => {
switch
(
action
.
zone
)
{
case
ygopro
.
CardZone
.
MZONE
:
case
ygopro
.
CardZone
.
SZONE
:
placeStore
.
set
(
action
.
zone
,
action
.
controller
,
action
.
sequence
,
{
interactivity
:
undefined
,
disabled
:
action
.
disabled
,
});
const
block
=
placeStore
.
of
(
action
);
if
(
block
)
{
block
.
disabled
=
action
.
disabled
;
}
else
{
console
.
warn
(
"
<FieldDisabled>block is undefined
"
);
}
break
;
default
:
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) => {
switch
(
place
.
zone
)
{
case
ygopro
.
CardZone
.
MZONE
:
case
ygopro
.
CardZone
.
SZONE
:
placeStore
.
set
(
place
.
zone
,
place
.
controller
,
place
.
sequence
,
{
interactivity
:
{
const
block
=
placeStore
.
of
(
place
);
if
(
block
)
{
block
.
interactivity
=
{
interactType
:
InteractType
.
PLACE_SELECTABLE
,
response
:
{
controller
:
place
.
controller
,
zone
:
place
.
zone
,
sequence
:
place
.
sequence
,
},
},
disabled
:
false
,
});
};
}
break
;
}
}
...
...
src/stores/cardStore.ts
View file @
5c9a4632
...
...
@@ -22,8 +22,6 @@ export interface CardType {
}
>
;
// 选择位置状态下的互动信息
counters
:
{
[
type
:
number
]:
number
};
// 指示器
isToken
:
boolean
;
// 是否是token
chainIndex
?:
number
/*连锁的序号,如果为空表示不在连锁
TODO: 目前是妥协的设计,因为其实一张卡是可以在同一个连锁链中被连锁多次的,这里为了避免太过复杂只保存最后的连锁序号*/
;
selected
:
boolean
;
// 当前卡是否被选择成为效果的对象
}
...
...
src/stores/placeStore.ts
View file @
5c9a4632
...
...
@@ -15,17 +15,19 @@ export type PlaceInteractivity =
}
>
|
undefined
;
const
{
MZONE
,
SZONE
}
=
ygopro
.
CardZone
;
const
{
MZONE
,
SZONE
,
HAND
,
GRAVE
,
REMOVED
}
=
ygopro
.
CardZone
;
export
interface
BlockState
{
interactivity
?:
PlaceInteractivity
;
// 互动性
disabled
:
boolean
;
// 是否被禁用
chainIndex
:
number
[];
// 当前位置上的连锁序号。YGOPRO和MASTER DUEL的连锁都是和位置绑定的,因此在`PlaceStore`中记录连锁状态。
}
const
genPLaces
=
(
n
:
number
):
BlockState
[]
=>
Array
.
from
({
length
:
n
}).
map
(()
=>
({
interactivity
:
undefined
,
disabled
:
false
,
chainIndex
:
[],
}));
const
initialState
=
{
...
...
@@ -37,27 +39,35 @@ const initialState = {
me
:
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
{
inner
:
{
[
MZONE
]:
{
me
:
BlockState
[];
op
:
BlockState
[];
};
[
SZONE
]:
{
[
zone
:
number
]:
{
me
:
BlockState
[];
op
:
BlockState
[];
};
}
=
initialState
;
set
(
zone
:
ygopro
.
CardZone
.
MZONE
|
ygopro
.
CardZone
.
SZONE
,
controller
:
number
,
sequence
:
number
,
state
:
BlockState
,
)
{
placeStore
.
inner
[
zone
][
matStore
.
isMe
(
controller
)
?
"
me
"
:
"
op
"
][
sequence
]
=
state
;
of
(
location
:
{
zone
:
ygopro
.
CardZone
;
controller
:
number
;
sequence
:
number
;
}):
BlockState
|
undefined
{
return
placeStore
.
inner
[
location
.
zone
][
matStore
.
isMe
(
location
.
controller
)
?
"
me
"
:
"
op
"
][
location
.
sequence
]
;
}
clearAllInteractivity
()
{
([
"
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