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
36cd55cd
Commit
36cd55cd
authored
Apr 19, 2023
by
timel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add hint
parent
c74ffee8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
76 additions
and
10 deletions
+76
-10
src/middleware/sqlite.ts
src/middleware/sqlite.ts
+4
-1
src/service/duel/draw.ts
src/service/duel/draw.ts
+2
-2
src/service/duel/move.ts
src/service/duel/move.ts
+1
-1
src/service/duel/start.ts
src/service/duel/start.ts
+1
-1
src/valtioStores/matStore/index.ts
src/valtioStores/matStore/index.ts
+45
-4
src/valtioStores/matStore/types.ts
src/valtioStores/matStore/types.ts
+23
-1
No files found.
src/middleware/sqlite.ts
View file @
36cd55cd
...
@@ -75,7 +75,10 @@ export default async function (action: sqliteAction): Promise<sqliteResult> {
...
@@ -75,7 +75,10 @@ export default async function (action: sqliteAction): Promise<sqliteResult> {
selectResult
:
constructCardMeta
(
code
,
dataResult
,
textResult
),
selectResult
:
constructCardMeta
(
code
,
dataResult
,
textResult
),
};
};
}
else
{
}
else
{
console
.
warn
(
"
ygo db not init or id not provied!
"
);
if
(
action
.
payload
?.
id
!==
0
)
{
// 0是无效的卡片ID,不需要报错,返回空即可
console
.
warn
(
"
ygo db not init or id not provied!
"
);
}
}
}
return
{};
return
{};
...
...
src/service/duel/draw.ts
View file @
36cd55cd
...
@@ -4,6 +4,8 @@ import { fetchEsHintMeta } from "@/reducers/duel/hintSlice";
...
@@ -4,6 +4,8 @@ import { fetchEsHintMeta } from "@/reducers/duel/hintSlice";
import
{
AppDispatch
}
from
"
@/store
"
;
import
{
AppDispatch
}
from
"
@/store
"
;
import
{
valtioStore
}
from
"
@/valtioStores
"
;
import
{
valtioStore
}
from
"
@/valtioStores
"
;
const
{
matStore
}
=
valtioStore
;
export
default
(
export
default
(
draw
:
ygopro
.
StocGameMessage
.
MsgDraw
,
draw
:
ygopro
.
StocGameMessage
.
MsgDraw
,
dispatch
:
AppDispatch
dispatch
:
AppDispatch
...
@@ -11,7 +13,5 @@ export default (
...
@@ -11,7 +13,5 @@ export default (
dispatch
(
fetchEsHintMeta
({
originMsg
:
"
玩家抽卡时
"
}));
dispatch
(
fetchEsHintMeta
({
originMsg
:
"
玩家抽卡时
"
}));
dispatch
(
fetchHandsMeta
({
controler
:
draw
.
player
,
codes
:
draw
.
cards
}));
dispatch
(
fetchHandsMeta
({
controler
:
draw
.
player
,
codes
:
draw
.
cards
}));
const
matStore
=
valtioStore
.
matStore
;
matStore
.
hands
.
add
(
draw
.
player
,
draw
.
cards
);
matStore
.
hands
.
add
(
draw
.
player
,
draw
.
cards
);
};
};
src/service/duel/move.ts
View file @
36cd55cd
...
@@ -23,7 +23,7 @@ import { valtioStore } from "@/valtioStores";
...
@@ -23,7 +23,7 @@ import { valtioStore } from "@/valtioStores";
import
{
REASON_MATERIAL
}
from
"
../../common
"
;
import
{
REASON_MATERIAL
}
from
"
../../common
"
;
const
matStore
=
valtioStore
.
mat
Store
;
const
{
matStore
}
=
valtio
Store
;
const
OVERLAY_STACK
:
{
code
:
number
;
sequence
:
number
}[]
=
[];
const
OVERLAY_STACK
:
{
code
:
number
;
sequence
:
number
}[]
=
[];
...
...
src/service/duel/start.ts
View file @
36cd55cd
...
@@ -12,7 +12,7 @@ import {
...
@@ -12,7 +12,7 @@ import {
import
{
AppDispatch
}
from
"
@/store
"
;
import
{
AppDispatch
}
from
"
@/store
"
;
import
{
valtioStore
}
from
"
@/valtioStores
"
;
import
{
valtioStore
}
from
"
@/valtioStores
"
;
const
matStore
=
valtioStore
.
mat
Store
;
const
{
matStore
}
=
valtio
Store
;
export
default
(
export
default
(
start
:
ygopro
.
StocGameMessage
.
MsgStart
,
start
:
ygopro
.
StocGameMessage
.
MsgStart
,
...
...
src/valtioStores/matStore/index.ts
View file @
36cd55cd
...
@@ -10,6 +10,7 @@ import type {
...
@@ -10,6 +10,7 @@ import type {
InitInfo
,
InitInfo
,
PlayMatState
,
PlayMatState
,
}
from
"
./types
"
;
}
from
"
./types
"
;
import
{
DESCRIPTION_LIMIT
,
fetchStrings
,
getStrings
}
from
"
@/api/strings
"
;
/**
/**
* 生成一个指定长度的卡片数组
* 生成一个指定长度的卡片数组
...
@@ -61,6 +62,48 @@ const initInfo: PlayMatState["initInfo"] = proxy({
...
@@ -61,6 +62,48 @@ const initInfo: PlayMatState["initInfo"] = proxy({
},
},
});
});
const
hint
:
PlayMatState
[
"
hint
"
]
=
proxy
({
code
:
-
1
,
fetchCommonHintMeta
:
(
hintData
:
number
)
=>
{
return
fetchStrings
(
"
!system
"
,
hintData
);
},
fetchSelectHintMeta
:
async
(
selectHintData
:
number
,
esHint
?:
string
)
=>
{
let
selectHintMeta
=
""
;
if
(
selectHintData
>
DESCRIPTION_LIMIT
)
{
// 针对`MSG_SELECT_PLACE`的特化逻辑
const
cardMeta
=
await
fetchCard
(
selectHintData
,
true
);
selectHintMeta
=
fetchStrings
(
"
!system
"
,
569
).
replace
(
"
[%ls]
"
,
cardMeta
.
text
.
name
||
"
[?]
"
);
}
else
{
selectHintMeta
=
await
getStrings
(
selectHintData
);
}
return
{
selectHintMeta
,
esHint
,
};
},
fetchEsHintMeta
:
async
(
_originMsg
:
string
|
number
,
location
?:
ygopro
.
CardLocation
,
cardID
?:
number
)
=>
{
const
originMsg
=
typeof
_originMsg
===
"
string
"
?
_originMsg
:
fetchStrings
(
"
!system
"
,
_originMsg
);
if
(
cardID
)
{
const
cardMeta
=
await
fetchCard
(
cardID
);
return
{
originMsg
,
cardMeta
,
location
};
}
else
{
return
{
originMsg
,
location
};
}
},
});
/**
/**
* 在决斗盘仓库之中,
* 在决斗盘仓库之中,
* 给 `{me: [...], op: [...]}` 这种类型的对象添加一些方法。
* 给 `{me: [...], op: [...]}` 这种类型的对象添加一些方法。
...
@@ -144,9 +187,7 @@ export const matStore = proxy<PlayMatState>({
...
@@ -144,9 +187,7 @@ export const matStore = proxy<PlayMatState>({
initInfo
,
initInfo
,
selfType
:
ygopro
.
StocTypeChange
.
SelfType
.
UNKNOWN
,
selfType
:
ygopro
.
StocTypeChange
.
SelfType
.
UNKNOWN
,
hint
:
{
hint
,
code
:
-
1
,
},
currentPlayer
:
-
1
,
currentPlayer
:
-
1
,
phase
:
{
phase
:
{
currentPhase
:
"
UNKNOWN
"
,
// TODO 当前的阶段 应该改成enum
currentPhase
:
"
UNKNOWN
"
,
// TODO 当前的阶段 应该改成enum
...
@@ -166,7 +207,7 @@ export const matStore = proxy<PlayMatState>({
...
@@ -166,7 +207,7 @@ export const matStore = proxy<PlayMatState>({
const
getWhom
=
(
controller
:
number
)
=>
const
getWhom
=
(
controller
:
number
)
=>
judgeSelf
(
controller
,
matStore
.
selfType
)
?
"
me
"
:
"
op
"
;
judgeSelf
(
controller
,
matStore
.
selfType
)
?
"
me
"
:
"
op
"
;
export
function
judgeSelf
(
player
:
number
,
selfType
:
number
):
boolean
{
function
judgeSelf
(
player
:
number
,
selfType
:
number
):
boolean
{
switch
(
selfType
)
{
switch
(
selfType
)
{
case
1
:
case
1
:
// 自己是先攻
// 自己是先攻
...
...
src/valtioStores/matStore/types.ts
View file @
36cd55cd
...
@@ -44,7 +44,7 @@ export interface PlayMatState {
...
@@ -44,7 +44,7 @@ export interface PlayMatState {
timeLimits
:
BothSide
<
number
>
;
// 双方的时间限制
timeLimits
:
BothSide
<
number
>
;
// 双方的时间限制
hint
:
HintState
;
hint
:
HintState
&
HintMethods
;
currentPlayer
:
number
;
// 当前的操作方
currentPlayer
:
number
;
// 当前的操作方
...
@@ -132,12 +132,34 @@ export interface ExtraDeckState extends DuelFieldState {}
...
@@ -132,12 +132,34 @@ export interface ExtraDeckState extends DuelFieldState {}
export
interface
TimeLimit
{
export
interface
TimeLimit
{
leftTime
:
number
;
leftTime
:
number
;
}
}
export
interface
HintState
{
export
interface
HintState
{
code
:
number
;
code
:
number
;
msg
?:
string
;
msg
?:
string
;
esHint
?:
string
;
esHint
?:
string
;
esSelectHint
?:
string
;
esSelectHint
?:
string
;
}
}
// 和hint相关的方法
export
interface
HintMethods
{
fetchCommonHintMeta
:
(
hintData
:
number
)
=>
string
;
fetchSelectHintMeta
:
(
selectHintData
:
number
,
esHint
?:
string
)
=>
Promise
<
{
selectHintMeta
:
string
;
esHint
?:
string
;
}
>
;
fetchEsHintMeta
:
(
originMsg
:
string
|
number
,
location
?:
ygopro
.
CardLocation
,
cardID
?:
number
)
=>
Promise
<
{
originMsg
:
string
;
cardMeta
?:
CardMeta
;
location
?:
ygopro
.
CardLocation
;
}
>
;
}
export
interface
PhaseState
{
export
interface
PhaseState
{
currentPhase
:
string
;
// TODO 当前的阶段 应该改成enum
currentPhase
:
string
;
// TODO 当前的阶段 应该改成enum
enableBp
:
boolean
;
// 允许进入战斗阶段
enableBp
:
boolean
;
// 允许进入战斗阶段
...
...
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