@xcpcio/core 0.36.0 → 0.37.0
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/dist/index.cjs +50 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.mjs +50 -1
- package/package.json +2 -2
- package/src/export/general-excel.ts +36 -1
- package/src/team.ts +26 -0
package/dist/index.cjs
CHANGED
|
@@ -409,6 +409,8 @@ class GeneralExcelConverter {
|
|
|
409
409
|
convertToAoa(rank) {
|
|
410
410
|
const aoa = [];
|
|
411
411
|
const enableAwards = rank.contest.isEnableAwards(rank.options.group);
|
|
412
|
+
const enableMembers = (Array.isArray(rank.teams) && rank.teams[0]?.members) ?? false;
|
|
413
|
+
const enableCoach = rank.teams[0]?.coach ?? false;
|
|
412
414
|
{
|
|
413
415
|
aoa.push([rank.contest.name]);
|
|
414
416
|
}
|
|
@@ -419,10 +421,18 @@ class GeneralExcelConverter {
|
|
|
419
421
|
head.push(`${rank.contest.organization} Rank`);
|
|
420
422
|
head.push(rank.contest.organization);
|
|
421
423
|
}
|
|
422
|
-
head.push("
|
|
424
|
+
head.push("Team", "Solved", "Penalty", ...rank.contest.problems.map((p) => p.label), "Dirt");
|
|
423
425
|
if (enableAwards) {
|
|
424
426
|
head.push("Medal");
|
|
425
427
|
}
|
|
428
|
+
if (enableMembers) {
|
|
429
|
+
head.push("Member1", "Member2", "Member3");
|
|
430
|
+
}
|
|
431
|
+
if (enableCoach) {
|
|
432
|
+
head.push("Coach");
|
|
433
|
+
}
|
|
434
|
+
head.push("Unofficial");
|
|
435
|
+
head.push("Girl");
|
|
426
436
|
aoa.push(head);
|
|
427
437
|
}
|
|
428
438
|
for (const team of rank.teams) {
|
|
@@ -456,6 +466,25 @@ class GeneralExcelConverter {
|
|
|
456
466
|
const medals = team.awards.filter((a) => isValidMedalType(a)).map((a) => a.toString());
|
|
457
467
|
arr.push(medals.join(", "));
|
|
458
468
|
}
|
|
469
|
+
if (enableMembers) {
|
|
470
|
+
const members = team.members;
|
|
471
|
+
if (Array.isArray(members)) {
|
|
472
|
+
arr.push(members[0] ?? "");
|
|
473
|
+
arr.push(members[1] ?? "");
|
|
474
|
+
arr.push(members[2] ?? "");
|
|
475
|
+
} else {
|
|
476
|
+
arr.push("", "", "");
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
if (enableCoach) {
|
|
480
|
+
if (typeof team.coach === "string") {
|
|
481
|
+
arr.push(team.coach ?? "");
|
|
482
|
+
} else {
|
|
483
|
+
arr.push("");
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
arr.push(team.isUnofficial ? "Y" : "N");
|
|
487
|
+
arr.push(team.isGirl ? "Y" : "N");
|
|
459
488
|
aoa.push(arr);
|
|
460
489
|
}
|
|
461
490
|
return aoa;
|
|
@@ -661,6 +690,26 @@ class Team {
|
|
|
661
690
|
const solvedNum = this.solvedProblemNum;
|
|
662
691
|
return calcDirt(attemptedNum, solvedNum);
|
|
663
692
|
}
|
|
693
|
+
get isUnofficial() {
|
|
694
|
+
return this.group.includes("unofficial");
|
|
695
|
+
}
|
|
696
|
+
get isGirl() {
|
|
697
|
+
return this.group.includes("girl");
|
|
698
|
+
}
|
|
699
|
+
get membersToArray() {
|
|
700
|
+
if (Array.isArray(this.members)) {
|
|
701
|
+
return this.members;
|
|
702
|
+
}
|
|
703
|
+
if (typeof this.members === "string") {
|
|
704
|
+
if (this.members.includes(", ")) {
|
|
705
|
+
return this.members.split(", ");
|
|
706
|
+
}
|
|
707
|
+
if (this.members.includes("\u3001")) {
|
|
708
|
+
return this.members.split("\u3001");
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
return [];
|
|
712
|
+
}
|
|
664
713
|
get membersToString() {
|
|
665
714
|
if (typeof this.members === "string") {
|
|
666
715
|
return this.members;
|
package/dist/index.d.ts
CHANGED
|
@@ -199,6 +199,9 @@ declare class Team {
|
|
|
199
199
|
reset(): void;
|
|
200
200
|
get penaltyToMinute(): number;
|
|
201
201
|
get dirt(): number;
|
|
202
|
+
get isUnofficial(): boolean;
|
|
203
|
+
get isGirl(): boolean;
|
|
204
|
+
get membersToArray(): string[];
|
|
202
205
|
get membersToString(): string | undefined;
|
|
203
206
|
get isEffectiveTeam(): boolean;
|
|
204
207
|
calcSolvedData(options: ContestOptions): void;
|
package/dist/index.mjs
CHANGED
|
@@ -378,6 +378,8 @@ class GeneralExcelConverter {
|
|
|
378
378
|
convertToAoa(rank) {
|
|
379
379
|
const aoa = [];
|
|
380
380
|
const enableAwards = rank.contest.isEnableAwards(rank.options.group);
|
|
381
|
+
const enableMembers = (Array.isArray(rank.teams) && rank.teams[0]?.members) ?? false;
|
|
382
|
+
const enableCoach = rank.teams[0]?.coach ?? false;
|
|
381
383
|
{
|
|
382
384
|
aoa.push([rank.contest.name]);
|
|
383
385
|
}
|
|
@@ -388,10 +390,18 @@ class GeneralExcelConverter {
|
|
|
388
390
|
head.push(`${rank.contest.organization} Rank`);
|
|
389
391
|
head.push(rank.contest.organization);
|
|
390
392
|
}
|
|
391
|
-
head.push("
|
|
393
|
+
head.push("Team", "Solved", "Penalty", ...rank.contest.problems.map((p) => p.label), "Dirt");
|
|
392
394
|
if (enableAwards) {
|
|
393
395
|
head.push("Medal");
|
|
394
396
|
}
|
|
397
|
+
if (enableMembers) {
|
|
398
|
+
head.push("Member1", "Member2", "Member3");
|
|
399
|
+
}
|
|
400
|
+
if (enableCoach) {
|
|
401
|
+
head.push("Coach");
|
|
402
|
+
}
|
|
403
|
+
head.push("Unofficial");
|
|
404
|
+
head.push("Girl");
|
|
395
405
|
aoa.push(head);
|
|
396
406
|
}
|
|
397
407
|
for (const team of rank.teams) {
|
|
@@ -425,6 +435,25 @@ class GeneralExcelConverter {
|
|
|
425
435
|
const medals = team.awards.filter((a) => isValidMedalType(a)).map((a) => a.toString());
|
|
426
436
|
arr.push(medals.join(", "));
|
|
427
437
|
}
|
|
438
|
+
if (enableMembers) {
|
|
439
|
+
const members = team.members;
|
|
440
|
+
if (Array.isArray(members)) {
|
|
441
|
+
arr.push(members[0] ?? "");
|
|
442
|
+
arr.push(members[1] ?? "");
|
|
443
|
+
arr.push(members[2] ?? "");
|
|
444
|
+
} else {
|
|
445
|
+
arr.push("", "", "");
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
if (enableCoach) {
|
|
449
|
+
if (typeof team.coach === "string") {
|
|
450
|
+
arr.push(team.coach ?? "");
|
|
451
|
+
} else {
|
|
452
|
+
arr.push("");
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
arr.push(team.isUnofficial ? "Y" : "N");
|
|
456
|
+
arr.push(team.isGirl ? "Y" : "N");
|
|
428
457
|
aoa.push(arr);
|
|
429
458
|
}
|
|
430
459
|
return aoa;
|
|
@@ -630,6 +659,26 @@ class Team {
|
|
|
630
659
|
const solvedNum = this.solvedProblemNum;
|
|
631
660
|
return calcDirt(attemptedNum, solvedNum);
|
|
632
661
|
}
|
|
662
|
+
get isUnofficial() {
|
|
663
|
+
return this.group.includes("unofficial");
|
|
664
|
+
}
|
|
665
|
+
get isGirl() {
|
|
666
|
+
return this.group.includes("girl");
|
|
667
|
+
}
|
|
668
|
+
get membersToArray() {
|
|
669
|
+
if (Array.isArray(this.members)) {
|
|
670
|
+
return this.members;
|
|
671
|
+
}
|
|
672
|
+
if (typeof this.members === "string") {
|
|
673
|
+
if (this.members.includes(", ")) {
|
|
674
|
+
return this.members.split(", ");
|
|
675
|
+
}
|
|
676
|
+
if (this.members.includes("\u3001")) {
|
|
677
|
+
return this.members.split("\u3001");
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
return [];
|
|
681
|
+
}
|
|
633
682
|
get membersToString() {
|
|
634
683
|
if (typeof this.members === "string") {
|
|
635
684
|
return this.members;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xcpcio/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "XCPCIO Core",
|
|
5
5
|
"author": "Dup4 <lyuzhi.pan@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"lodash": "^4.17.21",
|
|
47
47
|
"string-width": "^6.1.0",
|
|
48
48
|
"xlsx-js-style": "^1.2.0",
|
|
49
|
-
"@xcpcio/types": "0.
|
|
49
|
+
"@xcpcio/types": "0.37.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@babel/types": "^7.22.4",
|
|
@@ -110,6 +110,8 @@ export class GeneralExcelConverter {
|
|
|
110
110
|
const aoa: string[][] = [];
|
|
111
111
|
|
|
112
112
|
const enableAwards = rank.contest.isEnableAwards(rank.options.group);
|
|
113
|
+
const enableMembers = (Array.isArray(rank.teams) && rank.teams[0]?.members) ?? false;
|
|
114
|
+
const enableCoach = rank.teams[0]?.coach ?? false;
|
|
113
115
|
|
|
114
116
|
{
|
|
115
117
|
aoa.push([rank.contest.name]);
|
|
@@ -124,12 +126,23 @@ export class GeneralExcelConverter {
|
|
|
124
126
|
head.push(rank.contest.organization);
|
|
125
127
|
}
|
|
126
128
|
|
|
127
|
-
head.push("
|
|
129
|
+
head.push("Team", "Solved", "Penalty", ...rank.contest.problems.map(p => p.label), "Dirt");
|
|
128
130
|
|
|
129
131
|
if (enableAwards) {
|
|
130
132
|
head.push("Medal");
|
|
131
133
|
}
|
|
132
134
|
|
|
135
|
+
if (enableMembers) {
|
|
136
|
+
head.push("Member1", "Member2", "Member3");
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (enableCoach) {
|
|
140
|
+
head.push("Coach");
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
head.push("Unofficial");
|
|
144
|
+
head.push("Girl");
|
|
145
|
+
|
|
133
146
|
aoa.push(head);
|
|
134
147
|
}
|
|
135
148
|
|
|
@@ -176,6 +189,28 @@ export class GeneralExcelConverter {
|
|
|
176
189
|
arr.push(medals.join(", "));
|
|
177
190
|
}
|
|
178
191
|
|
|
192
|
+
if (enableMembers) {
|
|
193
|
+
const members = team.members;
|
|
194
|
+
if (Array.isArray(members)) {
|
|
195
|
+
arr.push(members[0] ?? "");
|
|
196
|
+
arr.push(members[1] ?? "");
|
|
197
|
+
arr.push(members[2] ?? "");
|
|
198
|
+
} else {
|
|
199
|
+
arr.push("", "", "");
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (enableCoach) {
|
|
204
|
+
if (typeof team.coach === "string") {
|
|
205
|
+
arr.push(team.coach ?? "");
|
|
206
|
+
} else {
|
|
207
|
+
arr.push("");
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
arr.push(team.isUnofficial ? "Y" : "N");
|
|
212
|
+
arr.push(team.isGirl ? "Y" : "N");
|
|
213
|
+
|
|
179
214
|
aoa.push(arr);
|
|
180
215
|
}
|
|
181
216
|
|
package/src/team.ts
CHANGED
|
@@ -119,6 +119,32 @@ export class Team {
|
|
|
119
119
|
return calcDirt(attemptedNum, solvedNum);
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
get isUnofficial() {
|
|
123
|
+
return this.group.includes("unofficial");
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
get isGirl() {
|
|
127
|
+
return this.group.includes("girl");
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
get membersToArray() {
|
|
131
|
+
if (Array.isArray(this.members)) {
|
|
132
|
+
return this.members;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (typeof this.members === "string") {
|
|
136
|
+
if (this.members.includes(", ")) {
|
|
137
|
+
return this.members.split(", ");
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (this.members.includes("、")) {
|
|
141
|
+
return this.members.split("、");
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return [];
|
|
146
|
+
}
|
|
147
|
+
|
|
122
148
|
get membersToString() {
|
|
123
149
|
if (typeof this.members === "string") {
|
|
124
150
|
return this.members;
|