Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Card Guess
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
nanahira
Card Guess
Commits
a764c716
Commit
a764c716
authored
Mar 30, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lflist
parent
d3ed7e14
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
7 deletions
+82
-7
guess.ts
guess.ts
+1
-1
info.example.yaml
info.example.yaml
+2
-2
readme.md
readme.md
+12
-4
src/checker.ts
src/checker.ts
+3
-0
src/checkers/LFListChecker.ts
src/checkers/LFListChecker.ts
+64
-0
No files found.
guess.ts
View file @
a764c716
...
...
@@ -172,7 +172,7 @@ async function queryCards(queryInfo: QueryInfo) {
}
const
wantedStatement
=
checkerInfo
.
statement
!=
null
?
checkerInfo
.
statement
:
true
;
await
checker
.
setInfo
(
checkerInfo
.
data
);
cards
=
cards
.
filter
(
card
=>
checker
.
check
(
card
)
);
cards
=
cards
.
filter
(
card
=>
!!
checker
.
check
(
card
)
===
wantedStatement
);
}
}
return
cards
;
...
...
info.example.yaml
View file @
a764c716
upper
:
100000000
lower
:
0
noFilterAlias
:
false
c
hecker
s
:
c
ondition
s
:
-
type
:
lflist
statement
:
true
data
:
...
...
@@ -11,7 +11,7 @@ checkers:
statement
:
true
data
:
field
:
name
pattern
:
'
^.*$'
pattern
:
'
^.*
雷龙
$'
where
:
-
"
type
&
{TYPE_MONSTER}
>
0"
mayIncorrectStatements
:
...
...
readme.md
View file @
a764c716
...
...
@@ -28,9 +28,17 @@
upper
:
100000000
lower
:
0
noFilterAlias
:
false
regexConditions
:
-
field
:
name
pattern
:
'
^雷龙$'
conditions
:
-
type
:
lflist
statement
:
true
data
:
match
:
'
^2021.4$'
limit
:
3
-
type
:
regex
statement
:
true
data
:
field
:
name
pattern
:
'
^.*雷龙$'
where
:
-
"
type
&
{TYPE_MONSTER}
>
0"
mayIncorrectStatements
:
...
...
@@ -54,7 +62,7 @@ mayIncorrectStatements:
*
`where`
约束条件,使用 SQL 语句填写,相互之间是 AND 的关系。
*
`
regexConditions`
卡名或描述的正则过滤条件。
`field`
可以是
`name`
或者
`desc`
。
*
`
conditions`
额外过滤条件
。
### 模糊逻辑
...
...
src/checker.ts
View file @
a764c716
import
{
AbstractChecker
}
from
'
./checkers/AbstractChecker
'
;
import
{
RegexChecker
}
from
'
./checkers/RegexChecker
'
;
import
{
LFListChecker
}
from
'
./checkers/LFListChecker
'
;
export
interface
Card
{
id
:
number
;
...
...
@@ -21,6 +22,8 @@ export async function loadCheckers() {
// add checkers here
const
regexChecker
=
new
RegexChecker
();
checkersList
.
set
(
'
regex
'
,
regexChecker
);
const
lflistChecker
=
new
LFListChecker
();
checkersList
.
set
(
'
lflist
'
,
lflistChecker
);
for
(
let
checkerName
of
checkersList
.
keys
())
{
const
checker
=
checkersList
.
get
(
checkerName
);
...
...
src/checkers/LFListChecker.ts
0 → 100644
View file @
a764c716
import
{
AbstractChecker
,
Card
}
from
"
./AbstractChecker
"
;
import
{
promises
as
fs
}
from
"
fs
"
;
type
Records
=
Map
<
number
,
number
>
;
class
LFList
{
name
:
string
;
records
:
Records
;
constructor
(
name
:
string
)
{
this
.
name
=
name
;
this
.
records
=
new
Map
();
}
addRecord
(
id
:
number
,
num
:
number
)
{
this
.
records
.
set
(
id
,
num
);
}
getNum
(
id
:
number
)
{
if
(
!
this
.
records
.
has
(
id
))
{
return
3
;
}
return
this
.
records
.
get
(
id
);
}
}
export
class
LFListChecker
extends
AbstractChecker
{
info
:
any
;
lflists
:
LFList
[];
pendingLists
:
LFList
[];
expectedCount
:
number
;
async
initialize
()
{
this
.
lflists
=
[];
const
content
=
await
fs
.
readFile
(
'
./lflist.conf
'
,
"
utf-8
"
);
let
currentLFList
:
LFList
;
for
(
let
_line
of
content
.
split
(
'
\n
'
))
{
const
line
=
_line
.
trim
();
if
(
line
.
startsWith
(
'
#
'
))
{
continue
;
}
let
match
:
RegExpMatchArray
;
match
=
line
.
match
(
/^!
(
.+
)
$/
);
if
(
match
)
{
const
lflistName
=
match
[
1
];
currentLFList
=
new
LFList
(
lflistName
);
console
.
log
(
`Loading LFList
${
lflistName
}
`
);
this
.
lflists
.
push
(
currentLFList
);
continue
;
}
match
=
line
.
match
(
/^
(\d
+
)
(\d)
.*$/
);
if
(
match
)
{
if
(
currentLFList
)
{
currentLFList
.
addRecord
(
parseInt
(
match
[
1
]),
parseInt
(
match
[
2
]));
}
continue
;
}
}
}
async
setInfo
(
info
:
any
)
{
await
super
.
setInfo
(
info
);
this
.
pendingLists
=
this
.
lflists
.
filter
(
list
=>
list
.
name
.
match
(
info
.
match
));
this
.
expectedCount
=
info
.
limit
;
}
check
(
card
:
Card
)
{
return
this
.
pendingLists
.
some
(
list
=>
list
.
getNum
(
card
.
id
)
===
this
.
expectedCount
);
}
}
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