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
76900895
Commit
76900895
authored
Mar 06, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix parse deck
parent
3da84301
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
59 deletions
+12
-59
src/api/deck.ts
src/api/deck.ts
+0
-55
src/ui/WaitRoom.tsx
src/ui/WaitRoom.tsx
+12
-4
No files found.
src/api/deck.ts
View file @
76900895
...
@@ -30,58 +30,3 @@ function _objToMap(object: any): Map<string, IDeck> {
...
@@ -30,58 +30,3 @@ function _objToMap(object: any): Map<string, IDeck> {
return
map
;
return
map
;
}
}
export
function
parseYdk
(
text
:
string
):
IDeck
|
undefined
{
const
lineIter
=
text
.
split
(
"
\n
"
);
const
deck
:
{
main
:
number
[];
extra
:
number
[];
side
:
number
[]
}
=
{
main
:
[],
extra
:
[],
side
:
[],
};
let
flag
=
-
1
;
for
(
const
line
of
lineIter
)
{
switch
(
line
)
{
case
"
#main
\r
"
:
{
flag
=
1
;
break
;
}
case
"
#extra
\r
"
:
{
flag
=
2
;
break
;
}
case
"
!side
\r
"
:
{
flag
=
3
;
break
;
}
default
:
{
let
code
=
Number
(
line
);
if
(
!
isNaN
(
code
))
{
if
(
code
>
100
)
{
switch
(
flag
)
{
case
1
:
{
deck
.
main
.
push
(
code
);
break
;
}
case
2
:
{
deck
.
extra
.
push
(
code
);
break
;
}
case
3
:
{
deck
.
side
.
push
(
code
);
break
;
}
default
:
{
break
;
}
}
}
}
break
;
}
}
}
return
deck
.
main
.
length
==
0
?
undefined
:
deck
;
}
src/ui/WaitRoom.tsx
View file @
76900895
...
@@ -22,7 +22,7 @@ import {
...
@@ -22,7 +22,7 @@ import {
import
{
useAppSelector
}
from
"
../hook
"
;
import
{
useAppSelector
}
from
"
../hook
"
;
import
{
selectJoined
}
from
"
../reducers/joinSlice
"
;
import
{
selectJoined
}
from
"
../reducers/joinSlice
"
;
import
{
selectChat
}
from
"
../reducers/chatSlice
"
;
import
{
selectChat
}
from
"
../reducers/chatSlice
"
;
import
{
fetchDeck
,
IDeck
,
parseYdk
}
from
"
../api/deck
"
;
import
{
fetchDeck
,
IDeck
}
from
"
../api/deck
"
;
import
{
import
{
sendUpdateDeck
,
sendUpdateDeck
,
sendHsReady
,
sendHsReady
,
...
@@ -43,6 +43,7 @@ import type { MenuProps, UploadProps } from "antd";
...
@@ -43,6 +43,7 @@ import type { MenuProps, UploadProps } from "antd";
import
{
useParams
}
from
"
react-router-dom
"
;
import
{
useParams
}
from
"
react-router-dom
"
;
import
{
selectDuelStart
}
from
"
../reducers/moraSlice
"
;
import
{
selectDuelStart
}
from
"
../reducers/moraSlice
"
;
import
NeosConfig
from
"
../../neos.config.json
"
;
import
NeosConfig
from
"
../../neos.config.json
"
;
import
YGOProDeck
from
"
ygopro-deck-encode
"
;
const
READY_STATE
=
"
ready
"
;
const
READY_STATE
=
"
ready
"
;
...
@@ -109,9 +110,16 @@ const WaitRoom = () => {
...
@@ -109,9 +110,16 @@ const WaitRoom = () => {
const
reader
=
new
FileReader
();
const
reader
=
new
FileReader
();
reader
.
readAsText
(
file
);
reader
.
readAsText
(
file
);
reader
.
onload
=
(
e
)
=>
{
reader
.
onload
=
(
e
)
=>
{
const
text
=
e
.
target
?.
result
as
string
;
const
ydk
=
e
.
target
?.
result
as
string
;
const
deck
=
parseYdk
(
text
);
const
deck
=
YGOProDeck
.
fromYdkString
(
ydk
);
if
(
deck
)
{
if
(
!
(
deck
.
main
.
length
==
0
&&
deck
.
extra
.
length
==
0
&&
deck
.
side
.
length
==
0
)
)
{
// YDK解析成功
// YDK解析成功
message
.
success
(
`
${
file
.
name
}
解析成功`
);
message
.
success
(
`
${
file
.
name
}
解析成功`
);
...
...
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