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
love_飞影
Neos
Commits
cfd5585e
Commit
cfd5585e
authored
Apr 28, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix/valtio' into 'main'
Fix/valtio See merge request
mycard/Neos!174
parents
2aa3893b
4f8fd00d
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
46 additions
and
39 deletions
+46
-39
src/service/duel/move.ts
src/service/duel/move.ts
+4
-1
src/service/duel/shuffleHand.ts
src/service/duel/shuffleHand.ts
+1
-13
src/stores/matStore/store.ts
src/stores/matStore/store.ts
+11
-5
src/stores/matStore/types.ts
src/stores/matStore/types.ts
+7
-3
src/stores/moraStore.ts
src/stores/moraStore.ts
+2
-2
src/ui/Duel/Message/CardModal.tsx
src/ui/Duel/Message/CardModal.tsx
+0
-4
src/ui/Duel/Message/HintNotification.tsx
src/ui/Duel/Message/HintNotification.tsx
+6
-6
src/ui/Mora.tsx
src/ui/Mora.tsx
+4
-3
src/ui/WaitRoom.tsx
src/ui/WaitRoom.tsx
+11
-2
No files found.
src/service/duel/move.ts
View file @
cfd5585e
...
...
@@ -72,7 +72,10 @@ export default (move: MsgMove) => {
case
ygopro
.
CardZone
.
GRAVE
:
case
ygopro
.
CardZone
.
EXTRA
:
case
ygopro
.
CardZone
.
HAND
:
{
matStore
.
in
(
to
.
location
).
of
(
to
.
controler
).
insert
(
to
.
sequence
,
code
);
matStore
.
in
(
to
.
location
)
.
of
(
to
.
controler
)
.
insert
(
code
,
to
.
sequence
,
to
.
position
);
break
;
}
case
ygopro
.
CardZone
.
OVERLAY
:
{
...
...
src/service/duel/shuffleHand.ts
View file @
cfd5585e
...
...
@@ -6,18 +6,6 @@ type MsgShuffleHand = ygopro.StocGameMessage.MsgShuffleHand;
export
default
(
shuffleHand
:
MsgShuffleHand
)
=>
{
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
.
of
(
controller
).
length
=
0
;
matStore
.
hands
.
of
(
controller
).
push
(...
meta
s
);
matStore
.
hands
.
of
(
controller
).
add
(
code
s
);
};
src/stores/matStore/store.ts
View file @
cfd5585e
...
...
@@ -24,11 +24,17 @@ class CardArray extends Array<CardState> implements ArrayCardState {
public
__proto__
=
CardArray
.
prototype
;
public
zone
:
ygopro
.
CardZone
=
ygopro
.
CardZone
.
MZONE
;
public
getController
:
()
=>
number
=
()
=>
1
;
private
genCard
=
async
(
controller
:
number
,
id
:
number
)
=>
({
private
genCard
=
async
(
controller
:
number
,
id
:
number
,
position
?:
ygopro
.
CardPosition
)
=>
({
occupant
:
await
fetchCard
(
id
,
true
),
location
:
{
controler
:
controller
,
location
:
this
.
zone
,
position
:
position
==
undefined
?
ygopro
.
CardPosition
.
FACEUP_ATTACK
:
position
,
},
counters
:
{},
idleInteractivities
:
[],
...
...
@@ -37,13 +43,13 @@ class CardArray extends Array<CardState> implements ArrayCardState {
remove
(
sequence
:
number
)
{
this
.
splice
(
sequence
,
1
);
}
async
insert
(
sequence
:
number
,
id
:
number
)
{
const
card
=
await
this
.
genCard
(
this
.
getController
(),
id
);
async
insert
(
sequence
:
number
,
id
:
number
,
position
?:
ygopro
.
CardPosition
)
{
const
card
=
await
this
.
genCard
(
this
.
getController
(),
id
,
position
);
this
.
splice
(
sequence
,
0
,
card
);
}
async
add
(
ids
:
number
[])
{
async
add
(
ids
:
number
[]
,
position
?:
ygopro
.
CardPosition
)
{
const
cards
=
await
Promise
.
all
(
ids
.
map
(
async
(
id
)
=>
this
.
genCard
(
this
.
getController
(),
id
))
ids
.
map
(
async
(
id
)
=>
this
.
genCard
(
this
.
getController
(),
id
,
position
))
);
this
.
splice
(
this
.
length
,
0
,
...
cards
);
}
...
...
src/stores/matStore/types.ts
View file @
cfd5585e
...
...
@@ -15,10 +15,14 @@ export interface BothSide<T> {
export
interface
DuelFieldState
extends
Array
<
CardState
>
{
/** 移除特定位置的卡片 */
remove
:
(
sequence
:
number
)
=>
void
;
/** 在末尾添加卡片 */
insert
:
(
sequence
:
number
,
id
:
number
)
=>
Promise
<
void
>
;
/** 在指定位置插入卡片 */
add
:
(
ids
:
number
[])
=>
Promise
<
void
>
;
insert
:
(
id
:
number
,
sequence
:
number
,
position
?:
ygopro
.
CardPosition
)
=>
Promise
<
void
>
;
/** 在末尾添加卡片 */
add
:
(
ids
:
number
[],
position
?:
ygopro
.
CardPosition
)
=>
Promise
<
void
>
;
/** 设置占据这个位置的卡片信息 */
setOccupant
:
(
sequence
:
number
,
...
...
src/stores/moraStore.ts
View file @
cfd5585e
...
...
@@ -8,6 +8,6 @@ export interface MoraState {
export
const
moraStore
=
proxy
<
MoraState
>
({
duelStart
:
false
,
selectHandAble
:
tru
e
,
selectTpAble
:
tru
e
,
selectHandAble
:
fals
e
,
selectTpAble
:
fals
e
,
});
src/ui/Duel/Message/CardModal.tsx
View file @
cfd5585e
...
...
@@ -28,10 +28,6 @@ const { cardModal } = messageStore;
export
const
CardModal
=
()
=>
{
const
snapCardModal
=
useSnapshot
(
cardModal
);
// const dispatch = store.dispatch;
// const isOpen = useAppSelector(selectCardModalIsOpen);
// const meta = useAppSelector(selectCardModalMeta);
const
isOpen
=
snapCardModal
.
isOpen
;
const
meta
=
snapCardModal
.
meta
;
...
...
src/ui/Duel/Message/HintNotification.tsx
View file @
cfd5585e
...
...
@@ -11,12 +11,12 @@ const MsgWin = ygopro.StocGameMessage.MsgWin;
const
NeosConfig
=
useConfig
();
export
const
HintNotification
=
()
=>
{
const
hintState
=
matStore
.
hint
;
const
hintS
nap
=
useSnapshot
(
matStore
.
hint
)
;
const
snap
=
useSnapshot
(
matStore
)
;
const
hintS
tate
=
snap
.
hint
;
const
currentPhase
=
matStore
.
phase
.
currentPhase
;
const
waiting
=
matStore
.
waiting
;
const
result
=
matStore
.
result
;
const
currentPhase
=
snap
.
phase
.
currentPhase
;
const
waiting
=
snap
.
waiting
;
const
result
=
snap
.
result
;
const
navigate
=
useNavigate
();
...
...
@@ -30,7 +30,7 @@ export const HintNotification = () => {
placement
:
"
bottom
"
,
});
}
},
[
hintS
nap
?
.
msg
]);
},
[
hintS
tate
.
msg
]);
useEffect
(()
=>
{
if
(
currentPhase
)
{
...
...
src/ui/Mora.tsx
View file @
cfd5585e
...
...
@@ -19,7 +19,8 @@ const {
const
Mora
=
()
=>
{
const
snapMora
=
useSnapshot
(
moraStore
);
const
snapMatInitInfo
=
useSnapshot
(
matStore
.
initInfo
);
const
snapMat
=
useSnapshot
(
matStore
);
const
meLife
=
snapMat
.
initInfo
.
me
.
life
;
const
selectHandAble
=
snapMora
.
selectHandAble
;
const
selectTpAble
=
snapMora
.
selectTpAble
;
...
...
@@ -42,10 +43,10 @@ const Mora = () => {
useEffect
(()
=>
{
// 若对局已经开始,自动跳转
if
(
snapMatInitInfo
.
me
.
l
ife
>
0
)
{
if
(
meL
ife
>
0
)
{
navigate
(
`/duel/
${
player
}
/
${
passWd
}
/
${
ip
}
`
);
}
},
[
snapMatInitInfo
.
m
e
]);
},
[
meLif
e
]);
useEffect
(()
=>
{
if
(
isAiMode
)
{
...
...
src/ui/WaitRoom.tsx
View file @
cfd5585e
...
...
@@ -25,7 +25,13 @@ import rustInit from "rust-src";
import
{
useSnapshot
}
from
"
valtio
"
;
import
YGOProDeck
from
"
ygopro-deck-encode
"
;
import
{
initStrings
,
sendHsReady
,
sendHsStart
,
sendUpdateDeck
}
from
"
@/api
"
;
import
{
initStrings
,
sendHsReady
,
sendHsStart
,
sendUpdateDeck
,
ygopro
,
}
from
"
@/api
"
;
import
{
DeckManager
,
fetchDeck
,
type
IDeck
}
from
"
@/api/deck
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
socketMiddleWare
,
{
socketCmd
}
from
"
@/middleware/socket
"
;
...
...
@@ -137,7 +143,10 @@ const WaitRoom = () => {
const
onDeckReady
=
async
(
deck
:
IDeck
)
=>
{
sendUpdateDeck
(
deck
);
store
.
matStore
.
extraDecks
.
me
.
add
(
deck
.
extra
?.
reverse
()
||
[]);
store
.
matStore
.
extraDecks
.
me
.
add
(
deck
.
extra
?.
reverse
()
||
[],
ygopro
.
CardPosition
.
FACEDOWN_ATTACK
);
setChoseDeck
(
true
);
};
...
...
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