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
128d5827
Commit
128d5827
authored
Jul 17, 2024
by
chechunchi
Committed by
Chunchi Che
Jul 17, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor store with placeStore
parent
e1c66ce2
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
45 additions
and
26 deletions
+45
-26
src/service/duel/chainEnd.ts
src/service/duel/chainEnd.ts
+8
-3
src/service/duel/chainSolved.ts
src/service/duel/chainSolved.ts
+8
-3
src/service/duel/chaining.ts
src/service/duel/chaining.ts
+8
-3
src/service/duel/fieldDisabled.ts
src/service/duel/fieldDisabled.ts
+4
-3
src/service/duel/gameMsg.ts
src/service/duel/gameMsg.ts
+4
-4
src/service/duel/selectPlace.ts
src/service/duel/selectPlace.ts
+3
-2
src/stores/placeStore.ts
src/stores/placeStore.ts
+10
-8
No files found.
src/service/duel/chainEnd.ts
View file @
128d5827
import
{
ygopro
}
from
"
@/api
"
;
import
{
cardStore
,
matStore
,
placeStore
}
from
"
@/stores
"
;
import
{
Container
}
from
"
@/container
"
;
import
{
cardStore
,
matStore
}
from
"
@/stores
"
;
export
default
(
_chainEnd
:
ygopro
.
StocGameMessage
.
MsgChainEnd
)
=>
{
export
default
(
container
:
Container
,
_chainEnd
:
ygopro
.
StocGameMessage
.
MsgChainEnd
,
)
=>
{
console
.
info
(
`<ChainEnd>chain has been end`
);
const
context
=
container
.
context
;
while
(
true
)
{
const
chain
=
matStore
.
chains
.
pop
();
...
...
@@ -10,7 +15,7 @@ export default (_chainEnd: ygopro.StocGameMessage.MsgChainEnd) => {
break
;
}
const
block
=
placeStore
.
of
(
chain
);
const
block
=
context
.
placeStore
.
of
(
context
,
chain
);
if
(
block
)
{
block
.
chainIndex
.
pop
();
}
else
{
...
...
src/service/duel/chainSolved.ts
View file @
128d5827
import
{
ygopro
}
from
"
@/api
"
;
import
{
matStore
,
placeStore
}
from
"
@/stores
"
;
import
{
Container
}
from
"
@/container
"
;
import
{
matStore
}
from
"
@/stores
"
;
// FIXME: 处理连锁会存在三种结果:
// 1. Solved - 已处理;
...
...
@@ -9,15 +10,19 @@ import { matStore, placeStore } from "@/stores";
// 第一种MSG后端会在每一个连锁点处理完(不管是无效还是禁用)发给前端,
// 第二第三种只会在特定情况下发,用于UI展示。
// 这里暂时只处理第一种。
export
default
async
(
chainSolved
:
ygopro
.
StocGameMessage
.
MsgChainSolved
)
=>
{
export
default
async
(
container
:
Container
,
chainSolved
:
ygopro
.
StocGameMessage
.
MsgChainSolved
,
)
=>
{
console
.
info
(
`<ChainSolved>solved_index =
${
chainSolved
.
solved_index
}
`
);
const
context
=
container
.
context
;
const
location
=
matStore
.
chains
.
splice
(
chainSolved
.
solved_index
-
1
,
1
)
.
at
(
0
);
if
(
location
)
{
// 设置被连锁状态为空,解除连锁
const
block
=
placeStore
.
of
(
location
);
const
block
=
context
.
placeStore
.
of
(
context
,
location
);
if
(
block
)
{
block
.
chainIndex
.
pop
();
}
else
{
...
...
src/service/duel/chaining.ts
View file @
128d5827
import
{
fetchCard
,
ygopro
}
from
"
@/api
"
;
import
{
Container
}
from
"
@/container
"
;
import
{
AudioActionType
,
playEffect
}
from
"
@/infra/audio
"
;
import
{
cardStore
,
fetchEsHintMeta
,
matStore
,
placeStore
}
from
"
@/stores
"
;
import
{
cardStore
,
fetchEsHintMeta
,
matStore
}
from
"
@/stores
"
;
import
{
callCardFocus
}
from
"
@/ui/Duel/PlayMat/Card
"
;
export
default
async
(
chaining
:
ygopro
.
StocGameMessage
.
MsgChaining
)
=>
{
export
default
async
(
container
:
Container
,
chaining
:
ygopro
.
StocGameMessage
.
MsgChaining
,
)
=>
{
playEffect
(
AudioActionType
.
SOUND_ACTIVATE
);
fetchEsHintMeta
({
originMsg
:
"
「[?]」被发动时
"
,
cardID
:
chaining
.
code
,
});
const
context
=
container
.
context
;
const
location
=
chaining
.
location
;
// 将`location`添加到连锁栈
...
...
@@ -18,7 +23,7 @@ export default async (chaining: ygopro.StocGameMessage.MsgChaining) => {
const
target
=
cardStore
.
find
(
location
);
if
(
target
)
{
// 设置连锁序号
const
block
=
placeStore
.
of
(
location
);
const
block
=
context
.
placeStore
.
of
(
context
,
location
);
if
(
block
)
{
block
.
chainIndex
.
push
(
matStore
.
chains
.
length
);
}
else
{
...
...
src/service/duel/fieldDisabled.ts
View file @
128d5827
import
{
ygopro
}
from
"
@/api
"
;
import
{
placeStore
}
from
"
@/stores
"
;
import
MsgFieldDisabled
=
ygopro
.
StocGameMessage
.
MsgFieldDisabled
;
import
{
Container
}
from
"
@/container
"
;
export
default
(
fieldDisabled
:
MsgFieldDisabled
)
=>
{
export
default
(
container
:
Container
,
fieldDisabled
:
MsgFieldDisabled
)
=>
{
const
context
=
container
.
context
;
for
(
const
action
of
fieldDisabled
.
actions
)
{
switch
(
action
.
zone
)
{
case
ygopro
.
CardZone
.
MZONE
:
case
ygopro
.
CardZone
.
SZONE
:
const
block
=
placeStore
.
of
(
action
);
const
block
=
context
.
placeStore
.
of
(
context
,
action
);
if
(
block
)
{
block
.
disabled
=
action
.
disabled
;
}
else
{
...
...
src/service/duel/gameMsg.ts
View file @
128d5827
...
...
@@ -273,16 +273,16 @@ export default async function handleGameMsg(
break
;
}
case
"
chaining
"
:
{
await
onMsgChaining
(
msg
.
chaining
);
await
onMsgChaining
(
container
,
msg
.
chaining
);
break
;
}
case
"
chain_solved
"
:
{
await
onMsgChainSolved
(
msg
.
chain_solved
);
await
onMsgChainSolved
(
container
,
msg
.
chain_solved
);
break
;
}
case
"
chain_end
"
:
{
onMsgChainEnd
(
msg
.
chain_end
);
onMsgChainEnd
(
container
,
msg
.
chain_end
);
break
;
}
...
...
@@ -346,7 +346,7 @@ export default async function handleGameMsg(
break
;
}
case
"
field_disabled
"
:
{
onMsgFieldDisabled
(
msg
.
field_disabled
);
onMsgFieldDisabled
(
container
,
msg
.
field_disabled
);
break
;
}
...
...
src/service/duel/selectPlace.ts
View file @
128d5827
import
{
sendSelectPlaceResponse
,
ygopro
}
from
"
@/api
"
;
import
{
Container
}
from
"
@/container
"
;
import
{
InteractType
,
placeStore
}
from
"
@/stores
"
;
import
{
InteractType
}
from
"
@/stores
"
;
type
MsgSelectPlace
=
ygopro
.
StocGameMessage
.
MsgSelectPlace
;
export
default
async
(
container
:
Container
,
selectPlace
:
MsgSelectPlace
)
=>
{
const
conn
=
container
.
conn
;
const
context
=
container
.
context
;
if
(
selectPlace
.
count
!==
1
)
{
console
.
warn
(
`Unhandled case:
${
selectPlace
}
`
);
return
;
...
...
@@ -26,7 +27,7 @@ export default async (container: Container, selectPlace: MsgSelectPlace) => {
switch
(
place
.
zone
)
{
case
ygopro
.
CardZone
.
MZONE
:
case
ygopro
.
CardZone
.
SZONE
:
const
block
=
placeStore
.
of
(
place
);
const
block
=
context
.
placeStore
.
of
(
context
,
place
);
if
(
block
)
{
block
.
interactivity
=
{
interactType
:
InteractType
.
PLACE_SELECTABLE
,
...
...
src/stores/placeStore.ts
View file @
128d5827
...
...
@@ -2,7 +2,7 @@ import { cloneDeep } from "lodash-es";
import
{
proxy
}
from
"
valtio
"
;
import
{
ygopro
}
from
"
@/api
"
;
import
{
matStore
}
from
"
@/stores
"
;
import
{
Context
}
from
"
@/container
"
;
import
type
{
Interactivity
}
from
"
./matStore/types
"
;
import
{
type
NeosStore
}
from
"
./shared
"
;
...
...
@@ -65,14 +65,16 @@ export class PlaceStore implements NeosStore {
op
:
BlockState
[];
};
}
=
initialState
;
of
(
location
:
{
zone
:
ygopro
.
CardZone
;
controller
:
number
;
sequence
:
number
;
}):
BlockState
|
undefined
{
of
(
context
:
Context
,
location
:
{
zone
:
ygopro
.
CardZone
;
controller
:
number
;
sequence
:
number
;
},
):
BlockState
|
undefined
{
return
this
.
inner
[
location
.
zone
][
// FIXME: inject `matStore`
matStore
.
isMe
(
location
.
controller
)
?
"
me
"
:
"
op
"
context
.
matStore
.
isMe
(
location
.
controller
)
?
"
me
"
:
"
op
"
][
location
.
sequence
];
}
clearAllInteractivity
()
{
...
...
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