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
68184e77
Commit
68184e77
authored
Apr 02, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
d8c00bb9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
29 deletions
+56
-29
src/reducers/duel/modal/checkCardModalSlice.ts
src/reducers/duel/modal/checkCardModalSlice.ts
+27
-19
src/reducers/duel/modal/mod.ts
src/reducers/duel/modal/mod.ts
+4
-3
src/reducers/duel/util.ts
src/reducers/duel/util.ts
+21
-3
src/ui/Duel/checkCardModal.tsx
src/ui/Duel/checkCardModal.tsx
+4
-4
No files found.
src/reducers/duel/modal/checkCardModalSlice.ts
View file @
68184e77
...
@@ -6,7 +6,7 @@ import {
...
@@ -6,7 +6,7 @@ import {
}
from
"
@reduxjs/toolkit
"
;
}
from
"
@reduxjs/toolkit
"
;
import
{
RootState
}
from
"
../../../store
"
;
import
{
RootState
}
from
"
../../../store
"
;
import
{
DuelState
}
from
"
../mod
"
;
import
{
DuelState
}
from
"
../mod
"
;
import
{
findCardByLocation
,
judgeSelf
}
from
"
../util
"
;
import
{
cmpCardLocation
,
findCardByLocation
,
judgeSelf
}
from
"
../util
"
;
import
{
fetchCard
,
getCardStr
}
from
"
../../../api/cards
"
;
import
{
fetchCard
,
getCardStr
}
from
"
../../../api/cards
"
;
import
{
ygopro
}
from
"
../../../api/ocgcore/idl/ocgcore
"
;
import
{
ygopro
}
from
"
../../../api/ocgcore/idl/ocgcore
"
;
...
@@ -65,17 +65,11 @@ export const fetchCheckCardMeta = createAsyncThunk(
...
@@ -65,17 +65,11 @@ export const fetchCheckCardMeta = createAsyncThunk(
})
=>
{
})
=>
{
// FIXME: 这里如果传的`controler`如果是对手,对应的`code`会为零,这时候就无法更新对应的`Meta`信息了,后续需要修复。`fetchCheckCardMetaV2`和`fetchCheckCardMetaV3`同理
// FIXME: 这里如果传的`controler`如果是对手,对应的`code`会为零,这时候就无法更新对应的`Meta`信息了,后续需要修复。`fetchCheckCardMetaV2`和`fetchCheckCardMetaV3`同理
const
meta
=
await
fetchCard
(
param
.
option
.
code
,
true
);
const
meta
=
await
fetchCard
(
param
.
option
.
code
,
true
);
const
effectDesc
=
param
.
option
.
effectDescCode
?
getCardStr
(
meta
,
param
.
option
.
effectDescCode
&
0xf
)
:
undefined
;
const
response
=
{
const
response
=
{
controler
:
param
.
option
.
location
.
controler
,
tagName
:
param
.
tagName
,
tagName
:
param
.
tagName
,
meta
:
{
option
:
{
code
:
meta
.
id
,
meta
,
name
:
meta
.
text
.
name
,
location
:
param
.
option
.
location
.
toObject
(),
desc
:
meta
.
text
.
desc
,
effectDesc
,
},
},
};
};
...
@@ -91,6 +85,7 @@ export const checkCardModalCase = (
...
@@ -91,6 +85,7 @@ export const checkCardModalCase = (
const
code
=
action
.
meta
.
arg
.
option
.
code
;
const
code
=
action
.
meta
.
arg
.
option
.
code
;
const
location
=
action
.
meta
.
arg
.
option
.
location
;
const
location
=
action
.
meta
.
arg
.
option
.
location
;
const
controler
=
location
.
controler
;
const
controler
=
location
.
controler
;
const
effectDescCode
=
action
.
meta
.
arg
.
option
.
effectDescCode
;
const
response
=
action
.
meta
.
arg
.
option
.
response
;
const
response
=
action
.
meta
.
arg
.
option
.
response
;
const
combinedTagName
=
judgeSelf
(
controler
,
state
)
const
combinedTagName
=
judgeSelf
(
controler
,
state
)
...
@@ -101,23 +96,29 @@ export const checkCardModalCase = (
...
@@ -101,23 +96,29 @@ export const checkCardModalCase = (
code
!=
0
?
code
:
findCardByLocation
(
state
,
location
)?.
occupant
?.
id
||
0
;
code
!=
0
?
code
:
findCardByLocation
(
state
,
location
)?.
occupant
?.
id
||
0
;
if
(
newID
)
{
if
(
newID
)
{
const
newOption
=
{
meta
:
{
id
:
code
,
data
:
{},
text
:
{}
},
location
:
location
.
toObject
(),
effectDescCode
,
response
,
};
for
(
const
tag
of
state
.
modalState
.
checkCardModal
.
tags
)
{
for
(
const
tag
of
state
.
modalState
.
checkCardModal
.
tags
)
{
if
(
tag
.
tagName
===
combinedTagName
)
{
if
(
tag
.
tagName
===
combinedTagName
)
{
tag
.
options
.
push
(
{
code
:
newID
,
response
}
);
tag
.
options
.
push
(
newOption
);
return
;
return
;
}
}
}
}
state
.
modalState
.
checkCardModal
.
tags
.
push
({
state
.
modalState
.
checkCardModal
.
tags
.
push
({
tagName
:
combinedTagName
,
tagName
:
combinedTagName
,
options
:
[
{
code
:
newID
,
response
}
],
options
:
[
newOption
],
});
});
}
}
});
});
builder
.
addCase
(
fetchCheckCardMeta
.
fulfilled
,
(
state
,
action
)
=>
{
builder
.
addCase
(
fetchCheckCardMeta
.
fulfilled
,
(
state
,
action
)
=>
{
const
controler
=
action
.
payload
.
controler
;
const
tagName
=
action
.
payload
.
tagName
;
const
tagName
=
action
.
payload
.
tagName
;
const
meta
=
action
.
payload
.
meta
;
const
option
=
action
.
payload
.
option
;
const
controler
=
option
.
location
.
controler
!
;
const
combinedTagName
=
judgeSelf
(
controler
,
state
)
const
combinedTagName
=
judgeSelf
(
controler
,
state
)
?
`我方的
${
tagName
}
`
?
`我方的
${
tagName
}
`
...
@@ -125,11 +126,18 @@ export const checkCardModalCase = (
...
@@ -125,11 +126,18 @@ export const checkCardModalCase = (
for
(
const
tag
of
state
.
modalState
.
checkCardModal
.
tags
)
{
for
(
const
tag
of
state
.
modalState
.
checkCardModal
.
tags
)
{
if
(
tag
.
tagName
===
combinedTagName
)
{
if
(
tag
.
tagName
===
combinedTagName
)
{
for
(
const
option
of
tag
.
options
)
{
for
(
const
old
of
tag
.
options
)
{
if
(
option
.
code
==
meta
.
code
)
{
if
(
option
.
name
=
meta
.
name
;
option
.
meta
.
id
==
old
.
meta
.
id
&&
option
.
desc
=
meta
.
desc
;
cmpCardLocation
(
option
.
location
,
old
.
location
)
option
.
effectDesc
=
meta
.
effectDesc
;
)
{
old
.
meta
=
option
.
meta
;
const
effectDescCode
=
old
.
effectDescCode
;
const
effectDesc
=
effectDescCode
?
getCardStr
(
old
.
meta
,
effectDescCode
&
0xf
)
:
undefined
;
old
.
effectDesc
=
effectDesc
;
}
}
}
}
}
}
...
...
src/reducers/duel/modal/mod.ts
View file @
68184e77
import
{
CardMeta
}
from
"
../../../api/cards
"
;
import
{
CardMeta
}
from
"
../../../api/cards
"
;
import
{
ygopro
}
from
"
../../../api/ocgcore/idl/ocgcore
"
;
import
{
ygopro
}
from
"
../../../api/ocgcore/idl/ocgcore
"
;
type
CardLocation
=
ReturnType
<
typeof
ygopro
.
CardLocation
.
prototype
.
toObject
>
;
export
interface
ModalState
{
export
interface
ModalState
{
// 卡牌弹窗
// 卡牌弹窗
...
@@ -28,9 +29,9 @@ export interface ModalState {
...
@@ -28,9 +29,9 @@ export interface ModalState {
tags
:
{
tags
:
{
tagName
:
string
;
tagName
:
string
;
options
:
{
options
:
{
code
:
number
;
meta
:
CardMeta
;
name
?:
string
;
location
?:
CardLocation
;
desc
?:
string
;
effectDescCode
?:
number
;
effectDesc
?:
string
;
effectDesc
?:
string
;
response
:
number
;
response
:
number
;
}[];
}[];
...
...
src/reducers/duel/util.ts
View file @
68184e77
...
@@ -8,6 +8,10 @@ import { Draft } from "@reduxjs/toolkit";
...
@@ -8,6 +8,10 @@ import { Draft } from "@reduxjs/toolkit";
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
CardState
}
from
"
./generic
"
;
import
{
CardState
}
from
"
./generic
"
;
type
Location
=
|
ygopro
.
CardLocation
|
ReturnType
<
typeof
ygopro
.
CardLocation
.
prototype
.
toObject
>
;
/*
/*
* 通过`player`和`selfType`判断是应该处理自己还是对手
* 通过`player`和`selfType`判断是应该处理自己还是对手
* */
* */
...
@@ -29,9 +33,7 @@ export function judgeSelf(player: number, state: Draft<DuelState>): boolean {
...
@@ -29,9 +33,7 @@ export function judgeSelf(player: number, state: Draft<DuelState>): boolean {
* 通过`controler`,`zone`和`sequence`获取卡牌状态*/
* 通过`controler`,`zone`和`sequence`获取卡牌状态*/
export
function
findCardByLocation
(
export
function
findCardByLocation
(
state
:
Draft
<
DuelState
>
,
state
:
Draft
<
DuelState
>
,
location
:
location
:
Location
|
ygopro
.
CardLocation
|
ReturnType
<
typeof
ygopro
.
CardLocation
.
prototype
.
toObject
>
):
CardState
|
undefined
{
):
CardState
|
undefined
{
const
controler
=
location
.
controler
!
;
const
controler
=
location
.
controler
!
;
const
zone
=
location
.
location
;
const
zone
=
location
.
location
;
...
@@ -73,3 +75,19 @@ export function findCardByLocation(
...
@@ -73,3 +75,19 @@ export function findCardByLocation(
}
}
}
}
}
}
export
function
cmpCardLocation
(
left
:
Location
,
right
?:
Location
,
strict
?:
boolean
):
boolean
{
if
(
strict
)
{
return
JSON
.
stringify
(
left
)
===
JSON
.
stringify
(
right
);
}
else
{
return
(
left
.
controler
===
right
?.
controler
&&
left
.
location
===
right
?.
location
&&
left
.
sequence
===
right
?.
sequence
);
}
}
src/ui/Duel/checkCardModal.tsx
View file @
68184e77
...
@@ -111,13 +111,13 @@ const CheckCardModal = () => {
...
@@ -111,13 +111,13 @@ const CheckCardModal = () => {
<
Col
span=
{
4
}
key=
{
idx
}
>
<
Col
span=
{
4
}
key=
{
idx
}
>
<
HoverCheckCard
<
HoverCheckCard
hoverContent=
{
option
.
effectDesc
}
hoverContent=
{
option
.
effectDesc
}
title=
{
option
.
name
}
title=
{
option
.
meta
.
text
.
name
}
description=
{
option
.
desc
}
description=
{
option
.
meta
.
text
.
desc
}
style=
{
{
width
:
120
}
}
style=
{
{
width
:
120
}
}
cover=
{
cover=
{
<
img
<
img
alt=
{
option
.
code
.
toString
()
}
alt=
{
option
.
meta
.
id
.
toString
()
}
src=
{
`${NeosConfig.cardImgUrl}/${option.
code
}.jpg`
}
src=
{
`${NeosConfig.cardImgUrl}/${option.
meta.id
}.jpg`
}
style=
{
{
width
:
100
}
}
style=
{
{
width
:
100
}
}
/>
/>
}
}
...
...
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