@xcpcio/core 0.42.0 → 0.43.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 CHANGED
@@ -1043,6 +1043,83 @@ class Balloon {
1043
1043
  }
1044
1044
  }
1045
1045
 
1046
+ var GiantsType = /* @__PURE__ */ ((GiantsType2) => {
1047
+ GiantsType2[GiantsType2["BLUE"] = 0] = "BLUE";
1048
+ GiantsType2[GiantsType2["RED"] = 1] = "RED";
1049
+ return GiantsType2;
1050
+ })(GiantsType || {});
1051
+ class Giants {
1052
+ constructor(type = 0 /* BLUE */) {
1053
+ this.type = type;
1054
+ this.name = `${type === 0 /* BLUE */ ? "Blue" : "Red"} Team`;
1055
+ this.teams = [];
1056
+ this.filterOrganizations = [];
1057
+ this.filterOrganizationMap = /* @__PURE__ */ new Map();
1058
+ this.filterTeams = [];
1059
+ this.filterTeamMap = /* @__PURE__ */ new Map();
1060
+ }
1061
+ setFilterOrganizations(filterOrganizations) {
1062
+ const m = /* @__PURE__ */ new Map();
1063
+ filterOrganizations.forEach((item) => {
1064
+ m.set(item.value, item);
1065
+ });
1066
+ this.filterOrganizations = filterOrganizations;
1067
+ this.filterOrganizationMap = m;
1068
+ }
1069
+ setFilterTeams(filterTeams) {
1070
+ const m = /* @__PURE__ */ new Map();
1071
+ filterTeams.forEach((item) => {
1072
+ m.set(item.value, item);
1073
+ });
1074
+ this.filterTeams = filterTeams;
1075
+ this.filterTeamMap = m;
1076
+ }
1077
+ refreshName() {
1078
+ if (this.filterOrganizations.length > 0) {
1079
+ this.name = this.filterOrganizations[0].text;
1080
+ } else {
1081
+ this.name = `${this.type === 0 /* BLUE */ ? "Blue" : "Red"} Team`;
1082
+ }
1083
+ return this.name;
1084
+ }
1085
+ get totalSolvedProblemNum() {
1086
+ let total = 0;
1087
+ this.teams.forEach((team) => {
1088
+ total += team.solvedProblemNum;
1089
+ });
1090
+ return total;
1091
+ }
1092
+ get totalPenalty() {
1093
+ let total = 0;
1094
+ this.teams.forEach((team) => {
1095
+ total += team.penaltyToMinute;
1096
+ });
1097
+ return total;
1098
+ }
1099
+ get totalPenaltyToString() {
1100
+ const penalty = this.totalPenalty;
1101
+ const two = (a) => {
1102
+ if (a < 10) {
1103
+ return `0${a}`;
1104
+ }
1105
+ return String(a);
1106
+ };
1107
+ const h = Math.floor(penalty / 60);
1108
+ const m = Math.floor(penalty % 60);
1109
+ return [two(h), two(m)].join(":");
1110
+ }
1111
+ }
1112
+ class BattleOfGiants {
1113
+ constructor() {
1114
+ this.enable = false;
1115
+ this.topX = 5;
1116
+ this.equalTeams = true;
1117
+ this.persist = false;
1118
+ this.blueTeam = new Giants(0 /* BLUE */);
1119
+ this.redTeam = new Giants(1 /* RED */);
1120
+ }
1121
+ }
1122
+
1046
1123
  class Group {
1047
1124
  constructor() {
1048
1125
  this.names = /* @__PURE__ */ new Map();
@@ -1402,6 +1479,20 @@ class RankOptions {
1402
1479
  this.filterTeams = [];
1403
1480
  this.filterTeamMap = /* @__PURE__ */ new Map();
1404
1481
  this.enableAnimatedSubmissions = false;
1482
+ this.battleOfGiants = new BattleOfGiants();
1483
+ }
1484
+ setSelf(self) {
1485
+ this.enableFilterSubmissionsByTimestamp = self.enableFilterSubmissionsByTimestamp;
1486
+ this.width = self.width;
1487
+ this.timestamp = self.timestamp;
1488
+ this.enableFilterTeamsByGroup = self.enableFilterTeamsByGroup;
1489
+ this.group = self.group;
1490
+ this.filterOrganizations = self.filterOrganizations;
1491
+ this.filterOrganizationMap = self.filterOrganizationMap;
1492
+ this.filterTeams = self.filterTeams;
1493
+ this.filterTeamMap = self.filterTeamMap;
1494
+ this.enableAnimatedSubmissions = self.enableAnimatedSubmissions;
1495
+ this.battleOfGiants = self.battleOfGiants;
1405
1496
  }
1406
1497
  setWidth(width, contest) {
1407
1498
  this.width = width;
@@ -1898,12 +1989,15 @@ class Resolver extends Rank {
1898
1989
  exports.dayjs = dayjs__default;
1899
1990
  exports.Award = Award;
1900
1991
  exports.Balloon = Balloon;
1992
+ exports.BattleOfGiants = BattleOfGiants;
1901
1993
  exports.CodeforcesGymGhostDATConverter = CodeforcesGymGhostDATConverter;
1902
1994
  exports.Contest = Contest;
1903
1995
  exports.ContestIndex = ContestIndex;
1904
1996
  exports.ContestIndexConfig = ContestIndexConfig;
1905
1997
  exports.ContestOptions = ContestOptions;
1906
1998
  exports.GeneralExcelConverter = GeneralExcelConverter;
1999
+ exports.Giants = Giants;
2000
+ exports.GiantsType = GiantsType;
1907
2001
  exports.ICPCStandingsCsvConverter = ICPCStandingsCsvConverter;
1908
2002
  exports.MedalType = MedalType;
1909
2003
  exports.PlaceChartPointData = PlaceChartPointData;
package/dist/index.d.ts CHANGED
@@ -244,6 +244,37 @@ interface SelectOptionItem {
244
244
  value: string;
245
245
  text: string;
246
246
  }
247
+
248
+ declare enum GiantsType {
249
+ BLUE = 0,
250
+ RED = 1
251
+ }
252
+ declare class Giants {
253
+ type: GiantsType;
254
+ name: string;
255
+ filterOrganizations: Array<SelectOptionItem>;
256
+ filterOrganizationMap: Map<string, SelectOptionItem>;
257
+ filterTeams: Array<SelectOptionItem>;
258
+ filterTeamMap: Map<string, SelectOptionItem>;
259
+ teams: Array<Team>;
260
+ constructor(type?: GiantsType);
261
+ setFilterOrganizations(filterOrganizations: Array<SelectOptionItem>): void;
262
+ setFilterTeams(filterTeams: Array<SelectOptionItem>): void;
263
+ refreshName(): string;
264
+ get totalSolvedProblemNum(): number;
265
+ get totalPenalty(): number;
266
+ get totalPenaltyToString(): string;
267
+ }
268
+ declare class BattleOfGiants {
269
+ enable: boolean;
270
+ topX: number;
271
+ equalTeams: boolean;
272
+ persist: boolean;
273
+ blueTeam: Giants;
274
+ redTeam: Giants;
275
+ constructor();
276
+ }
277
+
247
278
  declare class RankOptions {
248
279
  enableFilterSubmissionsByTimestamp: boolean;
249
280
  width: number;
@@ -255,7 +286,9 @@ declare class RankOptions {
255
286
  filterTeams: Array<SelectOptionItem>;
256
287
  filterTeamMap: Map<string, SelectOptionItem>;
257
288
  enableAnimatedSubmissions: boolean;
289
+ battleOfGiants: BattleOfGiants;
258
290
  constructor();
291
+ setSelf(self: RankOptions): void;
259
292
  setWidth(width: number, contest: Contest): void;
260
293
  disableFilterSubmissionByTimestamp(): void;
261
294
  setGroup(group: string): void;
@@ -356,4 +389,4 @@ declare function isRejected(status: SubmissionStatus): boolean;
356
389
  declare function isPending(status: SubmissionStatus): boolean;
357
390
  declare function isNotCalculatedPenaltyStatus(status: SubmissionStatus): boolean;
358
391
 
359
- export { Award, Awards, Balloon, Balloons, CodeforcesGymGhostDATConverter, Contest, ContestIndex, ContestIndexConfig, ContestIndexList, ContestOptions, GeneralExcelConverter, ICPCStandingsCsvConverter, MedalType, PlaceChartPointData, Problem, ProblemStatistics, Problems, Rank, RankOptions, RankStatistics, Resolver, SelectOptionItem, Submission, Submissions, Team, TeamProblemStatistics, Teams, calcDirt, createContest, createContestIndex, createContestIndexList, createDayJS, createProblem, createProblems, createProblemsByProblemIds, createSubmission, createSubmissions, createTeam, createTeams, getImageSource, getTimeDiff, getTimestamp, getWhiteOrBlackColor, getWhiteOrBlackColorV1, isAccepted, isNotCalculatedPenaltyStatus, isPending, isRejected, isValidMedalType, stringToSubmissionStatus };
392
+ export { Award, Awards, Balloon, Balloons, BattleOfGiants, CodeforcesGymGhostDATConverter, Contest, ContestIndex, ContestIndexConfig, ContestIndexList, ContestOptions, GeneralExcelConverter, Giants, GiantsType, ICPCStandingsCsvConverter, MedalType, PlaceChartPointData, Problem, ProblemStatistics, Problems, Rank, RankOptions, RankStatistics, Resolver, SelectOptionItem, Submission, Submissions, Team, TeamProblemStatistics, Teams, calcDirt, createContest, createContestIndex, createContestIndexList, createDayJS, createProblem, createProblems, createProblemsByProblemIds, createSubmission, createSubmissions, createTeam, createTeams, getImageSource, getTimeDiff, getTimestamp, getWhiteOrBlackColor, getWhiteOrBlackColorV1, isAccepted, isNotCalculatedPenaltyStatus, isPending, isRejected, isValidMedalType, stringToSubmissionStatus };
package/dist/index.mjs CHANGED
@@ -1010,6 +1010,83 @@ class Balloon {
1010
1010
  }
1011
1011
  }
1012
1012
 
1013
+ var GiantsType = /* @__PURE__ */ ((GiantsType2) => {
1014
+ GiantsType2[GiantsType2["BLUE"] = 0] = "BLUE";
1015
+ GiantsType2[GiantsType2["RED"] = 1] = "RED";
1016
+ return GiantsType2;
1017
+ })(GiantsType || {});
1018
+ class Giants {
1019
+ constructor(type = 0 /* BLUE */) {
1020
+ this.type = type;
1021
+ this.name = `${type === 0 /* BLUE */ ? "Blue" : "Red"} Team`;
1022
+ this.teams = [];
1023
+ this.filterOrganizations = [];
1024
+ this.filterOrganizationMap = /* @__PURE__ */ new Map();
1025
+ this.filterTeams = [];
1026
+ this.filterTeamMap = /* @__PURE__ */ new Map();
1027
+ }
1028
+ setFilterOrganizations(filterOrganizations) {
1029
+ const m = /* @__PURE__ */ new Map();
1030
+ filterOrganizations.forEach((item) => {
1031
+ m.set(item.value, item);
1032
+ });
1033
+ this.filterOrganizations = filterOrganizations;
1034
+ this.filterOrganizationMap = m;
1035
+ }
1036
+ setFilterTeams(filterTeams) {
1037
+ const m = /* @__PURE__ */ new Map();
1038
+ filterTeams.forEach((item) => {
1039
+ m.set(item.value, item);
1040
+ });
1041
+ this.filterTeams = filterTeams;
1042
+ this.filterTeamMap = m;
1043
+ }
1044
+ refreshName() {
1045
+ if (this.filterOrganizations.length > 0) {
1046
+ this.name = this.filterOrganizations[0].text;
1047
+ } else {
1048
+ this.name = `${this.type === 0 /* BLUE */ ? "Blue" : "Red"} Team`;
1049
+ }
1050
+ return this.name;
1051
+ }
1052
+ get totalSolvedProblemNum() {
1053
+ let total = 0;
1054
+ this.teams.forEach((team) => {
1055
+ total += team.solvedProblemNum;
1056
+ });
1057
+ return total;
1058
+ }
1059
+ get totalPenalty() {
1060
+ let total = 0;
1061
+ this.teams.forEach((team) => {
1062
+ total += team.penaltyToMinute;
1063
+ });
1064
+ return total;
1065
+ }
1066
+ get totalPenaltyToString() {
1067
+ const penalty = this.totalPenalty;
1068
+ const two = (a) => {
1069
+ if (a < 10) {
1070
+ return `0${a}`;
1071
+ }
1072
+ return String(a);
1073
+ };
1074
+ const h = Math.floor(penalty / 60);
1075
+ const m = Math.floor(penalty % 60);
1076
+ return [two(h), two(m)].join(":");
1077
+ }
1078
+ }
1079
+ class BattleOfGiants {
1080
+ constructor() {
1081
+ this.enable = false;
1082
+ this.topX = 5;
1083
+ this.equalTeams = true;
1084
+ this.persist = false;
1085
+ this.blueTeam = new Giants(0 /* BLUE */);
1086
+ this.redTeam = new Giants(1 /* RED */);
1087
+ }
1088
+ }
1089
+
1013
1090
  class Group {
1014
1091
  constructor() {
1015
1092
  this.names = /* @__PURE__ */ new Map();
@@ -1369,6 +1446,20 @@ class RankOptions {
1369
1446
  this.filterTeams = [];
1370
1447
  this.filterTeamMap = /* @__PURE__ */ new Map();
1371
1448
  this.enableAnimatedSubmissions = false;
1449
+ this.battleOfGiants = new BattleOfGiants();
1450
+ }
1451
+ setSelf(self) {
1452
+ this.enableFilterSubmissionsByTimestamp = self.enableFilterSubmissionsByTimestamp;
1453
+ this.width = self.width;
1454
+ this.timestamp = self.timestamp;
1455
+ this.enableFilterTeamsByGroup = self.enableFilterTeamsByGroup;
1456
+ this.group = self.group;
1457
+ this.filterOrganizations = self.filterOrganizations;
1458
+ this.filterOrganizationMap = self.filterOrganizationMap;
1459
+ this.filterTeams = self.filterTeams;
1460
+ this.filterTeamMap = self.filterTeamMap;
1461
+ this.enableAnimatedSubmissions = self.enableAnimatedSubmissions;
1462
+ this.battleOfGiants = self.battleOfGiants;
1372
1463
  }
1373
1464
  setWidth(width, contest) {
1374
1465
  this.width = width;
@@ -1862,4 +1953,4 @@ class Resolver extends Rank {
1862
1953
  }
1863
1954
  }
1864
1955
 
1865
- export { Award, Balloon, CodeforcesGymGhostDATConverter, Contest, ContestIndex, ContestIndexConfig, ContestOptions, GeneralExcelConverter, ICPCStandingsCsvConverter, MedalType, PlaceChartPointData, Problem, ProblemStatistics, Rank, RankOptions, RankStatistics, Resolver, Submission, Team, TeamProblemStatistics, calcDirt, createContest, createContestIndex, createContestIndexList, createDayJS, createProblem, createProblems, createProblemsByProblemIds, createSubmission, createSubmissions, createTeam, createTeams, getImageSource, getTimeDiff, getTimestamp, getWhiteOrBlackColor, getWhiteOrBlackColorV1, isAccepted, isNotCalculatedPenaltyStatus, isPending, isRejected, isValidMedalType, stringToSubmissionStatus };
1956
+ export { Award, Balloon, BattleOfGiants, CodeforcesGymGhostDATConverter, Contest, ContestIndex, ContestIndexConfig, ContestOptions, GeneralExcelConverter, Giants, GiantsType, ICPCStandingsCsvConverter, MedalType, PlaceChartPointData, Problem, ProblemStatistics, Rank, RankOptions, RankStatistics, Resolver, Submission, Team, TeamProblemStatistics, calcDirt, createContest, createContestIndex, createContestIndexList, createDayJS, createProblem, createProblems, createProblemsByProblemIds, createSubmission, createSubmissions, createTeam, createTeams, getImageSource, getTimeDiff, getTimestamp, getWhiteOrBlackColor, getWhiteOrBlackColorV1, isAccepted, isNotCalculatedPenaltyStatus, isPending, isRejected, isValidMedalType, stringToSubmissionStatus };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xcpcio/core",
3
- "version": "0.42.0",
3
+ "version": "0.43.0",
4
4
  "description": "XCPCIO Core",
5
5
  "author": "Dup4 <lyuzhi.pan@gmail.com>",
6
6
  "license": "MIT",
@@ -48,7 +48,7 @@
48
48
  "papaparse": "^5.4.1",
49
49
  "string-width": "^6.1.0",
50
50
  "xlsx-js-style": "^1.2.0",
51
- "@xcpcio/types": "0.42.0"
51
+ "@xcpcio/types": "0.43.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@babel/types": "^7.22.4",
@@ -0,0 +1,4 @@
1
+ export interface SelectOptionItem {
2
+ value: string;
3
+ text: string;
4
+ }
@@ -0,0 +1,112 @@
1
+ import { type SelectOptionItem } from "./basic-types";
2
+ import type { Team } from "./team";
3
+
4
+ export enum GiantsType {
5
+ BLUE,
6
+ RED,
7
+ }
8
+
9
+ export class Giants {
10
+ type: GiantsType;
11
+ name: string;
12
+
13
+ filterOrganizations: Array<SelectOptionItem>;
14
+ filterOrganizationMap: Map<string, SelectOptionItem>;
15
+ filterTeams: Array<SelectOptionItem>;
16
+ filterTeamMap: Map<string, SelectOptionItem>;
17
+
18
+ teams: Array<Team>;
19
+
20
+ constructor(type: GiantsType = GiantsType.BLUE) {
21
+ this.type = type;
22
+ this.name = `${type === GiantsType.BLUE ? "Blue" : "Red"} Team`;
23
+ this.teams = [];
24
+
25
+ this.filterOrganizations = [];
26
+ this.filterOrganizationMap = new Map<string, SelectOptionItem>();
27
+ this.filterTeams = [];
28
+ this.filterTeamMap = new Map<string, SelectOptionItem>();
29
+ }
30
+
31
+ setFilterOrganizations(filterOrganizations: Array<SelectOptionItem>) {
32
+ const m = new Map<string, SelectOptionItem>();
33
+ filterOrganizations.forEach((item) => {
34
+ m.set(item.value, item);
35
+ });
36
+
37
+ this.filterOrganizations = filterOrganizations;
38
+ this.filterOrganizationMap = m;
39
+ }
40
+
41
+ setFilterTeams(filterTeams: Array<SelectOptionItem>) {
42
+ const m = new Map<string, SelectOptionItem>();
43
+ filterTeams.forEach((item) => {
44
+ m.set(item.value, item);
45
+ });
46
+
47
+ this.filterTeams = filterTeams;
48
+ this.filterTeamMap = m;
49
+ }
50
+
51
+ refreshName() {
52
+ if (this.filterOrganizations.length > 0) {
53
+ this.name = this.filterOrganizations[0].text;
54
+ } else {
55
+ this.name = `${this.type === GiantsType.BLUE ? "Blue" : "Red"} Team`;
56
+ }
57
+
58
+ return this.name;
59
+ }
60
+
61
+ get totalSolvedProblemNum(): number {
62
+ let total = 0;
63
+ this.teams.forEach((team) => {
64
+ total += team.solvedProblemNum;
65
+ });
66
+ return total;
67
+ }
68
+
69
+ get totalPenalty(): number {
70
+ let total = 0;
71
+ this.teams.forEach((team) => {
72
+ total += team.penaltyToMinute;
73
+ });
74
+ return total;
75
+ }
76
+
77
+ get totalPenaltyToString(): string {
78
+ const penalty = this.totalPenalty;
79
+ const two = (a: number) => {
80
+ if (a < 10) {
81
+ return `0${a}`;
82
+ }
83
+
84
+ return String(a);
85
+ };
86
+
87
+ const h = Math.floor(penalty / 60);
88
+ const m = Math.floor(penalty % 60);
89
+
90
+ return [two(h), two(m)].join(":");
91
+ }
92
+ }
93
+
94
+ export class BattleOfGiants {
95
+ enable: boolean;
96
+ topX: number;
97
+ equalTeams: boolean;
98
+ persist: boolean;
99
+
100
+ blueTeam: Giants;
101
+ redTeam: Giants;
102
+
103
+ constructor() {
104
+ this.enable = false;
105
+ this.topX = 5;
106
+ this.equalTeams = true;
107
+ this.persist = false;
108
+
109
+ this.blueTeam = new Giants(GiantsType.BLUE);
110
+ this.redTeam = new Giants(GiantsType.RED);
111
+ }
112
+ }
package/src/index.ts CHANGED
@@ -3,6 +3,8 @@ export * from "./utils";
3
3
 
4
4
  export * from "./award";
5
5
  export * from "./balloon";
6
+ export * from "./basic-types";
7
+ export * from "./battle-of-giants";
6
8
  export * from "./contest-index";
7
9
  export * from "./contest";
8
10
  export * from "./image";
package/src/rank.ts CHANGED
@@ -11,11 +11,8 @@ import { TeamProblemStatistics } from "./problem";
11
11
  import { RankStatistics } from "./rank-statistics";
12
12
  import { Balloon, type Balloons } from "./balloon";
13
13
  import { Award, MedalType } from "./award";
14
-
15
- export interface SelectOptionItem {
16
- value: string;
17
- text: string;
18
- }
14
+ import { type SelectOptionItem } from "./basic-types";
15
+ import { BattleOfGiants } from "./battle-of-giants";
19
16
 
20
17
  export class RankOptions {
21
18
  enableFilterSubmissionsByTimestamp: boolean;
@@ -32,6 +29,8 @@ export class RankOptions {
32
29
 
33
30
  enableAnimatedSubmissions: boolean;
34
31
 
32
+ battleOfGiants: BattleOfGiants;
33
+
35
34
  constructor() {
36
35
  this.enableFilterSubmissionsByTimestamp = false;
37
36
  this.width = 0;
@@ -47,6 +46,27 @@ export class RankOptions {
47
46
  this.filterTeamMap = new Map<string, SelectOptionItem>();
48
47
 
49
48
  this.enableAnimatedSubmissions = false;
49
+
50
+ this.battleOfGiants = new BattleOfGiants();
51
+ }
52
+
53
+ setSelf(self: RankOptions) {
54
+ this.enableFilterSubmissionsByTimestamp = self.enableFilterSubmissionsByTimestamp;
55
+ this.width = self.width;
56
+ this.timestamp = self.timestamp;
57
+
58
+ this.enableFilterTeamsByGroup = self.enableFilterTeamsByGroup;
59
+ this.group = self.group;
60
+
61
+ this.filterOrganizations = self.filterOrganizations;
62
+ this.filterOrganizationMap = self.filterOrganizationMap;
63
+
64
+ this.filterTeams = self.filterTeams;
65
+ this.filterTeamMap = self.filterTeamMap;
66
+
67
+ this.enableAnimatedSubmissions = self.enableAnimatedSubmissions;
68
+
69
+ this.battleOfGiants = self.battleOfGiants;
50
70
  }
51
71
 
52
72
  setWidth(width: number, contest: Contest) {