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
23ade447
Commit
23ade447
authored
Apr 23, 2023
by
timel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: valtio store logic 80%
parent
24998446
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
1 deletion
+88
-1
src/service/duel/selectBattleCmd.ts
src/service/duel/selectBattleCmd.ts
+36
-0
src/service/duel/selectIdleCmd.ts
src/service/duel/selectIdleCmd.ts
+33
-1
src/service/duel/shuffleHand.ts
src/service/duel/shuffleHand.ts
+19
-0
No files found.
src/service/duel/selectBattleCmd.ts
View file @
23ade447
...
...
@@ -11,6 +11,12 @@ import {
setEnableM2
,
}
from
"
@/reducers/duel/mod
"
;
import
{
AppDispatch
}
from
"
@/store
"
;
import
{
clearAllIdleInteractivities
as
FIXME_clearAllIdleInteractivities
,
matStore
,
}
from
"
@/valtioStores
"
;
import
MsgSelectBattleCmd
=
ygopro
.
StocGameMessage
.
MsgSelectBattleCmd
;
export
default
(
selectBattleCmd
:
MsgSelectBattleCmd
,
dispatch
:
AppDispatch
)
=>
{
...
...
@@ -20,6 +26,8 @@ export default (selectBattleCmd: MsgSelectBattleCmd, dispatch: AppDispatch) => {
// 先清掉之前的互动性
dispatch
(
clearAllIdleInteractivities
(
player
));
FIXME_clearAllIdleInteractivities
(
player
);
const
dispatcher
=
(
battleData
:
MsgSelectBattleCmd
.
BattleCmd
.
BattleData
,
interactType
:
InteractType
|
undefined
,
...
...
@@ -67,6 +75,30 @@ export default (selectBattleCmd: MsgSelectBattleCmd, dispatch: AppDispatch) => {
cmd
.
battle_datas
.
forEach
((
data
)
=>
{
const
cardInfo
=
data
.
card_info
;
// valtio
if
(
interactType
)
{
const
map
:
Partial
<
Record
<
InteractType
,
undefined
|
Partial
<
Interactivity
<
number
>>>
>
=
{
[
InteractType
.
ACTIVATE
]:
{
activateIndex
:
data
.
effect_description
},
[
InteractType
.
ATTACK
]:
{
directAttackAble
:
data
.
direct_attackable
},
};
const
tmp
=
map
[
interactType
];
if
(
tmp
)
{
matStore
.
getZone
(
cardInfo
.
location
)
.
addIdleInteractivity
(
player
,
cardInfo
.
sequence
,
{
...
tmp
,
interactType
,
response
:
data
.
response
,
});
}
else
{
console
.
warn
(
`Unhandled InteractType:`
,
interactType
);
}
}
// >>> 从这开始删除 >>>
switch
(
cardInfo
.
location
)
{
case
ygopro
.
CardZone
.
HAND
:
{
dispatcher
(
data
,
interactType
,
addHandsIdleInteractivity
);
...
...
@@ -86,11 +118,15 @@ export default (selectBattleCmd: MsgSelectBattleCmd, dispatch: AppDispatch) => {
default
:
{
}
}
// <<< 到这结束删除,上面的const dispatcher也删掉 <<<
});
});
dispatch
(
setEnableM2
(
selectBattleCmd
.
enable_m2
));
dispatch
(
setEnableEp
(
selectBattleCmd
.
enable_ep
));
matStore
.
phase
.
enableM2
=
selectBattleCmd
.
enable_m2
;
matStore
.
phase
.
enableEp
=
selectBattleCmd
.
enable_ep
;
};
function
battleTypeToInteracType
(
...
...
src/service/duel/selectIdleCmd.ts
View file @
23ade447
...
...
@@ -12,15 +12,22 @@ import {
setEnableEp
,
}
from
"
@/reducers/duel/mod
"
;
import
{
AppDispatch
}
from
"
@/store
"
;
import
MsgSelectIdleCmd
=
ygopro
.
StocGameMessage
.
MsgSelectIdleCmd
;
import
{
ActionCreatorWithPayload
}
from
"
@reduxjs/toolkit
"
;
import
{
clearAllIdleInteractivities
as
FIXME_clearAllIdleInteractivities
,
matStore
,
}
from
"
@/valtioStores
"
;
import
MsgSelectIdleCmd
=
ygopro
.
StocGameMessage
.
MsgSelectIdleCmd
;
export
default
(
selectIdleCmd
:
MsgSelectIdleCmd
,
dispatch
:
AppDispatch
)
=>
{
const
player
=
selectIdleCmd
.
player
;
const
cmds
=
selectIdleCmd
.
idle_cmds
;
// 先清掉之前的互动性
dispatch
(
clearAllIdleInteractivities
(
player
));
FIXME_clearAllIdleInteractivities
(
player
);
const
dispatcher
=
(
idleData
:
MsgSelectIdleCmd
.
IdleCmd
.
IdleData
,
...
...
@@ -66,6 +73,28 @@ export default (selectIdleCmd: MsgSelectIdleCmd, dispatch: AppDispatch) => {
cmd
.
idle_datas
.
forEach
((
data
)
=>
{
const
cardInfo
=
data
.
card_info
;
// valtio。代码从 ./selectBattleCmd.ts 复制过来的
if
(
interactType
)
{
const
map
:
Partial
<
Record
<
InteractType
,
undefined
|
Partial
<
Interactivity
<
number
>>>
>
=
{
[
InteractType
.
ACTIVATE
]:
{
activateIndex
:
data
.
effect_description
},
};
const
tmp
=
map
[
interactType
];
if
(
tmp
)
{
matStore
.
getZone
(
cardInfo
.
location
)
.
addIdleInteractivity
(
player
,
cardInfo
.
sequence
,
{
...
tmp
,
interactType
,
response
:
data
.
response
,
});
}
else
{
console
.
warn
(
`Unhandled InteractType:`
,
interactType
);
}
}
switch
(
cardInfo
.
location
)
{
case
ygopro
.
CardZone
.
HAND
:
{
dispatcher
(
data
,
interactType
,
addHandsIdleInteractivity
);
...
...
@@ -106,6 +135,9 @@ export default (selectIdleCmd: MsgSelectIdleCmd, dispatch: AppDispatch) => {
dispatch
(
setEnableBp
(
selectIdleCmd
.
enable_bp
));
dispatch
(
setEnableEp
(
selectIdleCmd
.
enable_ep
));
matStore
.
phase
.
enableBp
=
selectIdleCmd
.
enable_bp
;
matStore
.
phase
.
enableEp
=
selectIdleCmd
.
enable_ep
;
};
function
idleTypeToInteractType
(
...
...
src/service/duel/shuffleHand.ts
View file @
23ade447
...
...
@@ -3,8 +3,27 @@ import { updateHandsMeta } from "@/reducers/duel/handsSlice";
import
{
AppDispatch
}
from
"
@/store
"
;
import
MsgShuffleHand
=
ygopro
.
StocGameMessage
.
MsgShuffleHand
;
import
{
matStore
}
from
"
@/valtioStores
"
;
export
default
(
shuffleHand
:
MsgShuffleHand
,
dispatch
:
AppDispatch
)
=>
{
dispatch
(
updateHandsMeta
({
controler
:
shuffleHand
.
player
,
codes
:
shuffleHand
.
hands
})
);
const
{
hands
:
codes
,
player
:
controller
}
=
shuffleHand
;
const
metas
=
codes
.
map
((
code
)
=>
{
return
{
occupant
:
{
id
:
code
,
data
:
{},
text
:
{}
},
location
:
{
controler
:
controller
,
location
:
ygopro
.
CardZone
.
HAND
,
},
idleInteractivities
:
[],
counters
:
{},
};
});
matStore
.
hands
.
at
(
controller
).
length
=
0
;
matStore
.
hands
.
at
(
controller
).
push
(...
metas
);
};
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