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
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
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
MyCard
Neos
Commits
d36d2caf
Commit
d36d2caf
authored
Aug 12, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add forbiddenstore
parent
b26d75e2
Pipeline
#23037
failed with stages
in 13 minutes and 11 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
0 deletions
+74
-0
neos.config.json
neos.config.json
+1
-0
neos.config.prod.json
neos.config.prod.json
+1
-0
src/stores/forbiddenStore.ts
src/stores/forbiddenStore.ts
+69
-0
src/stores/index.ts
src/stores/index.ts
+3
-0
No files found.
neos.config.json
View file @
d36d2caf
...
...
@@ -11,6 +11,7 @@
"cardImgUrl"
:
"https://cdn02.moecube.com:444/images/ygopro-images-zh-CN"
,
"cardsDbUrl"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/cards.cdb"
,
"stringsUrl"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf"
,
"lflistUrl"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/lflist.conf"
,
"replayUrl"
:
"replay.neos.moe"
,
"accountUrl"
:
"https://accounts.moecube.com"
,
"profileUrl"
:
"https://accounts.moecube.com/profiles"
,
...
...
neos.config.prod.json
View file @
d36d2caf
...
...
@@ -11,6 +11,7 @@
"cardImgUrl"
:
"https://cdn02.moecube.com:444/images/ygopro-images-zh-CN"
,
"cardsDbUrl"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/cards.cdb"
,
"stringsUrl"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf"
,
"lflistUrl"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/lflist.conf"
,
"replayUrl"
:
"replay.neos.moe"
,
"accountUrl"
:
"https://accounts.moecube.com"
,
"profileUrl"
:
"https://accounts.moecube.com/profiles"
,
...
...
src/stores/forbiddenStore.ts
0 → 100644
View file @
d36d2caf
//! 禁卡表Store
import
{
proxy
}
from
"
valtio
"
;
import
{
useConfig
}
from
"
@/config
"
;
const
{
lflistUrl
}
=
useConfig
();
type
Forbiddens
=
Map
<
number
,
number
>
;
class
ForbiddenStore
{
time
:
string
=
"
?
"
;
inner
:
Forbiddens
=
new
Map
([]);
async
init
()
{
const
text
=
await
(
await
fetch
(
lflistUrl
)).
text
();
const
{
time
,
forbiddens
}
=
extractForbiddensFromText
(
text
);
this
.
time
=
time
;
this
.
inner
=
forbiddens
;
}
}
// 解析函数,提取卡片编号和限制张数
function
parseCardInfo
(
input
:
string
):
{
cardId
:
number
;
limitCount
:
number
}
|
null
{
const
match
=
input
.
match
(
/^
(\d
+
)\s
+
(\d
+
)\s
+--/
);
if
(
match
)
{
const
cardId
=
parseInt
(
match
[
1
]);
const
limitCount
=
parseInt
(
match
[
2
]);
return
{
cardId
,
limitCount
};
}
return
null
;
}
// 分割文本为行,并提取每行的限制信息
function
extractForbiddensFromText
(
text
:
string
):
{
time
:
string
;
forbiddens
:
Forbiddens
;
}
{
const
lines
=
text
.
split
(
"
\n
"
);
const
forbiddens
=
new
Map
<
number
,
number
>
([]);
// remove first line
lines
.
shift
();
let
time
=
"
?
"
;
for
(
const
line
of
lines
)
{
if
(
line
.
startsWith
(
"
#
"
))
{
// do nothing
}
else
if
(
line
.
startsWith
(
"
!
"
))
{
if
(
time
!==
"
?
"
)
{
// 已经读取完第一个禁限表的信息了,退出循环
break
;
}
else
{
time
=
line
.
substring
(
1
).
trim
();
}
}
else
{
const
cardInfo
=
parseCardInfo
(
line
);
if
(
cardInfo
)
{
forbiddens
.
set
(
cardInfo
.
cardId
,
cardInfo
.
limitCount
);
}
}
}
return
{
time
,
forbiddens
};
}
export
const
forbiddenStore
=
proxy
(
new
ForbiddenStore
());
src/stores/index.ts
View file @
d36d2caf
...
...
@@ -2,6 +2,7 @@ export * from "./accountStore";
export
*
from
"
./cardStore
"
;
export
*
from
"
./chatStore
"
;
export
*
from
"
./deckStore
"
;
export
*
from
"
./forbiddenStore
"
;
export
*
from
"
./initStore
"
;
export
*
from
"
./matStore
"
;
export
*
from
"
./placeStore
"
;
...
...
@@ -16,6 +17,7 @@ import { accountStore } from "./accountStore";
import
{
cardStore
}
from
"
./cardStore
"
;
import
{
chatStore
}
from
"
./chatStore
"
;
import
{
deckStore
}
from
"
./deckStore
"
;
import
{
forbiddenStore
}
from
"
./forbiddenStore
"
;
import
{
initStore
}
from
"
./initStore
"
;
import
{
matStore
}
from
"
./matStore
"
;
import
{
placeStore
}
from
"
./placeStore
"
;
...
...
@@ -33,6 +35,7 @@ devtools(accountStore, { name: "account", enabled: DEV });
devtools
(
roomStore
,
{
name
:
"
room
"
,
enabled
:
DEV
});
devtools
(
deckStore
,
{
name
:
"
deck
"
,
enabled
:
DEV
});
devtools
(
initStore
,
{
name
:
"
init
"
,
enabled
:
DEV
});
devtools
(
forbiddenStore
,
{
name
:
"
forbidden
"
,
enabled
:
DEV
});
// 重置`Store`
export
const
resetUniverse
=
()
=>
{
...
...
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