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
485fdcc8
Commit
485fdcc8
authored
Apr 18, 2023
by
timel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style: add comments and rename
parent
fdecfd97
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
12 deletions
+49
-12
src/valtioStores/duelStore/playMat.ts
src/valtioStores/duelStore/playMat.ts
+17
-7
src/valtioStores/duelStore/types.ts
src/valtioStores/duelStore/types.ts
+5
-5
src/valtioStores/duelStore/utils/genBlock.ts
src/valtioStores/duelStore/utils/genBlock.ts
+26
-0
src/valtioStores/duelStore/utils/index.ts
src/valtioStores/duelStore/utils/index.ts
+1
-0
No files found.
src/valtioStores/duelStore/playMat.ts
View file @
485fdcc8
...
@@ -58,7 +58,8 @@ const initInfo: PlayMatState["initInfo"] = proxy({
...
@@ -58,7 +58,8 @@ const initInfo: PlayMatState["initInfo"] = proxy({
});
});
/**
/**
* 给 `{me: [...], op: [...]}` 这种类型的对象添加一些方法
* 在决斗盘仓库之中,
* 给 `{me: [...], op: [...]}` 这种类型的对象添加一些方法
*/
*/
const
wrap
=
<
T
extends
DuelFieldState
>
(
const
wrap
=
<
T
extends
DuelFieldState
>
(
entity
:
BothSide
<
T
>
,
entity
:
BothSide
<
T
>
,
...
@@ -100,21 +101,27 @@ const wrap = <T extends DuelFieldState>(
...
@@ -100,21 +101,27 @@ const wrap = <T extends DuelFieldState>(
return
res
;
return
res
;
};
};
/**
* 🔥 决斗盘状态仓库,本文件核心,
* 具体介绍可以点进`PlayMatState`去看
*/
export
const
playMat
=
proxy
<
PlayMatState
>
({
export
const
playMat
=
proxy
<
PlayMatState
>
({
magics
:
wrap
(
genBlock
(
ygopro
.
CardZone
.
SZONE
),
ygopro
.
CardZone
.
SZONE
),
magics
:
wrap
(
genBlock
(
ygopro
.
CardZone
.
SZONE
),
ygopro
.
CardZone
.
SZONE
),
monsters
:
wrap
(
genBlock
(
ygopro
.
CardZone
.
MZONE
),
ygopro
.
CardZone
.
MZONE
),
monsters
:
wrap
(
genBlock
(
ygopro
.
CardZone
.
MZONE
),
ygopro
.
CardZone
.
MZONE
),
graveyard
:
wrap
({
me
:
[],
op
:
[]
},
ygopro
.
CardZone
.
GRAVE
),
graveyard
s
:
wrap
({
me
:
[],
op
:
[]
},
ygopro
.
CardZone
.
GRAVE
),
banishedZone
:
wrap
({
me
:
[],
op
:
[]
},
ygopro
.
CardZone
.
REMOVED
),
banishedZone
s
:
wrap
({
me
:
[],
op
:
[]
},
ygopro
.
CardZone
.
REMOVED
),
hands
:
wrap
({
me
:
[],
op
:
[]
},
ygopro
.
CardZone
.
HAND
),
hands
:
wrap
({
me
:
[],
op
:
[]
},
ygopro
.
CardZone
.
HAND
),
deck
:
wrap
({
me
:
[],
op
:
[]
},
ygopro
.
CardZone
.
DECK
),
deck
s
:
wrap
({
me
:
[],
op
:
[]
},
ygopro
.
CardZone
.
DECK
),
extraDeck
:
wrap
({
me
:
[],
op
:
[]
},
ygopro
.
CardZone
.
EXTRA
),
extraDeck
s
:
wrap
({
me
:
[],
op
:
[]
},
ygopro
.
CardZone
.
EXTRA
),
initInfo
,
timeLimits
:
{
timeLimit
:
{
// 时间限制
me
:
0
,
me
:
0
,
op
:
0
,
op
:
0
,
},
},
initInfo
,
selfType
:
ygopro
.
StocTypeChange
.
SelfType
.
UNKNOWN
,
selfType
:
ygopro
.
StocTypeChange
.
SelfType
.
UNKNOWN
,
hint
:
{
hint
:
{
code
:
-
1
,
code
:
-
1
,
...
@@ -131,6 +138,9 @@ export const playMat = proxy<PlayMatState>({
...
@@ -131,6 +138,9 @@ export const playMat = proxy<PlayMatState>({
unimplemented
:
0
,
unimplemented
:
0
,
});
});
/**
* 根据controller判断是自己还是对方
*/
const
getWhom
=
(
controller
:
number
)
=>
const
getWhom
=
(
controller
:
number
)
=>
judgeSelf
(
controller
,
playMat
.
selfType
)
?
"
me
"
:
"
op
"
;
judgeSelf
(
controller
,
playMat
.
selfType
)
?
"
me
"
:
"
op
"
;
...
...
src/valtioStores/duelStore/types.ts
View file @
485fdcc8
...
@@ -27,15 +27,15 @@ export interface PlayMatState {
...
@@ -27,15 +27,15 @@ export interface PlayMatState {
magics
:
CardsBothSide
<
MagicState
>
;
// 双方的魔法区状态
magics
:
CardsBothSide
<
MagicState
>
;
// 双方的魔法区状态
graveyard
:
CardsBothSide
<
GraveyardState
>
;
// 双方的墓地状态
graveyard
s
:
CardsBothSide
<
GraveyardState
>
;
// 双方的墓地状态
banishedZone
:
CardsBothSide
<
BanishedZoneState
>
;
// 双方的除外区状态
banishedZone
s
:
CardsBothSide
<
BanishedZoneState
>
;
// 双方的除外区状态
deck
:
CardsBothSide
<
DeckState
>
;
// 双方的卡组状态
deck
s
:
CardsBothSide
<
DeckState
>
;
// 双方的卡组状态
extraDeck
:
CardsBothSide
<
ExtraDeckState
>
;
// 双方的额外卡组状态
extraDeck
s
:
CardsBothSide
<
ExtraDeckState
>
;
// 双方的额外卡组状态
timeLimit
:
BothSide
<
number
>
;
// 双方的时间限制
timeLimit
s
:
BothSide
<
number
>
;
// 双方的时间限制
hint
:
HintState
;
hint
:
HintState
;
...
...
src/valtioStores/duelStore/utils/genBlock.ts
0 → 100644
View file @
485fdcc8
import
{
ygopro
}
from
"
@/api/ocgcore/idl/ocgcore
"
;
/**
* 生成一个指定长度的卡片数组
*/
function
genBlock
(
location
:
ygopro
.
CardZone
,
n
:
number
=
5
)
{
return
{
me
:
Array
(
n
)
.
fill
(
null
)
.
map
((
_
)
=>
({
location
:
{
location
,
},
idleInteractivities
:
[],
counters
:
{},
})),
op
:
Array
(
n
)
.
fill
(
null
)
.
map
((
_
)
=>
({
location
:
{
location
,
},
idleInteractivities
:
[],
counters
:
{},
})),
};
}
src/valtioStores/duelStore/utils/index.ts
0 → 100644
View file @
485fdcc8
export
*
from
"
./genBlock
"
;
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