@xcpcio/core 0.42.1 → 0.44.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
@@ -19,6 +19,7 @@ const Papa = require('papaparse');
19
19
  const ordinal = require('ordinal');
20
20
  const chroma = require('chroma-js');
21
21
  const colorDiff = require('color-diff');
22
+ const jsBase64 = require('js-base64');
22
23
 
23
24
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
24
25
 
@@ -1043,6 +1044,115 @@ class Balloon {
1043
1044
  }
1044
1045
  }
1045
1046
 
1047
+ var GiantsType = /* @__PURE__ */ ((GiantsType2) => {
1048
+ GiantsType2[GiantsType2["BLUE"] = 0] = "BLUE";
1049
+ GiantsType2[GiantsType2["RED"] = 1] = "RED";
1050
+ return GiantsType2;
1051
+ })(GiantsType || {});
1052
+ class Giants {
1053
+ constructor(type = 0 /* BLUE */) {
1054
+ this.type = type;
1055
+ this.name = `${type === 0 /* BLUE */ ? "Blue" : "Red"} Team`;
1056
+ this.teams = [];
1057
+ this.filterOrganizations = [];
1058
+ this.filterOrganizationMap = /* @__PURE__ */ new Map();
1059
+ this.filterTeams = [];
1060
+ this.filterTeamMap = /* @__PURE__ */ new Map();
1061
+ }
1062
+ setFilterOrganizations(filterOrganizations) {
1063
+ const m = /* @__PURE__ */ new Map();
1064
+ filterOrganizations.forEach((item) => {
1065
+ m.set(item.value, item);
1066
+ });
1067
+ this.filterOrganizations = filterOrganizations;
1068
+ this.filterOrganizationMap = m;
1069
+ }
1070
+ setFilterTeams(filterTeams) {
1071
+ const m = /* @__PURE__ */ new Map();
1072
+ filterTeams.forEach((item) => {
1073
+ m.set(item.value, item);
1074
+ });
1075
+ this.filterTeams = filterTeams;
1076
+ this.filterTeamMap = m;
1077
+ }
1078
+ refreshName() {
1079
+ if (this.filterOrganizations.length > 0) {
1080
+ this.name = this.filterOrganizations[0].text;
1081
+ } else {
1082
+ this.name = `${this.type === 0 /* BLUE */ ? "Blue" : "Red"} Team`;
1083
+ }
1084
+ return this.name;
1085
+ }
1086
+ get totalSolvedProblemNum() {
1087
+ let total = 0;
1088
+ this.teams.forEach((team) => {
1089
+ total += team.solvedProblemNum;
1090
+ });
1091
+ return total;
1092
+ }
1093
+ get totalPenalty() {
1094
+ let total = 0;
1095
+ this.teams.forEach((team) => {
1096
+ total += team.penaltyToMinute;
1097
+ });
1098
+ return total;
1099
+ }
1100
+ get totalPenaltyToString() {
1101
+ const penalty = this.totalPenalty;
1102
+ const two = (a) => {
1103
+ if (a < 10) {
1104
+ return `0${a}`;
1105
+ }
1106
+ return String(a);
1107
+ };
1108
+ const h = Math.floor(penalty / 60);
1109
+ const m = Math.floor(penalty % 60);
1110
+ return [two(h), two(m)].join(":");
1111
+ }
1112
+ toJSON() {
1113
+ return {
1114
+ type: this.type,
1115
+ name: this.name,
1116
+ filterOrganizations: this.filterOrganizations,
1117
+ filterTeams: this.filterTeams
1118
+ };
1119
+ }
1120
+ }
1121
+ class BattleOfGiants {
1122
+ constructor() {
1123
+ this.enable = false;
1124
+ this.topX = 5;
1125
+ this.equalTeams = true;
1126
+ this.persist = false;
1127
+ this.blueTeam = new Giants(0 /* BLUE */);
1128
+ this.redTeam = new Giants(1 /* RED */);
1129
+ }
1130
+ ToBase64() {
1131
+ return jsBase64.Base64.encode(JSON.stringify(this));
1132
+ }
1133
+ FromBase64(base64) {
1134
+ if (base64.length === 0) {
1135
+ return;
1136
+ }
1137
+ if (jsBase64.Base64.isValid(base64) === false) {
1138
+ return;
1139
+ }
1140
+ const j = JSON.parse(jsBase64.Base64.decode(base64));
1141
+ this.enable = j.enable;
1142
+ this.topX = j.topX;
1143
+ this.equalTeams = j.equalTeams;
1144
+ this.persist = j.persist;
1145
+ this.blueTeam = new Giants(0 /* BLUE */);
1146
+ this.blueTeam.name = j.blueTeam.name;
1147
+ this.blueTeam.setFilterOrganizations(j.blueTeam.filterOrganizations);
1148
+ this.blueTeam.setFilterTeams(j.blueTeam.filterTeams);
1149
+ this.redTeam = new Giants(1 /* RED */);
1150
+ this.redTeam.name = j.redTeam.name;
1151
+ this.redTeam.setFilterOrganizations(j.redTeam.filterOrganizations);
1152
+ this.redTeam.setFilterTeams(j.redTeam.filterTeams);
1153
+ }
1154
+ }
1155
+
1046
1156
  class Group {
1047
1157
  constructor() {
1048
1158
  this.names = /* @__PURE__ */ new Map();
@@ -1402,6 +1512,20 @@ class RankOptions {
1402
1512
  this.filterTeams = [];
1403
1513
  this.filterTeamMap = /* @__PURE__ */ new Map();
1404
1514
  this.enableAnimatedSubmissions = false;
1515
+ this.battleOfGiants = new BattleOfGiants();
1516
+ }
1517
+ setSelf(self) {
1518
+ this.enableFilterSubmissionsByTimestamp = self.enableFilterSubmissionsByTimestamp;
1519
+ this.width = self.width;
1520
+ this.timestamp = self.timestamp;
1521
+ this.enableFilterTeamsByGroup = self.enableFilterTeamsByGroup;
1522
+ this.group = self.group;
1523
+ this.filterOrganizations = self.filterOrganizations;
1524
+ this.filterOrganizationMap = self.filterOrganizationMap;
1525
+ this.filterTeams = self.filterTeams;
1526
+ this.filterTeamMap = self.filterTeamMap;
1527
+ this.enableAnimatedSubmissions = self.enableAnimatedSubmissions;
1528
+ this.battleOfGiants = self.battleOfGiants;
1405
1529
  }
1406
1530
  setWidth(width, contest) {
1407
1531
  this.width = width;
@@ -1898,12 +2022,15 @@ class Resolver extends Rank {
1898
2022
  exports.dayjs = dayjs__default;
1899
2023
  exports.Award = Award;
1900
2024
  exports.Balloon = Balloon;
2025
+ exports.BattleOfGiants = BattleOfGiants;
1901
2026
  exports.CodeforcesGymGhostDATConverter = CodeforcesGymGhostDATConverter;
1902
2027
  exports.Contest = Contest;
1903
2028
  exports.ContestIndex = ContestIndex;
1904
2029
  exports.ContestIndexConfig = ContestIndexConfig;
1905
2030
  exports.ContestOptions = ContestOptions;
1906
2031
  exports.GeneralExcelConverter = GeneralExcelConverter;
2032
+ exports.Giants = Giants;
2033
+ exports.GiantsType = GiantsType;
1907
2034
  exports.ICPCStandingsCsvConverter = ICPCStandingsCsvConverter;
1908
2035
  exports.MedalType = MedalType;
1909
2036
  exports.PlaceChartPointData = PlaceChartPointData;
package/dist/index.d.ts CHANGED
@@ -244,6 +244,45 @@ 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
+ toJSON(): {
268
+ type: GiantsType;
269
+ name: string;
270
+ filterOrganizations: SelectOptionItem[];
271
+ filterTeams: SelectOptionItem[];
272
+ };
273
+ }
274
+ declare class BattleOfGiants {
275
+ enable: boolean;
276
+ topX: number;
277
+ equalTeams: boolean;
278
+ persist: boolean;
279
+ blueTeam: Giants;
280
+ redTeam: Giants;
281
+ constructor();
282
+ ToBase64(): string;
283
+ FromBase64(base64: string): void;
284
+ }
285
+
247
286
  declare class RankOptions {
248
287
  enableFilterSubmissionsByTimestamp: boolean;
249
288
  width: number;
@@ -255,7 +294,9 @@ declare class RankOptions {
255
294
  filterTeams: Array<SelectOptionItem>;
256
295
  filterTeamMap: Map<string, SelectOptionItem>;
257
296
  enableAnimatedSubmissions: boolean;
297
+ battleOfGiants: BattleOfGiants;
258
298
  constructor();
299
+ setSelf(self: RankOptions): void;
259
300
  setWidth(width: number, contest: Contest): void;
260
301
  disableFilterSubmissionByTimestamp(): void;
261
302
  setGroup(group: string): void;
@@ -356,4 +397,4 @@ declare function isRejected(status: SubmissionStatus): boolean;
356
397
  declare function isPending(status: SubmissionStatus): boolean;
357
398
  declare function isNotCalculatedPenaltyStatus(status: SubmissionStatus): boolean;
358
399
 
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 };
400
+ 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
@@ -16,6 +16,7 @@ import Papa from 'papaparse';
16
16
  import ordinal from 'ordinal';
17
17
  import chroma from 'chroma-js';
18
18
  import { furthest } from 'color-diff';
19
+ import { Base64 } from 'js-base64';
19
20
 
20
21
  function stringToSubmissionStatus(status) {
21
22
  status = status.toUpperCase().replace(" ", "_");
@@ -1010,6 +1011,115 @@ class Balloon {
1010
1011
  }
1011
1012
  }
1012
1013
 
1014
+ var GiantsType = /* @__PURE__ */ ((GiantsType2) => {
1015
+ GiantsType2[GiantsType2["BLUE"] = 0] = "BLUE";
1016
+ GiantsType2[GiantsType2["RED"] = 1] = "RED";
1017
+ return GiantsType2;
1018
+ })(GiantsType || {});
1019
+ class Giants {
1020
+ constructor(type = 0 /* BLUE */) {
1021
+ this.type = type;
1022
+ this.name = `${type === 0 /* BLUE */ ? "Blue" : "Red"} Team`;
1023
+ this.teams = [];
1024
+ this.filterOrganizations = [];
1025
+ this.filterOrganizationMap = /* @__PURE__ */ new Map();
1026
+ this.filterTeams = [];
1027
+ this.filterTeamMap = /* @__PURE__ */ new Map();
1028
+ }
1029
+ setFilterOrganizations(filterOrganizations) {
1030
+ const m = /* @__PURE__ */ new Map();
1031
+ filterOrganizations.forEach((item) => {
1032
+ m.set(item.value, item);
1033
+ });
1034
+ this.filterOrganizations = filterOrganizations;
1035
+ this.filterOrganizationMap = m;
1036
+ }
1037
+ setFilterTeams(filterTeams) {
1038
+ const m = /* @__PURE__ */ new Map();
1039
+ filterTeams.forEach((item) => {
1040
+ m.set(item.value, item);
1041
+ });
1042
+ this.filterTeams = filterTeams;
1043
+ this.filterTeamMap = m;
1044
+ }
1045
+ refreshName() {
1046
+ if (this.filterOrganizations.length > 0) {
1047
+ this.name = this.filterOrganizations[0].text;
1048
+ } else {
1049
+ this.name = `${this.type === 0 /* BLUE */ ? "Blue" : "Red"} Team`;
1050
+ }
1051
+ return this.name;
1052
+ }
1053
+ get totalSolvedProblemNum() {
1054
+ let total = 0;
1055
+ this.teams.forEach((team) => {
1056
+ total += team.solvedProblemNum;
1057
+ });
1058
+ return total;
1059
+ }
1060
+ get totalPenalty() {
1061
+ let total = 0;
1062
+ this.teams.forEach((team) => {
1063
+ total += team.penaltyToMinute;
1064
+ });
1065
+ return total;
1066
+ }
1067
+ get totalPenaltyToString() {
1068
+ const penalty = this.totalPenalty;
1069
+ const two = (a) => {
1070
+ if (a < 10) {
1071
+ return `0${a}`;
1072
+ }
1073
+ return String(a);
1074
+ };
1075
+ const h = Math.floor(penalty / 60);
1076
+ const m = Math.floor(penalty % 60);
1077
+ return [two(h), two(m)].join(":");
1078
+ }
1079
+ toJSON() {
1080
+ return {
1081
+ type: this.type,
1082
+ name: this.name,
1083
+ filterOrganizations: this.filterOrganizations,
1084
+ filterTeams: this.filterTeams
1085
+ };
1086
+ }
1087
+ }
1088
+ class BattleOfGiants {
1089
+ constructor() {
1090
+ this.enable = false;
1091
+ this.topX = 5;
1092
+ this.equalTeams = true;
1093
+ this.persist = false;
1094
+ this.blueTeam = new Giants(0 /* BLUE */);
1095
+ this.redTeam = new Giants(1 /* RED */);
1096
+ }
1097
+ ToBase64() {
1098
+ return Base64.encode(JSON.stringify(this));
1099
+ }
1100
+ FromBase64(base64) {
1101
+ if (base64.length === 0) {
1102
+ return;
1103
+ }
1104
+ if (Base64.isValid(base64) === false) {
1105
+ return;
1106
+ }
1107
+ const j = JSON.parse(Base64.decode(base64));
1108
+ this.enable = j.enable;
1109
+ this.topX = j.topX;
1110
+ this.equalTeams = j.equalTeams;
1111
+ this.persist = j.persist;
1112
+ this.blueTeam = new Giants(0 /* BLUE */);
1113
+ this.blueTeam.name = j.blueTeam.name;
1114
+ this.blueTeam.setFilterOrganizations(j.blueTeam.filterOrganizations);
1115
+ this.blueTeam.setFilterTeams(j.blueTeam.filterTeams);
1116
+ this.redTeam = new Giants(1 /* RED */);
1117
+ this.redTeam.name = j.redTeam.name;
1118
+ this.redTeam.setFilterOrganizations(j.redTeam.filterOrganizations);
1119
+ this.redTeam.setFilterTeams(j.redTeam.filterTeams);
1120
+ }
1121
+ }
1122
+
1013
1123
  class Group {
1014
1124
  constructor() {
1015
1125
  this.names = /* @__PURE__ */ new Map();
@@ -1369,6 +1479,20 @@ class RankOptions {
1369
1479
  this.filterTeams = [];
1370
1480
  this.filterTeamMap = /* @__PURE__ */ new Map();
1371
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;
1372
1496
  }
1373
1497
  setWidth(width, contest) {
1374
1498
  this.width = width;
@@ -1862,4 +1986,4 @@ class Resolver extends Rank {
1862
1986
  }
1863
1987
  }
1864
1988
 
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 };
1989
+ 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.1",
3
+ "version": "0.44.0",
4
4
  "description": "XCPCIO Core",
5
5
  "author": "Dup4 <lyuzhi.pan@gmail.com>",
6
6
  "license": "MIT",
@@ -43,12 +43,13 @@
43
43
  "chroma-js": "^2.4.2",
44
44
  "color-diff": "^1.4.0",
45
45
  "dayjs": "^1.11.8",
46
+ "js-base64": "^3.7.5",
46
47
  "lodash": "^4.17.21",
47
48
  "ordinal": "^1.0.3",
48
49
  "papaparse": "^5.4.1",
49
50
  "string-width": "^6.1.0",
50
51
  "xlsx-js-style": "^1.2.0",
51
- "@xcpcio/types": "0.42.1"
52
+ "@xcpcio/types": "0.44.0"
52
53
  },
53
54
  "devDependencies": {
54
55
  "@babel/types": "^7.22.4",
@@ -0,0 +1,4 @@
1
+ export interface SelectOptionItem {
2
+ value: string;
3
+ text: string;
4
+ }
@@ -0,0 +1,153 @@
1
+ import { Base64 } from "js-base64";
2
+ import { type SelectOptionItem } from "./basic-types";
3
+ import type { Team } from "./team";
4
+
5
+ export enum GiantsType {
6
+ BLUE,
7
+ RED,
8
+ }
9
+
10
+ export class Giants {
11
+ type: GiantsType;
12
+ name: string;
13
+
14
+ filterOrganizations: Array<SelectOptionItem>;
15
+ filterOrganizationMap: Map<string, SelectOptionItem>;
16
+ filterTeams: Array<SelectOptionItem>;
17
+ filterTeamMap: Map<string, SelectOptionItem>;
18
+
19
+ teams: Array<Team>;
20
+
21
+ constructor(type: GiantsType = GiantsType.BLUE) {
22
+ this.type = type;
23
+ this.name = `${type === GiantsType.BLUE ? "Blue" : "Red"} Team`;
24
+ this.teams = [];
25
+
26
+ this.filterOrganizations = [];
27
+ this.filterOrganizationMap = new Map<string, SelectOptionItem>();
28
+ this.filterTeams = [];
29
+ this.filterTeamMap = new Map<string, SelectOptionItem>();
30
+ }
31
+
32
+ setFilterOrganizations(filterOrganizations: Array<SelectOptionItem>) {
33
+ const m = new Map<string, SelectOptionItem>();
34
+ filterOrganizations.forEach((item) => {
35
+ m.set(item.value, item);
36
+ });
37
+
38
+ this.filterOrganizations = filterOrganizations;
39
+ this.filterOrganizationMap = m;
40
+ }
41
+
42
+ setFilterTeams(filterTeams: Array<SelectOptionItem>) {
43
+ const m = new Map<string, SelectOptionItem>();
44
+ filterTeams.forEach((item) => {
45
+ m.set(item.value, item);
46
+ });
47
+
48
+ this.filterTeams = filterTeams;
49
+ this.filterTeamMap = m;
50
+ }
51
+
52
+ refreshName() {
53
+ if (this.filterOrganizations.length > 0) {
54
+ this.name = this.filterOrganizations[0].text;
55
+ } else {
56
+ this.name = `${this.type === GiantsType.BLUE ? "Blue" : "Red"} Team`;
57
+ }
58
+
59
+ return this.name;
60
+ }
61
+
62
+ get totalSolvedProblemNum(): number {
63
+ let total = 0;
64
+ this.teams.forEach((team) => {
65
+ total += team.solvedProblemNum;
66
+ });
67
+ return total;
68
+ }
69
+
70
+ get totalPenalty(): number {
71
+ let total = 0;
72
+ this.teams.forEach((team) => {
73
+ total += team.penaltyToMinute;
74
+ });
75
+ return total;
76
+ }
77
+
78
+ get totalPenaltyToString(): string {
79
+ const penalty = this.totalPenalty;
80
+ const two = (a: number) => {
81
+ if (a < 10) {
82
+ return `0${a}`;
83
+ }
84
+
85
+ return String(a);
86
+ };
87
+
88
+ const h = Math.floor(penalty / 60);
89
+ const m = Math.floor(penalty % 60);
90
+
91
+ return [two(h), two(m)].join(":");
92
+ }
93
+
94
+ toJSON() {
95
+ return {
96
+ type: this.type,
97
+ name: this.name,
98
+ filterOrganizations: this.filterOrganizations,
99
+ filterTeams: this.filterTeams,
100
+ };
101
+ }
102
+ }
103
+
104
+ export class BattleOfGiants {
105
+ enable: boolean;
106
+ topX: number;
107
+ equalTeams: boolean;
108
+ persist: boolean;
109
+
110
+ blueTeam: Giants;
111
+ redTeam: Giants;
112
+
113
+ constructor() {
114
+ this.enable = false;
115
+ this.topX = 5;
116
+ this.equalTeams = true;
117
+ this.persist = false;
118
+
119
+ this.blueTeam = new Giants(GiantsType.BLUE);
120
+ this.redTeam = new Giants(GiantsType.RED);
121
+ }
122
+
123
+ ToBase64(): string {
124
+ return Base64.encode(JSON.stringify(this));
125
+ }
126
+
127
+ FromBase64(base64: string) {
128
+ if (base64.length === 0) {
129
+ return;
130
+ }
131
+
132
+ if (Base64.isValid(base64) === false) {
133
+ return;
134
+ }
135
+
136
+ const j = JSON.parse(Base64.decode(base64));
137
+
138
+ this.enable = j.enable;
139
+ this.topX = j.topX;
140
+ this.equalTeams = j.equalTeams;
141
+ this.persist = j.persist;
142
+
143
+ this.blueTeam = new Giants(GiantsType.BLUE);
144
+ this.blueTeam.name = j.blueTeam.name;
145
+ this.blueTeam.setFilterOrganizations(j.blueTeam.filterOrganizations);
146
+ this.blueTeam.setFilterTeams(j.blueTeam.filterTeams);
147
+
148
+ this.redTeam = new Giants(GiantsType.RED);
149
+ this.redTeam.name = j.redTeam.name;
150
+ this.redTeam.setFilterOrganizations(j.redTeam.filterOrganizations);
151
+ this.redTeam.setFilterTeams(j.redTeam.filterTeams);
152
+ }
153
+ }
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) {