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
3405b9d2
Commit
3405b9d2
authored
May 28, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix ts check
parent
77840865
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
103 deletions
+22
-103
src/service/duel/start.ts
src/service/duel/start.ts
+20
-88
src/stores/cardStore.ts
src/stores/cardStore.ts
+1
-1
src/ui/WaitRoom.tsx
src/ui/WaitRoom.tsx
+1
-14
No files found.
src/service/duel/start.ts
View file @
3405b9d2
import
{
v4
as
v4uuid
}
from
"
uuid
"
;
import
{
fetchCard
,
ygopro
}
from
"
@/api
"
;
import
{
playerStore
,
store
,
cardStore
,
CardType
}
from
"
@/stores
"
;
import
{
flatten
}
from
"
lodash-es
"
;
import
{
flatten
}
from
"
lodash-es
"
;
import
{
v4
as
v4uuid
}
from
"
uuid
"
;
import
{
proxy
}
from
"
valtio
"
;
import
{
proxy
}
from
"
valtio
"
;
import
{
subscribeKey
}
from
"
valtio/utils
"
;
import
{
subscribeKey
}
from
"
valtio/utils
"
;
import
{
fetchCard
,
ygopro
}
from
"
@/api
"
;
import
{
cardStore
,
CardType
,
playerStore
,
store
}
from
"
@/stores
"
;
const
{
matStore
}
=
store
;
const
{
matStore
}
=
store
;
const
TOKEN_SIZE
=
13
;
// 每人场上最多就只可能有13个token
export
default
(
start
:
ygopro
.
StocGameMessage
.
MsgStart
)
=>
{
export
default
(
start
:
ygopro
.
StocGameMessage
.
MsgStart
)
=>
{
matStore
.
selfType
=
start
.
playerType
;
matStore
.
selfType
=
start
.
playerType
;
...
@@ -31,90 +31,8 @@ export default (start: ygopro.StocGameMessage.MsgStart) => {
...
@@ -31,90 +31,8 @@ export default (start: ygopro.StocGameMessage.MsgStart) => {
extraSize
:
start
.
extraSize2
,
extraSize
:
start
.
extraSize2
,
});
});
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
));
for
(
let
i
=
0
;
i
<
start
.
deckSize1
;
i
++
)
{
matStore
.
decks
.
of
(
0
).
push
({
uuid
:
v4uuid
(),
occupant
:
{
id
:
0
,
data
:
{},
text
:
{},
},
location
:
{
controler
:
0
,
zone
:
ygopro
.
CardZone
.
DECK
,
},
focus
:
false
,
chaining
:
false
,
directAttack
:
false
,
counters
:
{},
idleInteractivities
:
[],
});
}
for
(
let
i
=
0
;
i
<
start
.
deckSize2
;
i
++
)
{
matStore
.
decks
.
of
(
1
).
push
({
uuid
:
v4uuid
(),
occupant
:
{
id
:
0
,
data
:
{},
text
:
{},
},
location
:
{
controler
:
1
,
zone
:
ygopro
.
CardZone
.
DECK
,
},
focus
:
false
,
chaining
:
false
,
directAttack
:
false
,
counters
:
{},
idleInteractivities
:
[],
});
}
// 初始化对手的额外卡组
for
(
let
i
=
0
;
i
<
start
.
extraSize2
;
i
++
)
{
matStore
.
extraDecks
.
op
.
push
({
uuid
:
v4uuid
(),
occupant
:
{
id
:
0
,
data
:
{},
text
:
{},
},
location
:
{
controler
:
opponent
,
zone
:
ygopro
.
CardZone
.
EXTRA
,
},
focus
:
false
,
chaining
:
false
,
directAttack
:
false
,
counters
:
{},
idleInteractivities
:
[],
});
}
// 在`WaitRoom`页面会设置自己的额外卡组,但那时候拿不到正确的`controller`值,因为不知道自己是先攻还是后手,因此这里需要重新为自己的额外卡组设置`controller`值
matStore
.
in
(
ygopro
.
CardZone
.
EXTRA
)
.
me
.
forEach
((
state
)
=>
(
state
.
location
.
controler
=
1
-
opponent
));
// 下面是cardStore的初始化
// 下面是cardStore的初始化
/** 自动从code推断出occupant */
const
genCard
=
(
o
:
CardType
)
=>
{
const
t
=
proxy
(
o
);
subscribeKey
(
t
,
"
code
"
,
async
(
code
)
=>
{
const
{
text
,
data
}
=
await
fetchCard
(
code
??
0
);
t
.
text
=
text
;
t
.
data
=
data
;
});
return
t
;
};
const
TOKEN_SIZE
=
13
;
// 每人场上最多就只可能有13个token
let
uuid
=
0
;
const
cards
=
flatten
(
const
cards
=
flatten
(
[
[
start
.
deckSize1
,
start
.
deckSize1
,
...
@@ -126,7 +44,7 @@ export default (start: ygopro.StocGameMessage.MsgStart) => {
...
@@ -126,7 +44,7 @@ export default (start: ygopro.StocGameMessage.MsgStart) => {
].
map
((
length
,
i
)
=>
].
map
((
length
,
i
)
=>
Array
.
from
({
length
}).
map
((
_
,
sequence
)
=>
Array
.
from
({
length
}).
map
((
_
,
sequence
)
=>
genCard
({
genCard
({
uuid
:
uuid
++
,
uuid
:
v4uuid
()
,
code
:
0
,
code
:
0
,
controller
:
i
<
3
?
1
-
opponent
:
opponent
,
// 前3个是自己的卡组,后3个是对手的卡组
controller
:
i
<
3
?
1
-
opponent
:
opponent
,
// 前3个是自己的卡组,后3个是对手的卡组
originController
:
i
<
3
?
1
-
opponent
:
opponent
,
originController
:
i
<
3
?
1
-
opponent
:
opponent
,
...
@@ -143,6 +61,9 @@ export default (start: ygopro.StocGameMessage.MsgStart) => {
...
@@ -143,6 +61,9 @@ export default (start: ygopro.StocGameMessage.MsgStart) => {
isToken
:
!
((
i
+
1
)
%
3
),
isToken
:
!
((
i
+
1
)
%
3
),
overlayMaterials
:
[],
overlayMaterials
:
[],
position
:
ygopro
.
CardPosition
.
FACEDOWN
,
position
:
ygopro
.
CardPosition
.
FACEDOWN
,
focus
:
false
,
chaining
:
false
,
directAttack
:
false
,
})
})
)
)
)
)
...
@@ -154,3 +75,14 @@ export default (start: ygopro.StocGameMessage.MsgStart) => {
...
@@ -154,3 +75,14 @@ export default (start: ygopro.StocGameMessage.MsgStart) => {
.
at
(
ygopro
.
CardZone
.
EXTRA
,
1
-
opponent
)
.
at
(
ygopro
.
CardZone
.
EXTRA
,
1
-
opponent
)
.
forEach
((
card
)
=>
(
card
.
code
=
myExtraDeckCodes
.
shift
()
!
));
.
forEach
((
card
)
=>
(
card
.
code
=
myExtraDeckCodes
.
shift
()
!
));
};
};
// 自动从code推断出occupant
const
genCard
=
(
o
:
CardType
)
=>
{
const
t
=
proxy
(
o
);
subscribeKey
(
t
,
"
code
"
,
async
(
code
)
=>
{
const
{
text
,
data
}
=
await
fetchCard
(
code
??
0
);
t
.
text
=
text
;
t
.
data
=
data
;
});
return
t
;
};
src/stores/cardStore.ts
View file @
3405b9d2
...
@@ -8,7 +8,7 @@ import type { Interactivity } from "./matStore/types";
...
@@ -8,7 +8,7 @@ import type { Interactivity } from "./matStore/types";
* 场上某位置的状态
* 场上某位置的状态
*/
*/
export
interface
CardType
{
export
interface
CardType
{
uuid
:
number
;
// 一张卡的唯一标识
uuid
:
string
;
// 一张卡的唯一标识
code
:
number
;
// 卡号
code
:
number
;
// 卡号
data
:
CardData
;
data
:
CardData
;
text
:
CardText
;
text
:
CardText
;
...
...
src/ui/WaitRoom.tsx
View file @
3405b9d2
...
@@ -22,17 +22,10 @@ import {
...
@@ -22,17 +22,10 @@ import {
import
React
,
{
useEffect
,
useState
}
from
"
react
"
;
import
React
,
{
useEffect
,
useState
}
from
"
react
"
;
import
{
useNavigate
,
useParams
}
from
"
react-router-dom
"
;
import
{
useNavigate
,
useParams
}
from
"
react-router-dom
"
;
import
rustInit
from
"
rust-src
"
;
import
rustInit
from
"
rust-src
"
;
import
{
v4
as
v4uuid
}
from
"
uuid
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
YGOProDeck
from
"
ygopro-deck-encode
"
;
import
YGOProDeck
from
"
ygopro-deck-encode
"
;
import
{
import
{
initStrings
,
sendHsReady
,
sendHsStart
,
sendUpdateDeck
}
from
"
@/api
"
;
initStrings
,
sendHsReady
,
sendHsStart
,
sendUpdateDeck
,
ygopro
,
}
from
"
@/api
"
;
import
{
DeckManager
,
fetchDeck
,
type
IDeck
}
from
"
@/api/deck
"
;
import
{
DeckManager
,
fetchDeck
,
type
IDeck
}
from
"
@/api/deck
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
socketMiddleWare
,
{
socketCmd
}
from
"
@/middleware/socket
"
;
import
socketMiddleWare
,
{
socketCmd
}
from
"
@/middleware/socket
"
;
...
@@ -144,12 +137,6 @@ const WaitRoom = () => {
...
@@ -144,12 +137,6 @@ const WaitRoom = () => {
const
onDeckReady
=
async
(
deck
:
IDeck
)
=>
{
const
onDeckReady
=
async
(
deck
:
IDeck
)
=>
{
sendUpdateDeck
(
deck
);
sendUpdateDeck
(
deck
);
store
.
matStore
.
extraDecks
.
me
.
add
(
(
deck
.
extra
?.
reverse
()
||
[]).
map
((
id
)
=>
{
return
{
uuid
:
v4uuid
(),
id
};
}),
ygopro
.
CardPosition
.
FACEDOWN_ATTACK
);
setChoseDeck
(
true
);
setChoseDeck
(
true
);
window
.
myExtraDeckCodes
=
deck
.
extra
;
window
.
myExtraDeckCodes
=
deck
.
extra
;
...
...
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