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
75fdc88a
Commit
75fdc88a
authored
Apr 24, 2023
by
timel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: types
parent
fcc09e9f
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
71 additions
and
73 deletions
+71
-73
src/service/duel/move.ts
src/service/duel/move.ts
+19
-12
src/service/duel/posChange.ts
src/service/duel/posChange.ts
+18
-14
src/service/duel/reloadField.ts
src/service/duel/reloadField.ts
+3
-3
src/service/duel/selectBattleCmd.ts
src/service/duel/selectBattleCmd.ts
+1
-1
src/service/duel/selectIdleCmd.ts
src/service/duel/selectIdleCmd.ts
+1
-1
src/service/duel/shuffleHand.ts
src/service/duel/shuffleHand.ts
+2
-2
src/service/duel/start.ts
src/service/duel/start.ts
+4
-4
src/service/duel/updateData.ts
src/service/duel/updateData.ts
+1
-1
src/service/duel/updateHp.ts
src/service/duel/updateHp.ts
+2
-2
src/valtioStores/matStore/methods/fetchCardMeta.ts
src/valtioStores/matStore/methods/fetchCardMeta.ts
+0
-12
src/valtioStores/matStore/methods/fetchCheckCardMeta.ts
src/valtioStores/matStore/methods/fetchCheckCardMeta.ts
+1
-1
src/valtioStores/matStore/methods/fetchHint.ts
src/valtioStores/matStore/methods/fetchHint.ts
+2
-2
src/valtioStores/matStore/methods/fetchOverlayMeta.ts
src/valtioStores/matStore/methods/fetchOverlayMeta.ts
+1
-1
src/valtioStores/matStore/methods/getCardByLocation.ts
src/valtioStores/matStore/methods/getCardByLocation.ts
+1
-1
src/valtioStores/matStore/store.ts
src/valtioStores/matStore/store.ts
+11
-11
src/valtioStores/matStore/types.ts
src/valtioStores/matStore/types.ts
+4
-5
No files found.
src/service/duel/move.ts
View file @
75fdc88a
...
...
@@ -36,29 +36,31 @@ export default (move: MsgMove, dispatch: AppDispatch) => {
const
to
=
move
.
to
;
const
reason
=
move
.
reason
;
// TODO: 如果后面做动画的话,要考虑DECK的情况。
// 现在不会对DECK做判断
switch
(
from
.
location
)
{
case
ygopro
.
CardZone
.
MZONE
:
case
ygopro
.
CardZone
.
SZONE
:
{
// 魔陷和怪兽需要清掉占用、清掉超量素材
const
target
=
matStore
.
getZone
(
from
.
location
).
at
(
from
.
controler
)[
const
target
=
matStore
.
in
(
from
.
location
).
of
(
from
.
controler
)[
from
.
sequence
];
target
.
occupant
=
undefined
;
target
.
overlay_materials
=
[];
break
;
}
case
ygopro
.
CardZone
.
HAND
:
case
ygopro
.
CardZone
.
REMOVED
:
case
ygopro
.
CardZone
.
GRAVE
:
case
ygopro
.
CardZone
.
HAND
:
case
ygopro
.
CardZone
.
EXTRA
:
{
// 其余区域就是在list删掉这张卡
matStore
.
getZone
(
from
.
location
).
remove
(
from
.
controler
,
from
.
sequence
);
matStore
.
in
(
from
.
location
).
remove
(
from
.
controler
,
from
.
sequence
);
break
;
}
// 仅仅去除超量素材
case
ygopro
.
CardZone
.
OVERLAY
:
{
const
target
=
matStore
.
monsters
.
at
(
from
.
controler
)[
from
.
sequence
];
const
target
=
matStore
.
monsters
.
of
(
from
.
controler
)[
from
.
sequence
];
if
(
target
&&
target
.
overlay_materials
)
{
target
.
overlay_materials
.
splice
(
from
.
overlay_sequence
,
1
);
}
...
...
@@ -81,23 +83,28 @@ export default (move: MsgMove, dispatch: AppDispatch) => {
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
:
{
case
ygopro
.
CardZone
.
SZONE
:
{
matStore
.
getZone
(
to
.
location
)
.
in
(
to
.
location
)
.
setOccupant
(
to
.
controler
,
to
.
sequence
,
code
,
to
.
position
);
break
;
// FIXME 这里逻辑不对...
}
case
ygopro
.
CardZone
.
REMOVED
:
case
ygopro
.
CardZone
.
GRAVE
:
case
ygopro
.
CardZone
.
EXTRA
:
case
ygopro
.
CardZone
.
HAND
:
{
matStore
.
hands
.
insert
(
to
.
controler
,
to
.
sequence
,
code
);
break
;
}
case
ygopro
.
CardZone
.
OVERLAY
:
{
if
(
reason
==
REASON_MATERIAL
)
{
// 超量素材在进行超量召唤时,若玩家未选择超量怪兽的位置,会“沉到决斗盘下面”,`reason`字段值是`REASON_MATERIAL`
// 这时候将它们放到一个栈中,待超量怪兽的Move消息到来时从栈中获取超量素材补充到状态中
OVERLAY_STACK
.
push
({
code
,
sequence
:
to
.
overlay_sequence
});
}
else
{
// 其他情况下,比如“宵星的机神 丁吉尔苏”的“补充超量素材”效果,直接更新状态中
FIXME_fetchOverlayMeta
(
to
.
controler
,
to
.
sequence
,
[
code
],
true
);
}
break
;
}
default
:
{
...
...
src/service/duel/posChange.ts
View file @
75fdc88a
...
...
@@ -3,43 +3,47 @@ import { fetchEsHintMeta } from "@/reducers/duel/hintSlice";
import
{
setMagicPosition
,
setMonsterPosition
}
from
"
@/reducers/duel/mod
"
;
import
{
AppDispatch
}
from
"
@/store
"
;
import
MsgPosChange
=
ygopro
.
StocGameMessage
.
MsgPosChange
;
import
{
matStore
}
from
"
@/valtioStores
"
;
import
{
matStore
,
fetchEsHintMeta
as
FIXME_fetchEsHintMeta
,
}
from
"
@/valtioStores
"
;
export
default
(
posChange
:
MsgPosChange
,
dispatch
:
AppDispatch
)
=>
{
const
cardInfo
=
posChange
.
card_info
;
const
{
location
,
controler
,
sequence
}
=
posChange
.
card_info
;
switch
(
cardInfo
.
location
)
{
switch
(
location
)
{
case
ygopro
.
CardZone
.
MZONE
:
{
dispatch
(
setMonsterPosition
({
controler
:
c
ardInfo
.
c
ontroler
,
sequence
:
cardInfo
.
sequence
,
controler
:
controler
,
sequence
,
position
:
posChange
.
cur_position
,
})
);
matStore
.
monsters
.
at
(
cardInfo
.
controler
)[
cardInfo
.
sequence
].
location
.
position
=
posChange
.
cur_position
;
matStore
.
monsters
.
of
(
controler
)[
sequence
].
location
.
position
=
posChange
.
cur_position
;
break
;
}
case
ygopro
.
CardZone
.
SZONE
:
{
dispatch
(
setMagicPosition
({
controler
:
c
ardInfo
.
c
ontroler
,
sequence
:
cardInfo
.
sequence
,
controler
:
controler
,
sequence
,
position
:
posChange
.
cur_position
,
})
);
matStore
.
magics
.
at
(
cardInfo
.
controler
)[
cardInfo
.
sequence
].
location
.
position
=
posChange
.
cur_position
;
matStore
.
magics
.
of
(
controler
)[
sequence
].
location
.
position
=
posChange
.
cur_position
;
break
;
}
default
:
{
console
.
log
(
`Unhandled zone
${
cardInfo
.
location
}
`
);
console
.
log
(
`Unhandled zone
${
location
}
`
);
}
}
dispatch
(
fetchEsHintMeta
({
originMsg
:
1600
}));
FIXME_fetchEsHintMeta
({
originMsg
:
1600
,
});
};
src/service/duel/reloadField.ts
View file @
75fdc88a
...
...
@@ -55,9 +55,9 @@ function reloadDuelField(
reload
:
true
,
};
});
matStore
.
getZone
(
cardZone
).
at
(
controller
).
length
=
0
;
matStore
.
in
(
cardZone
).
of
(
controller
).
length
=
0
;
matStore
.
getZone
(
cardZone
)
.
at
(
controller
)
.
in
(
cardZone
)
.
of
(
controller
)
.
push
(...
cards
);
}
src/service/duel/selectBattleCmd.ts
View file @
75fdc88a
...
...
@@ -87,7 +87,7 @@ export default (selectBattleCmd: MsgSelectBattleCmd, dispatch: AppDispatch) => {
const
tmp
=
map
[
interactType
];
if
(
tmp
)
{
matStore
.
getZone
(
cardInfo
.
location
)
.
in
(
cardInfo
.
location
)
.
addIdleInteractivity
(
player
,
cardInfo
.
sequence
,
{
...
tmp
,
interactType
,
...
...
src/service/duel/selectIdleCmd.ts
View file @
75fdc88a
...
...
@@ -84,7 +84,7 @@ export default (selectIdleCmd: MsgSelectIdleCmd, dispatch: AppDispatch) => {
const
tmp
=
map
[
interactType
];
if
(
tmp
)
{
matStore
.
getZone
(
cardInfo
.
location
)
.
in
(
cardInfo
.
location
)
.
addIdleInteractivity
(
player
,
cardInfo
.
sequence
,
{
...
tmp
,
interactType
,
...
...
src/service/duel/shuffleHand.ts
View file @
75fdc88a
...
...
@@ -24,6 +24,6 @@ export default (shuffleHand: MsgShuffleHand, dispatch: AppDispatch) => {
};
});
matStore
.
hands
.
at
(
controller
).
length
=
0
;
matStore
.
hands
.
at
(
controller
).
push
(...
metas
);
matStore
.
hands
.
of
(
controller
).
length
=
0
;
matStore
.
hands
.
of
(
controller
).
push
(...
metas
);
};
src/service/duel/start.ts
View file @
75fdc88a
...
...
@@ -71,10 +71,10 @@ export default (
// <<< 删除 <<<
// 上面的删除就可以了
matStore
.
monsters
.
at
(
0
).
forEach
((
x
)
=>
(
x
.
location
.
controler
=
0
));
matStore
.
monsters
.
at
(
1
).
forEach
((
x
)
=>
(
x
.
location
.
controler
=
1
));
matStore
.
magics
.
at
(
0
).
forEach
((
x
)
=>
(
x
.
location
.
controler
=
0
));
matStore
.
magics
.
at
(
1
).
forEach
((
x
)
=>
(
x
.
location
.
controler
=
1
));
matStore
.
monsters
.
of
(
0
).
forEach
((
x
)
=>
(
x
.
location
.
controler
=
0
));
matStore
.
monsters
.
of
(
1
).
forEach
((
x
)
=>
(
x
.
location
.
controler
=
1
));
matStore
.
magics
.
of
(
0
).
forEach
((
x
)
=>
(
x
.
location
.
controler
=
0
));
matStore
.
magics
.
of
(
1
).
forEach
((
x
)
=>
(
x
.
location
.
controler
=
1
));
matStore
.
decks
.
add
(
0
,
Array
(
start
.
deckSize1
).
fill
(
0
));
matStore
.
decks
.
add
(
1
,
Array
(
start
.
deckSize2
).
fill
(
0
));
...
...
src/service/duel/updateData.ts
View file @
75fdc88a
...
...
@@ -10,7 +10,7 @@ export default (updateData: MsgUpdateData, dispatch: AppDispatch) => {
const
{
player
:
controller
,
zone
,
actions
}
=
updateData
;
if
(
controller
!==
undefined
&&
zone
!==
undefined
&&
actions
!==
undefined
)
{
const
field
=
matStore
.
getZone
(
zone
).
at
(
controller
);
const
field
=
matStore
.
in
(
zone
).
of
(
controller
);
actions
.
forEach
((
action
)
=>
{
const
sequence
=
action
.
location
?.
sequence
;
if
(
typeof
sequence
!==
"
undefined
"
)
{
...
...
src/service/duel/updateHp.ts
View file @
75fdc88a
...
...
@@ -12,11 +12,11 @@ export default (msgUpdateHp: MsgUpdateHp, dispatch: AppDispatch) => {
if
(
msgUpdateHp
.
type_
==
MsgUpdateHp
.
ActionType
.
DAMAGE
)
{
dispatch
(
fetchEsHintMeta
({
originMsg
:
"
玩家收到伤害时
"
}));
// TODO: i18n
FIXME_fetchEsHintMeta
({
originMsg
:
"
玩家收到伤害时
"
});
matStore
.
initInfo
.
at
(
msgUpdateHp
.
player
).
life
-=
msgUpdateHp
.
value
;
matStore
.
initInfo
.
of
(
msgUpdateHp
.
player
).
life
-=
msgUpdateHp
.
value
;
}
else
if
(
msgUpdateHp
.
type_
==
MsgUpdateHp
.
ActionType
.
RECOVER
)
{
dispatch
(
fetchEsHintMeta
({
originMsg
:
"
玩家生命值回复时
"
}));
// TODO: i18n
FIXME_fetchEsHintMeta
({
originMsg
:
"
玩家生命值回复时
"
});
matStore
.
initInfo
.
at
(
msgUpdateHp
.
player
).
life
+=
msgUpdateHp
.
value
;
matStore
.
initInfo
.
of
(
msgUpdateHp
.
player
).
life
+=
msgUpdateHp
.
value
;
}
dispatch
(
updateHp
(
msgUpdateHp
));
// 可以删除了
...
...
src/valtioStores/matStore/methods/fetchCardMeta.ts
deleted
100644 → 0
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/fetchCheckCardMeta.ts
View file @
75fdc88a
...
...
@@ -102,7 +102,7 @@ export const fetchCheckCardMeta = async (
const
newID
=
code
!=
0
?
code
:
matStore
.
getZone
(
location
.
location
).
at
(
controller
)[
location
.
sequence
]
:
matStore
.
in
(
location
.
location
).
of
(
controller
)[
location
.
sequence
]
?.
occupant
?.
id
||
0
;
const
newOption
=
{
meta
:
{
id
:
newID
,
data
:
{},
text
:
{}
},
...
...
src/valtioStores/matStore/methods/fetchHint.ts
View file @
75fdc88a
...
...
@@ -63,8 +63,8 @@ export const fetchEsHintMeta = async ({
if
(
location
)
{
const
fieldMeta
=
matStore
.
getZone
(
location
.
location
)
.
at
(
location
.
controler
)
.
in
(
location
.
location
)
.
of
(
location
.
controler
)
.
at
(
location
.
sequence
);
if
(
fieldMeta
?.
occupant
?.
text
.
name
)
{
esHint
=
esHint
.
replace
(
"
[?]
"
,
fieldMeta
.
occupant
.
text
.
name
);
...
...
src/valtioStores/matStore/methods/fetchOverlayMeta.ts
View file @
75fdc88a
...
...
@@ -11,7 +11,7 @@ export const fetchOverlayMeta = async (
overlayCodes
.
map
(
async
(
id
)
=>
await
fetchCard
(
id
))
);
const
target
=
matStore
.
monsters
.
at
(
controller
)[
sequence
];
const
target
=
matStore
.
monsters
.
of
(
controller
)[
sequence
];
if
(
target
&&
target
.
occupant
)
{
if
(
append
)
{
target
.
overlay_materials
=
(
target
.
overlay_materials
||
[]).
concat
(
metas
);
...
...
src/valtioStores/matStore/methods/getCardByLocation.ts
View file @
75fdc88a
...
...
@@ -2,7 +2,7 @@ import type { ygopro } from "@/api";
import
{
matStore
}
from
"
@/valtioStores
"
;
export
const
getCardByLocation
=
(
location
:
ygopro
.
CardLocation
)
=>
{
return
matStore
.
getZone
(
location
.
location
).
at
(
location
.
controler
)[
return
matStore
.
in
(
location
.
location
).
of
(
location
.
controler
)[
location
.
sequence
];
};
src/valtioStores/matStore/store.ts
View file @
75fdc88a
...
...
@@ -39,11 +39,11 @@ const isMe = (player: number): boolean => {
}
};
const
genDuel
=
<
T
>
(
obj
:
T
)
=>
{
const
genDuel
=
<
T
>
(
obj
:
T
)
:
BothSide
<
T
>
=>
{
const
res
=
proxy
({
me
:
cloneDeep
(
obj
),
op
:
cloneDeep
(
obj
),
at
:
(
controller
:
number
)
=>
res
[
getWhom
(
controller
)],
of
:
(
controller
:
number
)
=>
res
[
getWhom
(
controller
)],
});
return
res
;
};
...
...
@@ -106,17 +106,17 @@ const wrap = <T extends DuelFieldState>(
const
res
:
CardsBothSide
<
T
>
=
proxy
({
...
entity
,
remove
:
(
controller
:
number
,
sequence
:
number
)
=>
{
res
.
at
(
controller
).
splice
(
sequence
,
1
);
res
.
of
(
controller
).
splice
(
sequence
,
1
);
},
insert
:
async
(
controller
:
number
,
sequence
:
number
,
id
:
number
)
=>
{
const
card
=
await
genCard
(
controller
,
id
);
res
.
at
(
controller
).
splice
(
sequence
,
0
,
card
);
res
.
of
(
controller
).
splice
(
sequence
,
0
,
card
);
},
add
:
async
(
controller
:
number
,
ids
:
number
[])
=>
{
const
cards
=
await
Promise
.
all
(
ids
.
map
(
async
(
id
)
=>
genCard
(
controller
,
id
))
);
res
.
at
(
controller
).
splice
(
res
.
at
(
controller
).
length
,
0
,
...
cards
);
res
.
of
(
controller
).
splice
(
res
.
of
(
controller
).
length
,
0
,
...
cards
);
},
setOccupant
:
async
(
controller
:
number
,
...
...
@@ -125,7 +125,7 @@ const wrap = <T extends DuelFieldState>(
position
?:
ygopro
.
CardPosition
)
=>
{
const
meta
=
await
fetchCard
(
id
);
const
target
=
res
.
at
(
controller
)[
sequence
];
const
target
=
res
.
of
(
controller
)[
sequence
];
target
.
occupant
=
meta
;
if
(
position
)
{
target
.
location
.
position
=
position
;
...
...
@@ -136,17 +136,17 @@ const wrap = <T extends DuelFieldState>(
sequence
:
number
,
interactivity
:
CardState
[
"
idleInteractivities
"
][
number
]
)
=>
{
res
.
at
(
controller
)[
sequence
].
idleInteractivities
.
push
(
interactivity
);
res
.
of
(
controller
)[
sequence
].
idleInteractivities
.
push
(
interactivity
);
},
clearIdleInteractivities
:
(
controller
:
number
)
=>
{
res
.
at
(
controller
).
forEach
((
card
)
=>
(
card
.
idleInteractivities
=
[]));
res
.
of
(
controller
).
forEach
((
card
)
=>
(
card
.
idleInteractivities
=
[]));
},
setPlaceInteractivityType
:
(
controller
:
number
,
sequence
:
number
,
interactType
:
InteractType
)
=>
{
res
.
at
(
controller
)[
sequence
].
placeInteractivity
=
{
res
.
of
(
controller
)[
sequence
].
placeInteractivity
=
{
interactType
:
interactType
,
response
:
{
controler
:
controller
,
...
...
@@ -157,7 +157,7 @@ const wrap = <T extends DuelFieldState>(
},
clearPlaceInteractivity
:
(
controller
:
number
)
=>
{
res
.
at
(
controller
)
.
of
(
controller
)
.
forEach
((
card
)
=>
(
card
.
placeInteractivity
=
undefined
));
},
});
...
...
@@ -226,6 +226,6 @@ export const matStore: MatState = proxy<MatState>({
waiting
:
false
,
unimplemented
:
0
,
// methods
getZone
,
in
:
getZone
,
isMe
,
});
src/valtioStores/matStore/types.ts
View file @
75fdc88a
...
...
@@ -6,12 +6,11 @@ import type { CardMeta } from "@/api/cards";
export
interface
BothSide
<
T
>
{
me
:
T
;
op
:
T
;
at
:
(
controller
:
number
)
=>
T
;
/** 根据controller返回对应的数组,op或者me */
of
:
(
controller
:
number
)
=>
T
;
}
export
interface
CardsBothSide
<
T
extends
DuelFieldState
>
extends
BothSide
<
T
>
{
/** 根据controller返回对应的数组,op或者me */
at
:
(
controller
:
number
)
=>
T
;
/** 移除特定位置的卡片 */
remove
:
(
player
:
number
,
sequence
:
number
)
=>
void
;
/** 在末尾添加卡片 */
...
...
@@ -81,8 +80,8 @@ export interface MatState {
unimplemented
:
number
;
// 未处理的`Message`
// >>> methods >>>
/** 根据zone获取hands/masters/
gy
... */
getZone
:
(
zone
:
ygopro
.
CardZone
)
=>
CardsBothSide
<
DuelFieldState
>
;
/** 根据zone获取hands/masters/
magics
... */
in
:
(
zone
:
ygopro
.
CardZone
)
=>
CardsBothSide
<
DuelFieldState
>
;
/** 根据自己的先后手判断是否是自己 */
isMe
:
(
player
:
number
)
=>
boolean
;
}
...
...
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