@xcpcio/core 0.7.2 → 0.8.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 +74 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.mjs +73 -2
- package/package.json +2 -2
- package/src/award.ts +21 -0
- package/src/contest.ts +46 -0
- package/src/index.ts +1 -0
- package/src/rank.ts +3 -1
- package/src/team.ts +26 -0
package/dist/index.cjs
CHANGED
|
@@ -27,6 +27,22 @@ const minMax__default = /*#__PURE__*/_interopDefaultLegacy(minMax);
|
|
|
27
27
|
const relativeTime__default = /*#__PURE__*/_interopDefaultLegacy(relativeTime);
|
|
28
28
|
const ___default = /*#__PURE__*/_interopDefaultLegacy(_);
|
|
29
29
|
|
|
30
|
+
var MedalType = /* @__PURE__ */ ((MedalType2) => {
|
|
31
|
+
MedalType2[MedalType2["UNKNOWN"] = 0] = "UNKNOWN";
|
|
32
|
+
MedalType2[MedalType2["GOLD"] = 1] = "GOLD";
|
|
33
|
+
MedalType2[MedalType2["SILVER"] = 2] = "SILVER";
|
|
34
|
+
MedalType2[MedalType2["BRONZE"] = 3] = "BRONZE";
|
|
35
|
+
MedalType2[MedalType2["HONORABLE"] = 4] = "HONORABLE";
|
|
36
|
+
return MedalType2;
|
|
37
|
+
})(MedalType || {});
|
|
38
|
+
class Award {
|
|
39
|
+
constructor() {
|
|
40
|
+
this.medalType = 0 /* UNKNOWN */;
|
|
41
|
+
this.minRank = 0;
|
|
42
|
+
this.maxRank = 0;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
30
46
|
function calcDict(attemptedNum, solvedNum) {
|
|
31
47
|
if (solvedNum === 0) {
|
|
32
48
|
return 0;
|
|
@@ -300,6 +316,40 @@ function createContest(contestJSON) {
|
|
|
300
316
|
}
|
|
301
317
|
c.badge = contestJSON.badge;
|
|
302
318
|
c.medal = contestJSON.medal;
|
|
319
|
+
(() => {
|
|
320
|
+
if (contestJSON.medal === void 0 || contestJSON.medal === null) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
c.awards = /* @__PURE__ */ new Map();
|
|
324
|
+
for (const k in contestJSON.medal) {
|
|
325
|
+
const v = contestJSON.medal[k];
|
|
326
|
+
{
|
|
327
|
+
const award = [];
|
|
328
|
+
let rank = 1;
|
|
329
|
+
const work = (key, medalType) => {
|
|
330
|
+
if (Object.keys(v).includes(key)) {
|
|
331
|
+
const a = new Award();
|
|
332
|
+
a.medalType = medalType;
|
|
333
|
+
a.minRank = rank;
|
|
334
|
+
rank += Number(v[key]);
|
|
335
|
+
a.maxRank = rank - 1;
|
|
336
|
+
award.push(a);
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
work("gold", MedalType.GOLD);
|
|
340
|
+
work("silver", MedalType.SILVER);
|
|
341
|
+
work("bronze", MedalType.BRONZE);
|
|
342
|
+
{
|
|
343
|
+
const a = new Award();
|
|
344
|
+
a.medalType = MedalType.HONORABLE;
|
|
345
|
+
a.minRank = rank;
|
|
346
|
+
a.maxRank = 1061109567;
|
|
347
|
+
award.push(a);
|
|
348
|
+
}
|
|
349
|
+
c.awards.set(k, award);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
})();
|
|
303
353
|
c.organization = contestJSON.organization;
|
|
304
354
|
{
|
|
305
355
|
const g = new Group();
|
|
@@ -437,6 +487,7 @@ class Team {
|
|
|
437
487
|
this.problemStatisticsMap = /* @__PURE__ */ new Map();
|
|
438
488
|
this.submissions = [];
|
|
439
489
|
this.placeChartPoints = [];
|
|
490
|
+
this.awards = [];
|
|
440
491
|
}
|
|
441
492
|
reset() {
|
|
442
493
|
this.rank = 0;
|
|
@@ -472,6 +523,16 @@ class Team {
|
|
|
472
523
|
}
|
|
473
524
|
}
|
|
474
525
|
}
|
|
526
|
+
calcAwards(awards) {
|
|
527
|
+
if (!awards) {
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
for (const award of awards) {
|
|
531
|
+
if (this.rank >= award.minRank && this.rank <= award.maxRank) {
|
|
532
|
+
this.awards.push(award.medalType);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
475
536
|
isEqualRank(otherTeam) {
|
|
476
537
|
return this.solvedProblemNum === otherTeam.solvedProblemNum && this.penalty === otherTeam.penalty;
|
|
477
538
|
}
|
|
@@ -530,6 +591,14 @@ function createTeam(teamJSON) {
|
|
|
530
591
|
if (Boolean(teamJSON.girl) === true) {
|
|
531
592
|
t.group.push("girl");
|
|
532
593
|
}
|
|
594
|
+
{
|
|
595
|
+
const tt = teamJSON;
|
|
596
|
+
for (const key of Object.keys(tt)) {
|
|
597
|
+
if (tt[key] === 1 || tt[key] === true) {
|
|
598
|
+
t.group.push(key);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
}
|
|
533
602
|
t.group = [...new Set(t.group)];
|
|
534
603
|
t.group.sort();
|
|
535
604
|
return t;
|
|
@@ -728,7 +797,7 @@ class RankOptions {
|
|
|
728
797
|
this.width = 0;
|
|
729
798
|
this.timestamp = 0;
|
|
730
799
|
this.enableFilterTeamsByGroup = false;
|
|
731
|
-
this.group = "";
|
|
800
|
+
this.group = "all";
|
|
732
801
|
this.filterOrganizations = [];
|
|
733
802
|
this.filterOrganizationMap = /* @__PURE__ */ new Map();
|
|
734
803
|
this.filterTeams = [];
|
|
@@ -751,6 +820,7 @@ class RankOptions {
|
|
|
751
820
|
}
|
|
752
821
|
disableFilterTeamsByGroup() {
|
|
753
822
|
this.enableFilterTeamsByGroup = false;
|
|
823
|
+
this.group = "all";
|
|
754
824
|
}
|
|
755
825
|
setFilterOrganizations(filterOrganizations) {
|
|
756
826
|
const m = /* @__PURE__ */ new Map();
|
|
@@ -908,6 +978,7 @@ class Rank {
|
|
|
908
978
|
this.teams.sort(Team.compare);
|
|
909
979
|
this.buildTeamRank();
|
|
910
980
|
this.buildOrgRank();
|
|
981
|
+
this.teams.forEach((t) => t.calcAwards(this.contest.awards?.get(this.options.group)));
|
|
911
982
|
this.teams.forEach((t) => t.postProcessPlaceChartPoints());
|
|
912
983
|
})();
|
|
913
984
|
(() => {
|
|
@@ -1080,9 +1151,11 @@ class Resolver extends Rank {
|
|
|
1080
1151
|
}
|
|
1081
1152
|
|
|
1082
1153
|
exports.dayjs = dayjs__default;
|
|
1154
|
+
exports.Award = Award;
|
|
1083
1155
|
exports.Contest = Contest;
|
|
1084
1156
|
exports.ContestIndex = ContestIndex;
|
|
1085
1157
|
exports.ContestIndexConfig = ContestIndexConfig;
|
|
1158
|
+
exports.MedalType = MedalType;
|
|
1086
1159
|
exports.PlaceChartPointData = PlaceChartPointData;
|
|
1087
1160
|
exports.Problem = Problem;
|
|
1088
1161
|
exports.ProblemStatistics = ProblemStatistics;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,21 @@ import dayjs from 'dayjs';
|
|
|
2
2
|
export { default as dayjs } from 'dayjs';
|
|
3
3
|
import { SubmissionStatus, Submission as Submission$1, Submissions as Submissions$1, BalloonColor, Problem as Problem$1, Problems as Problems$1, Lang, StatusTimeDisplay, Image, ContestState, Contest as Contest$1, ContestIndex as ContestIndex$1, Team as Team$1, Teams as Teams$1 } from '@xcpcio/types';
|
|
4
4
|
|
|
5
|
+
declare enum MedalType {
|
|
6
|
+
UNKNOWN = 0,
|
|
7
|
+
GOLD = 1,
|
|
8
|
+
SILVER = 2,
|
|
9
|
+
BRONZE = 3,
|
|
10
|
+
HONORABLE = 4
|
|
11
|
+
}
|
|
12
|
+
declare class Award {
|
|
13
|
+
medalType: MedalType;
|
|
14
|
+
minRank: number;
|
|
15
|
+
maxRank: number;
|
|
16
|
+
constructor();
|
|
17
|
+
}
|
|
18
|
+
type Awards = Map<string, Award[]>;
|
|
19
|
+
|
|
5
20
|
declare class Submission {
|
|
6
21
|
id: string;
|
|
7
22
|
teamId: string;
|
|
@@ -98,6 +113,7 @@ declare class Contest {
|
|
|
98
113
|
statusTimeDisplay: StatusTimeDisplay;
|
|
99
114
|
badge?: string;
|
|
100
115
|
medal?: Record<string, Record<string, number>>;
|
|
116
|
+
awards?: Awards;
|
|
101
117
|
organization?: string;
|
|
102
118
|
group: Map<string, Group>;
|
|
103
119
|
tag: Map<string, string>;
|
|
@@ -170,11 +186,13 @@ declare class Team {
|
|
|
170
186
|
problemStatisticsMap: Map<string, TeamProblemStatistics>;
|
|
171
187
|
submissions: Submissions;
|
|
172
188
|
placeChartPoints: Array<PlaceChartPointData>;
|
|
189
|
+
awards: MedalType[];
|
|
173
190
|
constructor();
|
|
174
191
|
reset(): void;
|
|
175
192
|
get penaltyToMinute(): number;
|
|
176
193
|
get dict(): number;
|
|
177
194
|
calcSolvedData(): void;
|
|
195
|
+
calcAwards(awards?: Award[]): void;
|
|
178
196
|
isEqualRank(otherTeam: Team): boolean;
|
|
179
197
|
postProcessPlaceChartPoints(): void;
|
|
180
198
|
static compare(lhs: Team, rhs: Team): number;
|
|
@@ -249,4 +267,4 @@ declare function isRejected(status: SubmissionStatus): boolean;
|
|
|
249
267
|
declare function isPending(status: SubmissionStatus): boolean;
|
|
250
268
|
declare function isNotCalculatedPenaltyStatus(status: SubmissionStatus): boolean;
|
|
251
269
|
|
|
252
|
-
export { Contest, ContestIndex, ContestIndexConfig, ContestIndexList, PlaceChartPointData, Problem, ProblemStatistics, Problems, Rank, RankOptions, RankStatistics, Resolver, SelectOptionItem, Submission, Submissions, Team, TeamProblemStatistics, Teams, calcDict, createContest, createContestIndex, createContestIndexList, createDayJS, createProblem, createProblems, createProblemsByProblemIds, createSubmission, createSubmissions, createTeam, createTeams, getImageSource, getTimeDiff, getTimestamp, isAccepted, isNotCalculatedPenaltyStatus, isPending, isRejected, stringToSubmissionStatus };
|
|
270
|
+
export { Award, Awards, Contest, ContestIndex, ContestIndexConfig, ContestIndexList, MedalType, PlaceChartPointData, Problem, ProblemStatistics, Problems, Rank, RankOptions, RankStatistics, Resolver, SelectOptionItem, Submission, Submissions, Team, TeamProblemStatistics, Teams, calcDict, createContest, createContestIndex, createContestIndexList, createDayJS, createProblem, createProblems, createProblemsByProblemIds, createSubmission, createSubmissions, createTeam, createTeams, getImageSource, getTimeDiff, getTimestamp, isAccepted, isNotCalculatedPenaltyStatus, isPending, isRejected, stringToSubmissionStatus };
|
package/dist/index.mjs
CHANGED
|
@@ -11,6 +11,22 @@ import relativeTime from 'dayjs/plugin/relativeTime';
|
|
|
11
11
|
import { ContestState, SubmissionStatus } from '@xcpcio/types';
|
|
12
12
|
import _ from 'lodash';
|
|
13
13
|
|
|
14
|
+
var MedalType = /* @__PURE__ */ ((MedalType2) => {
|
|
15
|
+
MedalType2[MedalType2["UNKNOWN"] = 0] = "UNKNOWN";
|
|
16
|
+
MedalType2[MedalType2["GOLD"] = 1] = "GOLD";
|
|
17
|
+
MedalType2[MedalType2["SILVER"] = 2] = "SILVER";
|
|
18
|
+
MedalType2[MedalType2["BRONZE"] = 3] = "BRONZE";
|
|
19
|
+
MedalType2[MedalType2["HONORABLE"] = 4] = "HONORABLE";
|
|
20
|
+
return MedalType2;
|
|
21
|
+
})(MedalType || {});
|
|
22
|
+
class Award {
|
|
23
|
+
constructor() {
|
|
24
|
+
this.medalType = 0 /* UNKNOWN */;
|
|
25
|
+
this.minRank = 0;
|
|
26
|
+
this.maxRank = 0;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
14
30
|
function calcDict(attemptedNum, solvedNum) {
|
|
15
31
|
if (solvedNum === 0) {
|
|
16
32
|
return 0;
|
|
@@ -284,6 +300,40 @@ function createContest(contestJSON) {
|
|
|
284
300
|
}
|
|
285
301
|
c.badge = contestJSON.badge;
|
|
286
302
|
c.medal = contestJSON.medal;
|
|
303
|
+
(() => {
|
|
304
|
+
if (contestJSON.medal === void 0 || contestJSON.medal === null) {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
c.awards = /* @__PURE__ */ new Map();
|
|
308
|
+
for (const k in contestJSON.medal) {
|
|
309
|
+
const v = contestJSON.medal[k];
|
|
310
|
+
{
|
|
311
|
+
const award = [];
|
|
312
|
+
let rank = 1;
|
|
313
|
+
const work = (key, medalType) => {
|
|
314
|
+
if (Object.keys(v).includes(key)) {
|
|
315
|
+
const a = new Award();
|
|
316
|
+
a.medalType = medalType;
|
|
317
|
+
a.minRank = rank;
|
|
318
|
+
rank += Number(v[key]);
|
|
319
|
+
a.maxRank = rank - 1;
|
|
320
|
+
award.push(a);
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
work("gold", MedalType.GOLD);
|
|
324
|
+
work("silver", MedalType.SILVER);
|
|
325
|
+
work("bronze", MedalType.BRONZE);
|
|
326
|
+
{
|
|
327
|
+
const a = new Award();
|
|
328
|
+
a.medalType = MedalType.HONORABLE;
|
|
329
|
+
a.minRank = rank;
|
|
330
|
+
a.maxRank = 1061109567;
|
|
331
|
+
award.push(a);
|
|
332
|
+
}
|
|
333
|
+
c.awards.set(k, award);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
})();
|
|
287
337
|
c.organization = contestJSON.organization;
|
|
288
338
|
{
|
|
289
339
|
const g = new Group();
|
|
@@ -421,6 +471,7 @@ class Team {
|
|
|
421
471
|
this.problemStatisticsMap = /* @__PURE__ */ new Map();
|
|
422
472
|
this.submissions = [];
|
|
423
473
|
this.placeChartPoints = [];
|
|
474
|
+
this.awards = [];
|
|
424
475
|
}
|
|
425
476
|
reset() {
|
|
426
477
|
this.rank = 0;
|
|
@@ -456,6 +507,16 @@ class Team {
|
|
|
456
507
|
}
|
|
457
508
|
}
|
|
458
509
|
}
|
|
510
|
+
calcAwards(awards) {
|
|
511
|
+
if (!awards) {
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
for (const award of awards) {
|
|
515
|
+
if (this.rank >= award.minRank && this.rank <= award.maxRank) {
|
|
516
|
+
this.awards.push(award.medalType);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
459
520
|
isEqualRank(otherTeam) {
|
|
460
521
|
return this.solvedProblemNum === otherTeam.solvedProblemNum && this.penalty === otherTeam.penalty;
|
|
461
522
|
}
|
|
@@ -514,6 +575,14 @@ function createTeam(teamJSON) {
|
|
|
514
575
|
if (Boolean(teamJSON.girl) === true) {
|
|
515
576
|
t.group.push("girl");
|
|
516
577
|
}
|
|
578
|
+
{
|
|
579
|
+
const tt = teamJSON;
|
|
580
|
+
for (const key of Object.keys(tt)) {
|
|
581
|
+
if (tt[key] === 1 || tt[key] === true) {
|
|
582
|
+
t.group.push(key);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}
|
|
517
586
|
t.group = [...new Set(t.group)];
|
|
518
587
|
t.group.sort();
|
|
519
588
|
return t;
|
|
@@ -712,7 +781,7 @@ class RankOptions {
|
|
|
712
781
|
this.width = 0;
|
|
713
782
|
this.timestamp = 0;
|
|
714
783
|
this.enableFilterTeamsByGroup = false;
|
|
715
|
-
this.group = "";
|
|
784
|
+
this.group = "all";
|
|
716
785
|
this.filterOrganizations = [];
|
|
717
786
|
this.filterOrganizationMap = /* @__PURE__ */ new Map();
|
|
718
787
|
this.filterTeams = [];
|
|
@@ -735,6 +804,7 @@ class RankOptions {
|
|
|
735
804
|
}
|
|
736
805
|
disableFilterTeamsByGroup() {
|
|
737
806
|
this.enableFilterTeamsByGroup = false;
|
|
807
|
+
this.group = "all";
|
|
738
808
|
}
|
|
739
809
|
setFilterOrganizations(filterOrganizations) {
|
|
740
810
|
const m = /* @__PURE__ */ new Map();
|
|
@@ -892,6 +962,7 @@ class Rank {
|
|
|
892
962
|
this.teams.sort(Team.compare);
|
|
893
963
|
this.buildTeamRank();
|
|
894
964
|
this.buildOrgRank();
|
|
965
|
+
this.teams.forEach((t) => t.calcAwards(this.contest.awards?.get(this.options.group)));
|
|
895
966
|
this.teams.forEach((t) => t.postProcessPlaceChartPoints());
|
|
896
967
|
})();
|
|
897
968
|
(() => {
|
|
@@ -1063,4 +1134,4 @@ class Resolver extends Rank {
|
|
|
1063
1134
|
}
|
|
1064
1135
|
}
|
|
1065
1136
|
|
|
1066
|
-
export { Contest, ContestIndex, ContestIndexConfig, PlaceChartPointData, Problem, ProblemStatistics, Rank, RankOptions, RankStatistics, Resolver, Submission, Team, TeamProblemStatistics, calcDict, createContest, createContestIndex, createContestIndexList, createDayJS, createProblem, createProblems, createProblemsByProblemIds, createSubmission, createSubmissions, createTeam, createTeams, getImageSource, getTimeDiff, getTimestamp, isAccepted, isNotCalculatedPenaltyStatus, isPending, isRejected, stringToSubmissionStatus };
|
|
1137
|
+
export { Award, Contest, ContestIndex, ContestIndexConfig, MedalType, PlaceChartPointData, Problem, ProblemStatistics, Rank, RankOptions, RankStatistics, Resolver, Submission, Team, TeamProblemStatistics, calcDict, createContest, createContestIndex, createContestIndexList, createDayJS, createProblem, createProblems, createProblemsByProblemIds, createSubmission, createSubmissions, createTeam, createTeams, getImageSource, getTimeDiff, getTimestamp, isAccepted, isNotCalculatedPenaltyStatus, isPending, isRejected, stringToSubmissionStatus };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xcpcio/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "XCPCIO Core",
|
|
5
5
|
"author": "Dup4 <lyuzhi.pan@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"dayjs": "^1.11.8",
|
|
44
44
|
"lodash": "^4.17.21",
|
|
45
|
-
"@xcpcio/types": "0.
|
|
45
|
+
"@xcpcio/types": "0.8.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@babel/types": "^7.22.4",
|
package/src/award.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export enum MedalType {
|
|
2
|
+
UNKNOWN,
|
|
3
|
+
GOLD,
|
|
4
|
+
SILVER,
|
|
5
|
+
BRONZE,
|
|
6
|
+
HONORABLE,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class Award {
|
|
10
|
+
medalType: MedalType;
|
|
11
|
+
minRank: number;
|
|
12
|
+
maxRank: number;
|
|
13
|
+
|
|
14
|
+
constructor() {
|
|
15
|
+
this.medalType = MedalType.UNKNOWN;
|
|
16
|
+
this.minRank = 0;
|
|
17
|
+
this.maxRank = 0;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type Awards = Map<string, Award[]>;
|
package/src/contest.ts
CHANGED
|
@@ -5,6 +5,8 @@ import type { Problem, Problems } from "./problem";
|
|
|
5
5
|
import { createProblems, createProblemsByProblemIds } from "./problem";
|
|
6
6
|
import { createDayJS, dayjs, getTimeDiff } from "./utils";
|
|
7
7
|
import { Group } from "./group";
|
|
8
|
+
import { Award } from "./award";
|
|
9
|
+
import { type Awards, MedalType } from "./award";
|
|
8
10
|
|
|
9
11
|
export class Contest {
|
|
10
12
|
name = "";
|
|
@@ -26,6 +28,7 @@ export class Contest {
|
|
|
26
28
|
|
|
27
29
|
badge?: string;
|
|
28
30
|
medal?: Record<string, Record<string, number>>;
|
|
31
|
+
awards?: Awards;
|
|
29
32
|
organization?: string;
|
|
30
33
|
|
|
31
34
|
group: Map<string, Group>;
|
|
@@ -189,6 +192,49 @@ export function createContest(contestJSON: IContest): Contest {
|
|
|
189
192
|
|
|
190
193
|
c.badge = contestJSON.badge;
|
|
191
194
|
c.medal = contestJSON.medal;
|
|
195
|
+
|
|
196
|
+
(() => {
|
|
197
|
+
if (contestJSON.medal === undefined || contestJSON.medal === null) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
c.awards = new Map<string, Award[]>();
|
|
202
|
+
|
|
203
|
+
for (const k in contestJSON.medal) {
|
|
204
|
+
const v = contestJSON.medal[k];
|
|
205
|
+
|
|
206
|
+
{
|
|
207
|
+
const award: Award[] = [];
|
|
208
|
+
|
|
209
|
+
let rank = 1;
|
|
210
|
+
const work = (key: string, medalType: MedalType) => {
|
|
211
|
+
if (Object.keys(v).includes(key)) {
|
|
212
|
+
const a = new Award();
|
|
213
|
+
a.medalType = medalType;
|
|
214
|
+
a.minRank = rank;
|
|
215
|
+
rank += Number(v[key]);
|
|
216
|
+
a.maxRank = rank - 1;
|
|
217
|
+
award.push(a);
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
work("gold", MedalType.GOLD);
|
|
222
|
+
work("silver", MedalType.SILVER);
|
|
223
|
+
work("bronze", MedalType.BRONZE);
|
|
224
|
+
|
|
225
|
+
{
|
|
226
|
+
const a = new Award();
|
|
227
|
+
a.medalType = MedalType.HONORABLE;
|
|
228
|
+
a.minRank = rank;
|
|
229
|
+
a.maxRank = 0x3F3F3F3F;
|
|
230
|
+
award.push(a);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
c.awards.set(k, award);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
})();
|
|
237
|
+
|
|
192
238
|
c.organization = contestJSON.organization;
|
|
193
239
|
|
|
194
240
|
{
|
package/src/index.ts
CHANGED
package/src/rank.ts
CHANGED
|
@@ -32,7 +32,7 @@ export class RankOptions {
|
|
|
32
32
|
this.timestamp = 0;
|
|
33
33
|
|
|
34
34
|
this.enableFilterTeamsByGroup = false;
|
|
35
|
-
this.group = "";
|
|
35
|
+
this.group = "all";
|
|
36
36
|
|
|
37
37
|
this.filterOrganizations = [];
|
|
38
38
|
this.filterOrganizationMap = new Map<string, SelectOptionItem>();
|
|
@@ -62,6 +62,7 @@ export class RankOptions {
|
|
|
62
62
|
|
|
63
63
|
disableFilterTeamsByGroup() {
|
|
64
64
|
this.enableFilterTeamsByGroup = false;
|
|
65
|
+
this.group = "all";
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
setFilterOrganizations(filterOrganizations: Array<SelectOptionItem>) {
|
|
@@ -285,6 +286,7 @@ export class Rank {
|
|
|
285
286
|
this.buildTeamRank();
|
|
286
287
|
this.buildOrgRank();
|
|
287
288
|
|
|
289
|
+
this.teams.forEach(t => t.calcAwards(this.contest.awards?.get(this.options.group)));
|
|
288
290
|
this.teams.forEach(t => t.postProcessPlaceChartPoints());
|
|
289
291
|
})();
|
|
290
292
|
|
package/src/team.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { Team as ITeam, Teams as ITeams, Image } from "@xcpcio/types";
|
|
|
3
3
|
import type { Problem, TeamProblemStatistics } from "./problem";
|
|
4
4
|
import { calcDict } from "./utils";
|
|
5
5
|
import type { Submissions } from "./submission";
|
|
6
|
+
import type { Award, MedalType } from "./award";
|
|
6
7
|
|
|
7
8
|
export class PlaceChartPointData {
|
|
8
9
|
timePoint: number;
|
|
@@ -48,6 +49,8 @@ export class Team {
|
|
|
48
49
|
|
|
49
50
|
placeChartPoints: Array<PlaceChartPointData>;
|
|
50
51
|
|
|
52
|
+
awards: MedalType[];
|
|
53
|
+
|
|
51
54
|
constructor() {
|
|
52
55
|
this.id = "";
|
|
53
56
|
this.name = "";
|
|
@@ -75,6 +78,8 @@ export class Team {
|
|
|
75
78
|
this.submissions = [];
|
|
76
79
|
|
|
77
80
|
this.placeChartPoints = [];
|
|
81
|
+
|
|
82
|
+
this.awards = [];
|
|
78
83
|
}
|
|
79
84
|
|
|
80
85
|
reset() {
|
|
@@ -125,6 +130,18 @@ export class Team {
|
|
|
125
130
|
}
|
|
126
131
|
}
|
|
127
132
|
|
|
133
|
+
calcAwards(awards?: Award[]) {
|
|
134
|
+
if (!awards) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
for (const award of awards) {
|
|
139
|
+
if (this.rank >= award.minRank && this.rank <= award.maxRank) {
|
|
140
|
+
this.awards.push(award.medalType);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
128
145
|
isEqualRank(otherTeam: Team) {
|
|
129
146
|
return this.solvedProblemNum === otherTeam.solvedProblemNum && this.penalty === otherTeam.penalty;
|
|
130
147
|
}
|
|
@@ -205,6 +222,15 @@ export function createTeam(teamJSON: ITeam): Team {
|
|
|
205
222
|
t.group.push("girl");
|
|
206
223
|
}
|
|
207
224
|
|
|
225
|
+
{
|
|
226
|
+
const tt: any = teamJSON as any;
|
|
227
|
+
for (const key of Object.keys(tt)) {
|
|
228
|
+
if (tt[key] === 1 || tt[key] === true) {
|
|
229
|
+
t.group.push(key);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
208
234
|
t.group = [...new Set(t.group)];
|
|
209
235
|
t.group.sort();
|
|
210
236
|
|