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
baichixing
Neos
Commits
fcc09e9f
Commit
fcc09e9f
authored
Apr 24, 2023
by
timel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add some logic
parent
cfd62e25
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
79 additions
and
7 deletions
+79
-7
src/api/cards.ts
src/api/cards.ts
+3
-4
src/service/duel/move.ts
src/service/duel/move.ts
+40
-2
src/valtioStores/matStore/methods/fetchCardMeta.ts
src/valtioStores/matStore/methods/fetchCardMeta.ts
+12
-0
src/valtioStores/matStore/methods/fetchOverlayMeta.ts
src/valtioStores/matStore/methods/fetchOverlayMeta.ts
+22
-0
src/valtioStores/matStore/methods/index.ts
src/valtioStores/matStore/methods/index.ts
+1
-0
src/valtioStores/matStore/types.ts
src/valtioStores/matStore/types.ts
+1
-1
No files found.
src/api/cards.ts
View file @
fcc09e9f
...
@@ -54,12 +54,11 @@ export async function fetchCard(
...
@@ -54,12 +54,11 @@ export async function fetchCard(
local
:
boolean
=
true
local
:
boolean
=
true
):
Promise
<
CardMeta
>
{
):
Promise
<
CardMeta
>
{
if
(
local
)
{
if
(
local
)
{
return
await
sqliteMiddleWare
({
const
res
=
await
sqliteMiddleWare
({
cmd
:
sqliteCmd
.
SELECT
,
cmd
:
sqliteCmd
.
SELECT
,
payload
:
{
id
},
payload
:
{
id
},
}).
then
((
res
)
=>
});
res
.
selectResult
?
res
.
selectResult
:
{
id
,
data
:
{},
text
:
{}
}
return
res
.
selectResult
?
res
.
selectResult
:
{
id
,
data
:
{},
text
:
{}
};
);
}
}
const
res
=
await
axios
.
get
<
CardMeta
>
(
"
http://localhost:3030/cards/
"
+
id
);
const
res
=
await
axios
.
get
<
CardMeta
>
(
"
http://localhost:3030/cards/
"
+
id
);
...
...
src/service/duel/move.ts
View file @
fcc09e9f
...
@@ -19,7 +19,10 @@ import {
...
@@ -19,7 +19,10 @@ import {
fetchOverlayMeta
,
fetchOverlayMeta
,
}
from
"
@/reducers/duel/monstersSlice
"
;
}
from
"
@/reducers/duel/monstersSlice
"
;
import
{
AppDispatch
}
from
"
@/store
"
;
import
{
AppDispatch
}
from
"
@/store
"
;
import
{
valtioStore
}
from
"
@/valtioStores
"
;
import
{
valtioStore
,
fetchOverlayMeta
as
FIXME_fetchOverlayMeta
,
}
from
"
@/valtioStores
"
;
import
{
REASON_MATERIAL
}
from
"
../../common
"
;
import
{
REASON_MATERIAL
}
from
"
../../common
"
;
...
@@ -36,6 +39,7 @@ export default (move: MsgMove, dispatch: AppDispatch) => {
...
@@ -36,6 +39,7 @@ export default (move: MsgMove, dispatch: AppDispatch) => {
switch
(
from
.
location
)
{
switch
(
from
.
location
)
{
case
ygopro
.
CardZone
.
MZONE
:
case
ygopro
.
CardZone
.
MZONE
:
case
ygopro
.
CardZone
.
SZONE
:
{
case
ygopro
.
CardZone
.
SZONE
:
{
// 魔陷和怪兽需要清掉占用、清掉超量素材
const
target
=
matStore
.
getZone
(
from
.
location
).
at
(
from
.
controler
)[
const
target
=
matStore
.
getZone
(
from
.
location
).
at
(
from
.
controler
)[
from
.
sequence
from
.
sequence
];
];
...
@@ -48,9 +52,11 @@ export default (move: MsgMove, dispatch: AppDispatch) => {
...
@@ -48,9 +52,11 @@ export default (move: MsgMove, dispatch: AppDispatch) => {
case
ygopro
.
CardZone
.
GRAVE
:
case
ygopro
.
CardZone
.
GRAVE
:
case
ygopro
.
CardZone
.
HAND
:
case
ygopro
.
CardZone
.
HAND
:
case
ygopro
.
CardZone
.
EXTRA
:
{
case
ygopro
.
CardZone
.
EXTRA
:
{
// 其余区域就是在list删掉这张卡
matStore
.
getZone
(
from
.
location
).
remove
(
from
.
controler
,
from
.
sequence
);
matStore
.
getZone
(
from
.
location
).
remove
(
from
.
controler
,
from
.
sequence
);
break
;
break
;
}
}
// 仅仅去除超量素材
case
ygopro
.
CardZone
.
OVERLAY
:
{
case
ygopro
.
CardZone
.
OVERLAY
:
{
const
target
=
matStore
.
monsters
.
at
(
from
.
controler
)[
from
.
sequence
];
const
target
=
matStore
.
monsters
.
at
(
from
.
controler
)[
from
.
sequence
];
if
(
target
&&
target
.
overlay_materials
)
{
if
(
target
&&
target
.
overlay_materials
)
{
...
@@ -65,6 +71,39 @@ export default (move: MsgMove, dispatch: AppDispatch) => {
...
@@ -65,6 +71,39 @@ export default (move: MsgMove, dispatch: AppDispatch) => {
}
}
switch
(
to
.
location
)
{
switch
(
to
.
location
)
{
// @ts-ignore
case
ygopro
.
CardZone
.
MZONE
:
{
// 设置超量素材
const
overlayMetarials
=
OVERLAY_STACK
.
splice
(
0
,
OVERLAY_STACK
.
length
);
const
sorted
=
overlayMetarials
.
sort
((
a
,
b
)
=>
a
.
sequence
-
b
.
sequence
)
.
map
((
overlay
)
=>
overlay
.
code
);
FIXME_fetchOverlayMeta
(
to
.
controler
,
to
.
sequence
,
sorted
);
// 设置Occupant,和魔陷区/其他区共用一个逻辑,特地不写break
}
case
ygopro
.
CardZone
.
SZONE
:
case
ygopro
.
CardZone
.
DECK
:
case
ygopro
.
CardZone
.
REMOVED
:
case
ygopro
.
CardZone
.
GRAVE
:
case
ygopro
.
CardZone
.
HAND
:
case
ygopro
.
CardZone
.
EXTRA
:
{
matStore
.
getZone
(
to
.
location
)
.
setOccupant
(
to
.
controler
,
to
.
sequence
,
code
,
to
.
position
);
break
;
// FIXME 这里逻辑不对...
}
case
ygopro
.
CardZone
.
HAND
:
{
matStore
.
hands
.
insert
(
to
.
controler
,
to
.
sequence
,
code
);
break
;
}
case
ygopro
.
CardZone
.
OVERLAY
:
{
break
;
}
default
:
{
console
.
log
(
`Unhandled zone type
${
to
.
location
}
`
);
break
;
}
}
}
switch
(
from
.
location
)
{
switch
(
from
.
location
)
{
...
@@ -175,7 +214,6 @@ export default (move: MsgMove, dispatch: AppDispatch) => {
...
@@ -175,7 +214,6 @@ export default (move: MsgMove, dispatch: AppDispatch) => {
dispatch
(
dispatch
(
insertHandMeta
({
controler
:
to
.
controler
,
sequence
:
to
.
sequence
,
code
})
insertHandMeta
({
controler
:
to
.
controler
,
sequence
:
to
.
sequence
,
code
})
);
);
matStore
.
hands
.
insert
(
to
.
controler
,
to
.
sequence
,
code
);
break
;
break
;
}
}
...
...
src/valtioStores/matStore/methods/fetchCardMeta.ts
0 → 100644
View file @
fcc09e9f
import
{
ygopro
,
fetchCard
}
from
"
@/api
"
;
import
{
matStore
,
getCardByLocation
}
from
"
@/valtioStores
"
;
export
const
fetchCardMeta
=
async
(
zone
:
ygopro
.
CardZone
,
controler
:
number
,
sequence
:
number
,
code
:
number
,
position
?:
ygopro
.
CardPosition
)
=>
{
await
matStore
.
getZone
(
zone
).
setOccupant
(
controler
,
sequence
,
code
,
position
);
};
src/valtioStores/matStore/methods/fetchOverlayMeta.ts
0 → 100644
View file @
fcc09e9f
import
{
fetchCard
}
from
"
@/api
"
;
import
{
matStore
}
from
"
@/valtioStores
"
;
export
const
fetchOverlayMeta
=
async
(
controller
:
number
,
sequence
:
number
,
overlayCodes
:
number
[],
append
?:
boolean
)
=>
{
const
metas
=
await
Promise
.
all
(
overlayCodes
.
map
(
async
(
id
)
=>
await
fetchCard
(
id
))
);
const
target
=
matStore
.
monsters
.
at
(
controller
)[
sequence
];
if
(
target
&&
target
.
occupant
)
{
if
(
append
)
{
target
.
overlay_materials
=
(
target
.
overlay_materials
||
[]).
concat
(
metas
);
}
else
{
target
.
overlay_materials
=
metas
;
}
}
};
src/valtioStores/matStore/methods/index.ts
View file @
fcc09e9f
export
*
from
"
./fetchCheckCardMeta
"
;
export
*
from
"
./fetchCheckCardMeta
"
;
export
*
from
"
./fetchHint
"
;
export
*
from
"
./fetchHint
"
;
export
*
from
"
./getCardByLocation
"
;
export
*
from
"
./getCardByLocation
"
;
export
*
from
"
./fetchOverlayMeta
"
;
src/valtioStores/matStore/types.ts
View file @
fcc09e9f
...
@@ -24,7 +24,7 @@ export interface CardsBothSide<T extends DuelFieldState> extends BothSide<T> {
...
@@ -24,7 +24,7 @@ export interface CardsBothSide<T extends DuelFieldState> extends BothSide<T> {
sequence
:
number
,
sequence
:
number
,
id
:
number
,
id
:
number
,
position
?:
ygopro
.
CardPosition
position
?:
ygopro
.
CardPosition
)
=>
void
;
)
=>
Promise
<
void
>
;
/** 添加 idle 的交互性 */
/** 添加 idle 的交互性 */
addIdleInteractivity
:
(
addIdleInteractivity
:
(
controller
:
number
,
controller
:
number
,
...
...
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