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
c61a4a16
Commit
c61a4a16
authored
Apr 16, 2023
by
timel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: valtio store logic 15%
parent
39c16d26
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
34 deletions
+62
-34
src/valtioStores/duelStore/duel.ts
src/valtioStores/duelStore/duel.ts
+0
-19
src/valtioStores/duelStore/index.ts
src/valtioStores/duelStore/index.ts
+5
-0
src/valtioStores/duelStore/playMat.ts
src/valtioStores/duelStore/playMat.ts
+39
-0
src/valtioStores/duelStore/types.ts
src/valtioStores/duelStore/types.ts
+15
-15
src/valtioStores/index.tsx
src/valtioStores/index.tsx
+3
-0
No files found.
src/valtioStores/duelStore/duel.ts
deleted
100644 → 0
View file @
39c16d26
import
{
proxy
}
from
"
valtio
"
;
import
{
ygopro
}
from
"
@/api/ocgcore/idl/ocgcore
"
;
import
type
{
DuelState
}
from
"
./types
"
;
export
const
playMat
=
proxy
<
DuelState
>
({
opMagics
:
{
inner
:
Array
(
5
)
.
fill
(
null
)
.
map
((
_
,
i
)
=>
({
location
:
{
location
:
ygopro
.
CardZone
.
SZONE
,
},
idleInteractivities
:
[],
counters
:
{},
})),
},
});
src/valtioStores/duelStore/index.ts
View file @
c61a4a16
import
{
proxy
}
from
"
valtio
"
;
import
{
playMat
}
from
"
./playMat
"
;
export
const
duelStore
=
proxy
({
playMat
,
});
src/valtioStores/duelStore/playMat.ts
0 → 100644
View file @
c61a4a16
import
{
proxy
}
from
"
valtio
"
;
import
{
ygopro
}
from
"
@/api/ocgcore/idl/ocgcore
"
;
import
type
{
DuelState
}
from
"
./types
"
;
/**
* 生成一个指定长度的卡片数组
*/
function
genDuelFieldState
(
location
:
ygopro
.
CardZone
,
n
:
number
=
5
)
{
return
{
inner
:
Array
(
n
)
.
fill
(
null
)
.
map
((
_
)
=>
({
location
:
{
location
,
},
idleInteractivities
:
[],
counters
:
{},
})),
};
}
export
const
playMat
=
proxy
<
DuelState
>
({
opMagics
:
genDuelFieldState
(
ygopro
.
CardZone
.
SZONE
),
meMagics
:
genDuelFieldState
(
ygopro
.
CardZone
.
SZONE
),
opMonsters
:
genDuelFieldState
(
ygopro
.
CardZone
.
MZONE
),
meMonsters
:
genDuelFieldState
(
ygopro
.
CardZone
.
MZONE
),
opGraveyard
:
{
inner
:
[]
},
meGraveyard
:
{
inner
:
[]
},
opBanishedZone
:
{
inner
:
[]
},
meBanishedZone
:
{
inner
:
[]
},
opHands
:
{
inner
:
[]
},
meHands
:
{
inner
:
[]
},
opDeck
:
{
inner
:
[]
},
meDeck
:
{
inner
:
[]
},
opExtraDeck
:
{
inner
:
[]
},
meExtraDeck
:
{
inner
:
[]
},
});
src/valtioStores/duelStore/types.ts
View file @
c61a4a16
...
...
@@ -6,26 +6,26 @@ export interface DuelState {
meInitInfo
?:
InitInfo
;
// 自己的初始状态
opInitInfo
?:
InitInfo
;
// 对手的初始状态
meHands
?
:
HandState
;
// 自己的手牌
opHands
?
:
HandState
;
// 对手的手牌
meHands
:
HandState
;
// 自己的手牌
opHands
:
HandState
;
// 对手的手牌
meMonsters
?
:
MonsterState
;
// 自己的怪兽区状态
opMonsters
?
:
MonsterState
;
// 对手的怪兽区状态
meMonsters
:
MonsterState
;
// 自己的怪兽区状态
opMonsters
:
MonsterState
;
// 对手的怪兽区状态
meMagics
?
:
MagicState
;
// 自己的魔法陷阱区状态
opMagics
?
:
MagicState
;
// 对手的魔法陷阱区状态
meMagics
:
MagicState
;
// 自己的魔法陷阱区状态
opMagics
:
MagicState
;
// 对手的魔法陷阱区状态
meGraveyard
?
:
GraveyardState
;
// 自己的墓地状态
opGraveyard
?
:
GraveyardState
;
// 对手的墓地状态
meGraveyard
:
GraveyardState
;
// 自己的墓地状态
opGraveyard
:
GraveyardState
;
// 对手的墓地状态
meBanishedZone
?
:
BanishedZoneState
;
// 自己的除外区状态
opBanishedZone
?
:
BanishedZoneState
;
// 对手的除外区状态
meBanishedZone
:
BanishedZoneState
;
// 自己的除外区状态
opBanishedZone
:
BanishedZoneState
;
// 对手的除外区状态
meDeck
?
:
DeckState
;
// 自己的卡组状态
opDeck
?
:
DeckState
;
// 对手的卡组状态
meDeck
:
DeckState
;
// 自己的卡组状态
opDeck
:
DeckState
;
// 对手的卡组状态
meExtraDeck
?
:
ExtraDeckState
;
// 自己的额外卡组状态
opExtraDeck
?
:
ExtraDeckState
;
// 对手的额外卡组状态
meExtraDeck
:
ExtraDeckState
;
// 自己的额外卡组状态
opExtraDeck
:
ExtraDeckState
;
// 对手的额外卡组状态
meTimeLimit
?:
TimeLimit
;
// 自己的计时
opTimeLimit
?:
TimeLimit
;
// 对手的计时
...
...
@@ -54,7 +54,7 @@ export interface CardState {
occupant
?:
CardMeta
;
// 占据此位置的卡牌元信息
location
:
{
controler
?:
number
;
location
?:
number
;
location
:
ygopro
.
CardZone
;
position
?:
ygopro
.
CardPosition
;
overlay_sequence
?:
number
;
};
// 位置信息
...
...
src/valtioStores/index.tsx
View file @
c61a4a16
...
...
@@ -2,6 +2,7 @@ export * from "./chatStore";
export
*
from
"
./joinStore
"
;
export
*
from
"
./moraStore
"
;
export
*
from
"
./playerStore
"
;
export
*
from
"
./duelStore
"
;
import
{
createContext
,
type
ReactNode
,
useRef
}
from
"
react
"
;
import
{
proxy
}
from
"
valtio
"
;
...
...
@@ -11,12 +12,14 @@ import { chatStore } from "./chatStore";
import
{
joinStore
}
from
"
./joinStore
"
;
import
{
moraStore
}
from
"
./moraStore
"
;
import
{
playerStore
}
from
"
./playerStore
"
;
import
{
duelStore
}
from
"
./duelStore
"
;
export
const
valtioStore
=
proxy
({
playerStore
,
chatStore
,
joinStore
,
moraStore
,
duelStore
,
});
devtools
(
valtioStore
,
{
name
:
"
valtio store
"
,
enabled
:
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