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
ab716aa8
Commit
ab716aa8
authored
Apr 24, 2023
by
timel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: valtio store logic 20%
parent
c61a4a16
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
194 additions
and
13 deletions
+194
-13
src/valtioStores/duelStore/index.ts
src/valtioStores/duelStore/index.ts
+2
-0
src/valtioStores/duelStore/modal.ts
src/valtioStores/duelStore/modal.ts
+34
-1
src/valtioStores/duelStore/playMat.ts
src/valtioStores/duelStore/playMat.ts
+30
-2
src/valtioStores/duelStore/types.ts
src/valtioStores/duelStore/types.ts
+128
-10
No files found.
src/valtioStores/duelStore/index.ts
View file @
ab716aa8
import
{
proxy
}
from
"
valtio
"
;
import
{
playMat
}
from
"
./playMat
"
;
import
{
modal
}
from
"
./modal
"
;
export
const
duelStore
=
proxy
({
playMat
,
modal
,
});
src/valtioStores/duelStore/modal.ts
View file @
ab716aa8
export
{};
import
{
proxy
}
from
"
valtio
"
;
import
type
{
ModalState
}
from
"
./types
"
;
export
const
modal
=
proxy
<
ModalState
>
({
cardModal
:
{
isOpen
:
false
,
interactivies
:
[],
counters
:
{}
},
cardListModal
:
{
isOpen
:
false
,
list
:
[]
},
checkCardModal
:
{
isOpen
:
false
,
cancelAble
:
false
,
tags
:
[]
},
yesNoModal
:
{
isOpen
:
false
},
positionModal
:
{
isOpen
:
false
,
positions
:
[]
},
optionModal
:
{
isOpen
:
false
,
options
:
[]
},
checkCardModalV2
:
{
isOpen
:
false
,
cancelAble
:
false
,
finishAble
:
false
,
responseable
:
false
,
selectableOptions
:
[],
selectedOptions
:
[],
},
checkCardModalV3
:
{
isOpen
:
false
,
overflow
:
false
,
allLevel
:
0
,
mustSelectList
:
[],
selectAbleList
:
[],
},
checkCounterModal
:
{
isOpen
:
false
,
options
:
[],
},
sortCardModal
:
{
isOpen
:
false
,
options
:
[],
},
});
src/valtioStores/duelStore/playMat.ts
View file @
ab716aa8
...
...
@@ -2,7 +2,7 @@ import { proxy } from "valtio";
import
{
ygopro
}
from
"
@/api/ocgcore/idl/ocgcore
"
;
import
type
{
Duel
State
}
from
"
./types
"
;
import
type
{
PlayMat
State
}
from
"
./types
"
;
/**
* 生成一个指定长度的卡片数组
...
...
@@ -21,7 +21,7 @@ function genDuelFieldState(location: ygopro.CardZone, n: number = 5) {
};
}
export
const
playMat
=
proxy
<
Duel
State
>
({
export
const
playMat
=
proxy
<
PlayMat
State
>
({
opMagics
:
genDuelFieldState
(
ygopro
.
CardZone
.
SZONE
),
meMagics
:
genDuelFieldState
(
ygopro
.
CardZone
.
SZONE
),
opMonsters
:
genDuelFieldState
(
ygopro
.
CardZone
.
MZONE
),
...
...
@@ -36,4 +36,32 @@ export const playMat = proxy<DuelState>({
meDeck
:
{
inner
:
[]
},
opExtraDeck
:
{
inner
:
[]
},
meExtraDeck
:
{
inner
:
[]
},
selfType
:
ygopro
.
StocTypeChange
.
SelfType
.
UNKNOWN
,
meInitInfo
:
{
masterRule
:
"
UNKNOWN
"
,
life
:
7999
,
// 特地设置一个不可能的值
deckSize
:
0
,
extraSize
:
0
,
},
opInitInfo
:
{
masterRule
:
""
,
life
:
7999
,
// 特地设置一个不可能的值
deckSize
:
0
,
extraSize
:
0
,
},
hint
:
{
code
:
-
1
,
},
currentPlayer
:
-
1
,
phase
:
{
currentPhase
:
"
UNKNOWN
"
,
// TODO 当前的阶段 应该改成enum
enableBp
:
false
,
// 允许进入战斗阶段
enableM2
:
false
,
// 允许进入M2阶段
enableEp
:
false
,
// 允许回合结束
},
result
:
ygopro
.
StocGameMessage
.
MsgWin
.
ActionType
.
UNKNOWN
,
waiting
:
false
,
unimplemented
:
0
,
});
src/valtioStores/duelStore/types.ts
View file @
ab716aa8
import
type
{
CardMeta
}
from
"
@/api/cards
"
;
import
type
{
ygopro
}
from
"
@/api/ocgcore/idl/ocgcore
"
;
export
interface
DuelState
{
selfType
?:
number
;
meInitInfo
?:
InitInfo
;
// 自己的初始状态
opInitInfo
?:
InitInfo
;
// 对手的初始状态
// >>> play mat state >>>
export
interface
PlayMatState
{
selfType
:
number
;
meInitInfo
:
InitInfo
;
// 自己的初始状态
opInitInfo
:
InitInfo
;
// 对手的初始状态
meHands
:
HandState
;
// 自己的手牌
opHands
:
HandState
;
// 对手的手牌
...
...
@@ -30,17 +31,17 @@ export interface DuelState {
meTimeLimit
?:
TimeLimit
;
// 自己的计时
opTimeLimit
?:
TimeLimit
;
// 对手的计时
hint
?
:
HintState
;
hint
:
HintState
;
currentPlayer
?
:
number
;
// 当前的操作方
currentPlayer
:
number
;
// 当前的操作方
phase
?
:
PhaseState
;
phase
:
PhaseState
;
result
?
:
ygopro
.
StocGameMessage
.
MsgWin
.
ActionType
;
result
:
ygopro
.
StocGameMessage
.
MsgWin
.
ActionType
;
waiting
?
:
boolean
;
waiting
:
boolean
;
unimplemented
?
:
number
;
// 未处理的`Message`
unimplemented
:
number
;
// 未处理的`Message`
}
export
interface
InitInfo
{
...
...
@@ -124,3 +125,120 @@ export interface PhaseState {
enableM2
:
boolean
;
// 允许进入M2阶段
enableEp
:
boolean
;
// 允许回合结束
}
// <<< play mat state <<<
// >>> modal types >>>
type
CardLocation
=
ReturnType
<
typeof
ygopro
.
CardLocation
.
prototype
.
toObject
>
;
export
interface
ModalState
{
// 卡牌弹窗
cardModal
:
{
isOpen
:
boolean
;
meta
?:
CardMeta
;
interactivies
:
{
desc
:
string
;
response
:
number
}[];
counters
:
{
[
type
:
number
]:
number
};
};
// 卡牌列表弹窗
cardListModal
:
{
isOpen
:
boolean
;
list
:
{
meta
?:
CardMeta
;
interactivies
:
{
desc
:
string
;
response
:
number
}[];
}[];
};
// 卡牌选择弹窗
checkCardModal
:
{
isOpen
:
boolean
;
onSubmit
?:
string
;
selectMin
?:
number
;
selectMax
?:
number
;
cancelAble
:
boolean
;
cancelResponse
?:
number
;
tags
:
{
tagName
:
string
;
options
:
{
meta
:
CardMeta
;
location
?:
CardLocation
;
effectDescCode
?:
number
;
effectDesc
?:
string
;
response
:
number
;
}[];
}[];
};
// Yes or No弹窗
yesNoModal
:
{
isOpen
:
boolean
;
msg
?:
string
;
};
// 表示形式选择弹窗
positionModal
:
{
isOpen
:
boolean
;
positions
:
ygopro
.
CardPosition
[];
};
// 选项选择弹窗
optionModal
:
{
isOpen
:
boolean
;
options
:
{
msg
:
string
;
response
:
number
}[];
};
// 卡牌选择弹窗V2
checkCardModalV2
:
{
isOpen
:
boolean
;
cancelAble
:
boolean
;
finishAble
:
boolean
;
selectMin
?:
number
;
selectMax
?:
number
;
responseable
?:
boolean
;
selectableOptions
:
{
code
:
number
;
name
?:
string
;
desc
?:
string
;
response
:
number
;
}[];
selectedOptions
:
{
code
:
number
;
name
?:
string
;
desc
?:
string
;
response
:
number
;
}[];
};
// 卡牌选择弹窗V3
checkCardModalV3
:
{
isOpen
:
boolean
;
overflow
:
boolean
;
allLevel
:
number
;
selectMin
?:
number
;
selectMax
?:
number
;
responseable
?:
boolean
;
mustSelectList
:
{
meta
:
CardMeta
;
level1
:
number
;
level2
:
number
;
response
:
number
;
}[];
selectAbleList
:
{
meta
:
CardMeta
;
level1
:
number
;
level2
:
number
;
response
:
number
;
}[];
};
// 指示器选择弹窗
checkCounterModal
:
{
isOpen
:
boolean
;
counterType
?:
number
;
min
?:
number
;
options
:
{
code
:
number
;
max
:
number
;
}[];
};
// 卡牌排序弹窗
sortCardModal
:
{
isOpen
:
boolean
;
options
:
{
meta
:
CardMeta
;
response
:
number
;
}[];
};
}
// <<< modal types <<<
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