koishi-plugin-noah 2.3.6 → 2.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/games/sdvx/utils/param-parser.d.ts +5 -3
- package/lib/index.cjs +263 -3
- package/package.json +1 -1
|
@@ -8,6 +8,11 @@ export interface QueryParams {
|
|
|
8
8
|
grade?: SDVXGrade | SDVXGrade[];
|
|
9
9
|
clearType?: SDVXClearType | SDVXClearType[];
|
|
10
10
|
vf?: number | number[];
|
|
11
|
+
excludeLevel?: number[];
|
|
12
|
+
excludeScore?: number[];
|
|
13
|
+
excludeGrade?: SDVXGrade[];
|
|
14
|
+
excludeClearType?: SDVXClearType[];
|
|
15
|
+
excludeVf?: number[];
|
|
11
16
|
}
|
|
12
17
|
/**
|
|
13
18
|
* 解析带后缀的数字
|
|
@@ -49,7 +54,4 @@ export declare function parseSingleGrade(item: string): SDVXGrade[] | null;
|
|
|
49
54
|
* 解析雷达特征
|
|
50
55
|
*/
|
|
51
56
|
export declare function parseRadarFeature(item: string): string | null;
|
|
52
|
-
/**
|
|
53
|
-
* 解析用户输入参数
|
|
54
|
-
*/
|
|
55
57
|
export declare function parseQueryInput(input: string): QueryParams;
|
package/lib/index.cjs
CHANGED
|
@@ -2668,12 +2668,12 @@ function getNextVFIncrease(level, currentScore, clearType) {
|
|
|
2668
2668
|
}
|
|
2669
2669
|
__name(getNextVFIncrease, "getNextVFIncrease");
|
|
2670
2670
|
function getGradeRange(grade) {
|
|
2671
|
-
if (!grade) return ALL_GRADES;
|
|
2671
|
+
if (!grade) return ALL_GRADES.slice(0, ALL_GRADES.indexOf("A") + 1);
|
|
2672
2672
|
return Array.isArray(grade) ? grade : [grade];
|
|
2673
2673
|
}
|
|
2674
2674
|
__name(getGradeRange, "getGradeRange");
|
|
2675
2675
|
function getClearTypeRange(clearType) {
|
|
2676
|
-
if (!clearType) return ALL_CLEAR_TYPES;
|
|
2676
|
+
if (!clearType) return ALL_CLEAR_TYPES.slice(0, ALL_CLEAR_TYPES.indexOf("NC") + 1);
|
|
2677
2677
|
return Array.isArray(clearType) ? clearType : [clearType];
|
|
2678
2678
|
}
|
|
2679
2679
|
__name(getClearTypeRange, "getClearTypeRange");
|
|
@@ -2889,7 +2889,20 @@ function generateQueryResults(params) {
|
|
|
2889
2889
|
uniqueResults.push(result);
|
|
2890
2890
|
}
|
|
2891
2891
|
}
|
|
2892
|
-
const
|
|
2892
|
+
const excludeLevelSet = params.excludeLevel ? new Set(params.excludeLevel.map((l) => Math.round(l * 10))) : null;
|
|
2893
|
+
const excludeScoreSet = params.excludeScore ? new Set(params.excludeScore) : null;
|
|
2894
|
+
const excludeGradeSet = params.excludeGrade ? new Set(params.excludeGrade) : null;
|
|
2895
|
+
const excludeClearTypeSet = params.excludeClearType ? new Set(params.excludeClearType) : null;
|
|
2896
|
+
const excludeVfSet = params.excludeVf ? new Set(params.excludeVf.map((v) => Math.round(v * 20))) : null;
|
|
2897
|
+
const afterExclusion = uniqueResults.filter((result) => {
|
|
2898
|
+
if (excludeLevelSet && excludeLevelSet.has(Math.round(result.level * 10))) return false;
|
|
2899
|
+
if (excludeScoreSet && excludeScoreSet.has(result.score)) return false;
|
|
2900
|
+
if (excludeGradeSet && excludeGradeSet.has(result.grade)) return false;
|
|
2901
|
+
if (excludeClearTypeSet && excludeClearTypeSet.has(result.clearType)) return false;
|
|
2902
|
+
if (excludeVfSet && excludeVfSet.has(Math.round(result.vf * 20))) return false;
|
|
2903
|
+
return true;
|
|
2904
|
+
});
|
|
2905
|
+
const filteredResults = afterExclusion.filter((result) => result.clearType !== "S-PUC");
|
|
2893
2906
|
return filteredResults.sort((a, b) => b.vf - a.vf);
|
|
2894
2907
|
}
|
|
2895
2908
|
__name(generateQueryResults, "generateQueryResults");
|
|
@@ -5388,6 +5401,249 @@ function parseRadarFeature(item) {
|
|
|
5388
5401
|
return null;
|
|
5389
5402
|
}
|
|
5390
5403
|
__name(parseRadarFeature, "parseRadarFeature");
|
|
5404
|
+
function extractOperator(item) {
|
|
5405
|
+
if (item.startsWith(">=")) return { op: ">=", value: item.slice(2) };
|
|
5406
|
+
if (item.startsWith("<=")) return { op: "<=", value: item.slice(2) };
|
|
5407
|
+
if (item.startsWith("!=")) return { op: "!=", value: item.slice(2) };
|
|
5408
|
+
if (item.startsWith(">")) return { op: ">", value: item.slice(1) };
|
|
5409
|
+
if (item.startsWith("<")) return { op: "<", value: item.slice(1) };
|
|
5410
|
+
if (item.startsWith("=")) return { op: "=", value: item.slice(1) };
|
|
5411
|
+
if (item.startsWith("~")) return { op: "~", value: item.slice(1) };
|
|
5412
|
+
return { op: null, value: item };
|
|
5413
|
+
}
|
|
5414
|
+
__name(extractOperator, "extractOperator");
|
|
5415
|
+
function getAllValidLevels2() {
|
|
5416
|
+
const levels = [];
|
|
5417
|
+
for (let i = 1; i <= 16; i++) levels.push(i);
|
|
5418
|
+
levels.push(17, 17.5);
|
|
5419
|
+
for (let scaled = 180; scaled <= 209; scaled++) levels.push(scaled / 10);
|
|
5420
|
+
return levels;
|
|
5421
|
+
}
|
|
5422
|
+
__name(getAllValidLevels2, "getAllValidLevels");
|
|
5423
|
+
function applyLevelOperator(op, levels) {
|
|
5424
|
+
const allLevels = getAllValidLevels2();
|
|
5425
|
+
const value = levels[0];
|
|
5426
|
+
if (op === "=") return { include: levels, exclude: [] };
|
|
5427
|
+
if (op === "!=") return { include: [], exclude: levels };
|
|
5428
|
+
if (op === "~") {
|
|
5429
|
+
const result = /* @__PURE__ */ new Set();
|
|
5430
|
+
for (const lv of levels) {
|
|
5431
|
+
const idx2 = allLevels.indexOf(lv);
|
|
5432
|
+
if (idx2 === -1) continue;
|
|
5433
|
+
if (idx2 > 0) result.add(allLevels[idx2 - 1]);
|
|
5434
|
+
result.add(allLevels[idx2]);
|
|
5435
|
+
if (idx2 < allLevels.length - 1) result.add(allLevels[idx2 + 1]);
|
|
5436
|
+
}
|
|
5437
|
+
return { include: [...result], exclude: [] };
|
|
5438
|
+
}
|
|
5439
|
+
const idx = allLevels.indexOf(value);
|
|
5440
|
+
if (idx === -1) return { include: levels, exclude: [] };
|
|
5441
|
+
switch (op) {
|
|
5442
|
+
case ">":
|
|
5443
|
+
return { include: allLevels.slice(idx + 1), exclude: [] };
|
|
5444
|
+
case ">=":
|
|
5445
|
+
return { include: allLevels.slice(idx), exclude: [] };
|
|
5446
|
+
case "<":
|
|
5447
|
+
return { include: allLevels.slice(0, idx), exclude: [] };
|
|
5448
|
+
case "<=":
|
|
5449
|
+
return { include: allLevels.slice(0, idx + 1), exclude: [] };
|
|
5450
|
+
}
|
|
5451
|
+
}
|
|
5452
|
+
__name(applyLevelOperator, "applyLevelOperator");
|
|
5453
|
+
function applyScoreOperator(op, scores) {
|
|
5454
|
+
const value = scores[0];
|
|
5455
|
+
if (op === "=") return { include: [value], exclude: [] };
|
|
5456
|
+
if (op === "!=") return { include: [], exclude: [value] };
|
|
5457
|
+
if (op === "~") {
|
|
5458
|
+
return { include: [value - 5e4, value + 5e4], exclude: [] };
|
|
5459
|
+
}
|
|
5460
|
+
switch (op) {
|
|
5461
|
+
case ">":
|
|
5462
|
+
return { include: [value + 1, 1e7], exclude: [] };
|
|
5463
|
+
case ">=":
|
|
5464
|
+
return { include: [value, 1e7], exclude: [] };
|
|
5465
|
+
case "<":
|
|
5466
|
+
return { include: [0, value - 1], exclude: [] };
|
|
5467
|
+
case "<=":
|
|
5468
|
+
return { include: [0, value], exclude: [] };
|
|
5469
|
+
}
|
|
5470
|
+
}
|
|
5471
|
+
__name(applyScoreOperator, "applyScoreOperator");
|
|
5472
|
+
function applyVfOperator(op, vfValue) {
|
|
5473
|
+
if (op === "=") return { include: vfValue, exclude: [] };
|
|
5474
|
+
if (op === "!=") return { include: [], exclude: [vfValue] };
|
|
5475
|
+
if (op === "~") {
|
|
5476
|
+
return { include: [vfValue - 0.25, vfValue + 0.25], exclude: [] };
|
|
5477
|
+
}
|
|
5478
|
+
switch (op) {
|
|
5479
|
+
case ">":
|
|
5480
|
+
return { include: [vfValue + 0.05, 99], exclude: [] };
|
|
5481
|
+
case ">=":
|
|
5482
|
+
return { include: [vfValue, 99], exclude: [] };
|
|
5483
|
+
case "<":
|
|
5484
|
+
return { include: [0, vfValue - 0.05], exclude: [] };
|
|
5485
|
+
case "<=":
|
|
5486
|
+
return { include: [0, vfValue], exclude: [] };
|
|
5487
|
+
}
|
|
5488
|
+
}
|
|
5489
|
+
__name(applyVfOperator, "applyVfOperator");
|
|
5490
|
+
function applyGradeOperator(op, grade) {
|
|
5491
|
+
const idx = ALL_GRADES.indexOf(grade);
|
|
5492
|
+
if (idx === -1) return { include: [grade], exclude: [] };
|
|
5493
|
+
if (op === "=") return { include: [grade], exclude: [] };
|
|
5494
|
+
if (op === "!=") return { include: [], exclude: [grade] };
|
|
5495
|
+
if (op === "~") {
|
|
5496
|
+
const result = [];
|
|
5497
|
+
if (idx > 0) result.push(ALL_GRADES[idx - 1]);
|
|
5498
|
+
result.push(ALL_GRADES[idx]);
|
|
5499
|
+
if (idx < ALL_GRADES.length - 1) result.push(ALL_GRADES[idx + 1]);
|
|
5500
|
+
return { include: result, exclude: [] };
|
|
5501
|
+
}
|
|
5502
|
+
switch (op) {
|
|
5503
|
+
case ">":
|
|
5504
|
+
return { include: ALL_GRADES.slice(0, idx), exclude: [] };
|
|
5505
|
+
case ">=":
|
|
5506
|
+
return { include: ALL_GRADES.slice(0, idx + 1), exclude: [] };
|
|
5507
|
+
case "<":
|
|
5508
|
+
return { include: ALL_GRADES.slice(idx + 1), exclude: [] };
|
|
5509
|
+
case "<=":
|
|
5510
|
+
return { include: ALL_GRADES.slice(idx), exclude: [] };
|
|
5511
|
+
}
|
|
5512
|
+
}
|
|
5513
|
+
__name(applyGradeOperator, "applyGradeOperator");
|
|
5514
|
+
function applyClearTypeOperator(op, clearType) {
|
|
5515
|
+
const idx = ALL_CLEAR_TYPES.indexOf(clearType);
|
|
5516
|
+
if (idx === -1) return { include: [clearType], exclude: [] };
|
|
5517
|
+
if (op === "=") return { include: [clearType], exclude: [] };
|
|
5518
|
+
if (op === "!=") return { include: [], exclude: [clearType] };
|
|
5519
|
+
if (op === "~") {
|
|
5520
|
+
const result = [];
|
|
5521
|
+
if (idx > 0) result.push(ALL_CLEAR_TYPES[idx - 1]);
|
|
5522
|
+
result.push(ALL_CLEAR_TYPES[idx]);
|
|
5523
|
+
if (idx < ALL_CLEAR_TYPES.length - 1) result.push(ALL_CLEAR_TYPES[idx + 1]);
|
|
5524
|
+
return { include: result, exclude: [] };
|
|
5525
|
+
}
|
|
5526
|
+
switch (op) {
|
|
5527
|
+
case ">":
|
|
5528
|
+
return { include: ALL_CLEAR_TYPES.slice(0, idx), exclude: [] };
|
|
5529
|
+
case ">=":
|
|
5530
|
+
return { include: ALL_CLEAR_TYPES.slice(0, idx + 1), exclude: [] };
|
|
5531
|
+
case "<":
|
|
5532
|
+
return { include: ALL_CLEAR_TYPES.slice(idx + 1), exclude: [] };
|
|
5533
|
+
case "<=":
|
|
5534
|
+
return { include: ALL_CLEAR_TYPES.slice(idx), exclude: [] };
|
|
5535
|
+
}
|
|
5536
|
+
}
|
|
5537
|
+
__name(applyClearTypeOperator, "applyClearTypeOperator");
|
|
5538
|
+
function mergeLevels(params, levels) {
|
|
5539
|
+
if (params.level !== void 0) {
|
|
5540
|
+
const existing = Array.isArray(params.level) ? params.level : [params.level];
|
|
5541
|
+
params.level = [.../* @__PURE__ */ new Set([...existing, ...levels])];
|
|
5542
|
+
} else {
|
|
5543
|
+
params.level = levels.length === 1 ? levels[0] : levels;
|
|
5544
|
+
}
|
|
5545
|
+
}
|
|
5546
|
+
__name(mergeLevels, "mergeLevels");
|
|
5547
|
+
function mergeScores(params, scores) {
|
|
5548
|
+
if (params.score !== void 0) {
|
|
5549
|
+
const existing = Array.isArray(params.score) ? params.score : [params.score];
|
|
5550
|
+
params.score = [.../* @__PURE__ */ new Set([...existing, ...scores])];
|
|
5551
|
+
} else {
|
|
5552
|
+
params.score = scores.length === 1 ? scores[0] : scores;
|
|
5553
|
+
}
|
|
5554
|
+
}
|
|
5555
|
+
__name(mergeScores, "mergeScores");
|
|
5556
|
+
function mergeVf(params, vf2) {
|
|
5557
|
+
if (params.vf !== void 0) {
|
|
5558
|
+
const existing = Array.isArray(params.vf) ? params.vf : [params.vf];
|
|
5559
|
+
const newVf = Array.isArray(vf2) ? vf2 : [vf2];
|
|
5560
|
+
params.vf = [...existing, ...newVf];
|
|
5561
|
+
} else {
|
|
5562
|
+
params.vf = vf2;
|
|
5563
|
+
}
|
|
5564
|
+
}
|
|
5565
|
+
__name(mergeVf, "mergeVf");
|
|
5566
|
+
function mergeGrades(params, grades) {
|
|
5567
|
+
if (params.grade) {
|
|
5568
|
+
const existing = Array.isArray(params.grade) ? params.grade : [params.grade];
|
|
5569
|
+
params.grade = [.../* @__PURE__ */ new Set([...existing, ...grades])];
|
|
5570
|
+
} else {
|
|
5571
|
+
params.grade = grades.length === 1 ? grades[0] : grades;
|
|
5572
|
+
}
|
|
5573
|
+
}
|
|
5574
|
+
__name(mergeGrades, "mergeGrades");
|
|
5575
|
+
function mergeClearTypes(params, clearTypes) {
|
|
5576
|
+
if (params.clearType) {
|
|
5577
|
+
const existing = Array.isArray(params.clearType) ? params.clearType : [params.clearType];
|
|
5578
|
+
params.clearType = [.../* @__PURE__ */ new Set([...existing, ...clearTypes])];
|
|
5579
|
+
} else {
|
|
5580
|
+
params.clearType = clearTypes;
|
|
5581
|
+
}
|
|
5582
|
+
}
|
|
5583
|
+
__name(mergeClearTypes, "mergeClearTypes");
|
|
5584
|
+
function parseWithOperator(params, op, value) {
|
|
5585
|
+
const vf2 = parseVfValue(value);
|
|
5586
|
+
if (vf2 !== null) {
|
|
5587
|
+
const vfNum = Array.isArray(vf2) ? vf2[0] : vf2;
|
|
5588
|
+
const result = applyVfOperator(op, vfNum);
|
|
5589
|
+
if (result.exclude.length > 0) {
|
|
5590
|
+
params.excludeVf = [...params.excludeVf || [], ...result.exclude];
|
|
5591
|
+
}
|
|
5592
|
+
if (Array.isArray(result.include) && result.include.length > 0) {
|
|
5593
|
+
mergeVf(params, result.include);
|
|
5594
|
+
} else if (typeof result.include === "number") {
|
|
5595
|
+
mergeVf(params, result.include);
|
|
5596
|
+
}
|
|
5597
|
+
return true;
|
|
5598
|
+
}
|
|
5599
|
+
const levels = parseLevelRange(value);
|
|
5600
|
+
if (levels !== null && levels.length === 1) {
|
|
5601
|
+
const result = applyLevelOperator(op, levels);
|
|
5602
|
+
if (result.exclude.length > 0) {
|
|
5603
|
+
params.excludeLevel = [...params.excludeLevel || [], ...result.exclude];
|
|
5604
|
+
}
|
|
5605
|
+
if (result.include.length > 0) {
|
|
5606
|
+
mergeLevels(params, result.include);
|
|
5607
|
+
}
|
|
5608
|
+
return true;
|
|
5609
|
+
}
|
|
5610
|
+
const scores = parseScoreRange(value);
|
|
5611
|
+
if (scores !== null && scores.length === 1) {
|
|
5612
|
+
const result = applyScoreOperator(op, scores);
|
|
5613
|
+
if (result.exclude.length > 0) {
|
|
5614
|
+
params.excludeScore = [...params.excludeScore || [], ...result.exclude];
|
|
5615
|
+
}
|
|
5616
|
+
if (result.include.length > 0) {
|
|
5617
|
+
mergeScores(params, result.include);
|
|
5618
|
+
}
|
|
5619
|
+
return true;
|
|
5620
|
+
}
|
|
5621
|
+
const singleClearTypes = parseSingleClearType(value);
|
|
5622
|
+
if (singleClearTypes !== null) {
|
|
5623
|
+
const ct = singleClearTypes[0];
|
|
5624
|
+
const result = applyClearTypeOperator(op, ct);
|
|
5625
|
+
if (result.exclude.length > 0) {
|
|
5626
|
+
params.excludeClearType = [...params.excludeClearType || [], ...result.exclude];
|
|
5627
|
+
}
|
|
5628
|
+
if (result.include.length > 0) {
|
|
5629
|
+
mergeClearTypes(params, result.include);
|
|
5630
|
+
}
|
|
5631
|
+
return true;
|
|
5632
|
+
}
|
|
5633
|
+
const singleGrades = parseSingleGrade(value);
|
|
5634
|
+
if (singleGrades !== null) {
|
|
5635
|
+
const result = applyGradeOperator(op, singleGrades[0]);
|
|
5636
|
+
if (result.exclude.length > 0) {
|
|
5637
|
+
params.excludeGrade = [...params.excludeGrade || [], ...result.exclude];
|
|
5638
|
+
}
|
|
5639
|
+
if (result.include.length > 0) {
|
|
5640
|
+
mergeGrades(params, result.include);
|
|
5641
|
+
}
|
|
5642
|
+
return true;
|
|
5643
|
+
}
|
|
5644
|
+
return false;
|
|
5645
|
+
}
|
|
5646
|
+
__name(parseWithOperator, "parseWithOperator");
|
|
5391
5647
|
function parseQueryInput(input) {
|
|
5392
5648
|
const params = {};
|
|
5393
5649
|
if (!input || input.trim() === "") {
|
|
@@ -5395,6 +5651,10 @@ function parseQueryInput(input) {
|
|
|
5395
5651
|
}
|
|
5396
5652
|
const items = input.split(/\s+/).map((s) => s.trim()).filter(Boolean);
|
|
5397
5653
|
for (const item of items) {
|
|
5654
|
+
const { op, value } = extractOperator(item);
|
|
5655
|
+
if (op) {
|
|
5656
|
+
if (parseWithOperator(params, op, value)) continue;
|
|
5657
|
+
}
|
|
5398
5658
|
const vf2 = parseVfValue(item);
|
|
5399
5659
|
if (vf2 !== null) {
|
|
5400
5660
|
if (params.vf !== void 0) {
|