tods-competition-factory 1.2.26 → 1.2.28
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/forge/generate.mjs +135 -37
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/index.mjs +144 -39
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +183 -33
- package/dist/tods-competition-factory.development.cjs.js.map +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js.map +1 -1
- package/package.json +5 -5
package/dist/forge/generate.mjs
CHANGED
|
@@ -16019,6 +16019,60 @@ function processOutcome({
|
|
|
16019
16019
|
}
|
|
16020
16020
|
}
|
|
16021
16021
|
|
|
16022
|
+
function getTallyReport({ matchUps, order, report }) {
|
|
16023
|
+
const participants = {};
|
|
16024
|
+
matchUps.forEach(({ sides }) => {
|
|
16025
|
+
sides.forEach((side) => {
|
|
16026
|
+
if (side.participantId && side.participant) {
|
|
16027
|
+
participants[side.participantId] = side.participant.participantName;
|
|
16028
|
+
}
|
|
16029
|
+
});
|
|
16030
|
+
});
|
|
16031
|
+
const readable = [];
|
|
16032
|
+
if (Array.isArray(report)) {
|
|
16033
|
+
report.forEach((step, i) => {
|
|
16034
|
+
var _a;
|
|
16035
|
+
if ((_a = step.excludedDirectives) == null ? void 0 : _a.length) {
|
|
16036
|
+
const attributes = step.excludedDirectives.map(({ attribute }) => attribute).join(", ");
|
|
16037
|
+
const note = `${attributes.length} directives were excluded due to participants limit}`;
|
|
16038
|
+
readable.push(note);
|
|
16039
|
+
const excluded = `Excluded: ${attributes}`;
|
|
16040
|
+
readable.push(excluded);
|
|
16041
|
+
} else {
|
|
16042
|
+
const floatSort = (a, b) => parseFloat(step.reversed ? a : b) - parseFloat(step.reversed ? b : a);
|
|
16043
|
+
const getExplanation = (step2) => {
|
|
16044
|
+
Object.keys(step2.groups).sort(floatSort).forEach((key) => {
|
|
16045
|
+
const participantNames = step2.groups[key].map((participantId) => participants[participantId]).join(", ");
|
|
16046
|
+
const explanation = `${key} ${step2.attribute}: ${participantNames}`;
|
|
16047
|
+
readable.push(explanation);
|
|
16048
|
+
});
|
|
16049
|
+
};
|
|
16050
|
+
const reversed = step.reversed ? " in reverse order" : "";
|
|
16051
|
+
const participantsCount = Object.values(step.groups).flat(
|
|
16052
|
+
Infinity
|
|
16053
|
+
).length;
|
|
16054
|
+
const description = `Step ${i + 1}: ${participantsCount} particiants were grouped${reversed} by ${step.attribute}`;
|
|
16055
|
+
readable.push(description);
|
|
16056
|
+
if (step.idsFilter) {
|
|
16057
|
+
const note = `${step.attribute} was calculated considering ONLY TIED PARTICIPANTS`;
|
|
16058
|
+
readable.push(note);
|
|
16059
|
+
}
|
|
16060
|
+
getExplanation(step);
|
|
16061
|
+
}
|
|
16062
|
+
readable.push("----------------------");
|
|
16063
|
+
});
|
|
16064
|
+
}
|
|
16065
|
+
readable.push("Final Order:");
|
|
16066
|
+
order.forEach((orderEntry) => {
|
|
16067
|
+
const { participantId, resolved } = orderEntry;
|
|
16068
|
+
const pOrder = orderEntry.groupOrder || orderEntry.provisionalOrder;
|
|
16069
|
+
readable.push(
|
|
16070
|
+
`${pOrder}: ${participants[participantId]} => resolved: ${resolved}`
|
|
16071
|
+
);
|
|
16072
|
+
});
|
|
16073
|
+
return readable.join("\r\n");
|
|
16074
|
+
}
|
|
16075
|
+
|
|
16022
16076
|
var __defProp$C = Object.defineProperty;
|
|
16023
16077
|
var __getOwnPropSymbols$C = Object.getOwnPropertySymbols;
|
|
16024
16078
|
var __hasOwnProp$C = Object.prototype.hasOwnProperty;
|
|
@@ -16063,8 +16117,9 @@ function getGroupOrder(params) {
|
|
|
16063
16117
|
subOrderMap,
|
|
16064
16118
|
tallyPolicy
|
|
16065
16119
|
} = params;
|
|
16120
|
+
const report = [];
|
|
16066
16121
|
if (requireCompletion && !isComplete(params))
|
|
16067
|
-
return;
|
|
16122
|
+
return {};
|
|
16068
16123
|
const attribute = [
|
|
16069
16124
|
"tieMatchUpsWon",
|
|
16070
16125
|
"tieSinglesWon",
|
|
@@ -16082,7 +16137,12 @@ function getGroupOrder(params) {
|
|
|
16082
16137
|
participantResults,
|
|
16083
16138
|
attribute
|
|
16084
16139
|
});
|
|
16085
|
-
|
|
16140
|
+
report.push({ attribute, groups: orderedTallyGroups });
|
|
16141
|
+
const groupOrder = Object.keys(orderedTallyGroups).map((key) => parseFloat(key)).sort((a, b) => b - a).map((key) => orderedTallyGroups[key]).map((participantIds) => {
|
|
16142
|
+
const result = groupSubSort(__spreadValues$C({ participantIds }, params));
|
|
16143
|
+
report.push(result.report);
|
|
16144
|
+
return result.order;
|
|
16145
|
+
}).flat(Infinity);
|
|
16086
16146
|
let groupPosition = 1;
|
|
16087
16147
|
let priorPositionResolution;
|
|
16088
16148
|
groupOrder.forEach((finishingPosition, index) => {
|
|
@@ -16120,7 +16180,7 @@ function getGroupOrder(params) {
|
|
|
16120
16180
|
finishingPosition.groupOrder = position + (finishingPosition.subOrder || 1) - 1;
|
|
16121
16181
|
}
|
|
16122
16182
|
});
|
|
16123
|
-
return groupOrder;
|
|
16183
|
+
return { groupOrder, report: report.flat(Infinity).filter(Boolean) };
|
|
16124
16184
|
function getRatioHash(result) {
|
|
16125
16185
|
const attributes = Array.isArray(tallyPolicy == null ? void 0 : tallyPolicy.GEMscore) ? Object.keys(GEMScoreValueMap).filter(
|
|
16126
16186
|
(attribute2) => tallyPolicy.GEMscore.includes(attribute2)
|
|
@@ -16160,9 +16220,11 @@ function processAttribute({
|
|
|
16160
16220
|
participantIds,
|
|
16161
16221
|
attribute
|
|
16162
16222
|
});
|
|
16223
|
+
const report = [{ attribute, reversed, groups, idsFilter }];
|
|
16224
|
+
let order;
|
|
16163
16225
|
if (Object.keys(groups).length > 1 && participantIds.length) {
|
|
16164
|
-
|
|
16165
|
-
|
|
16226
|
+
order = Object.keys(groups).map((key) => parseFloat(key)).sort((a, b) => reversed ? a - b : b - a).map((key) => groups[key]).map((participantIds2) => {
|
|
16227
|
+
const result = groupSubSort({
|
|
16166
16228
|
participantResults,
|
|
16167
16229
|
disableHeadToHead,
|
|
16168
16230
|
participantIds: participantIds2,
|
|
@@ -16170,8 +16232,11 @@ function processAttribute({
|
|
|
16170
16232
|
tallyPolicy,
|
|
16171
16233
|
matchUps
|
|
16172
16234
|
});
|
|
16235
|
+
report.push(result.report);
|
|
16236
|
+
return result.order;
|
|
16173
16237
|
}).flat(Infinity);
|
|
16174
16238
|
}
|
|
16239
|
+
return { order, report };
|
|
16175
16240
|
}
|
|
16176
16241
|
function groupSubSort({
|
|
16177
16242
|
participantResults,
|
|
@@ -16181,35 +16246,51 @@ function groupSubSort({
|
|
|
16181
16246
|
tallyPolicy,
|
|
16182
16247
|
matchUps
|
|
16183
16248
|
}) {
|
|
16184
|
-
if ((participantIds == null ? void 0 : participantIds.length) === 1)
|
|
16185
|
-
|
|
16249
|
+
if ((participantIds == null ? void 0 : participantIds.length) === 1) {
|
|
16250
|
+
const participantId = participantIds[0];
|
|
16251
|
+
return {
|
|
16252
|
+
order: [{ resolved: true, participantId }]
|
|
16253
|
+
};
|
|
16254
|
+
}
|
|
16186
16255
|
if ((participantIds == null ? void 0 : participantIds.length) === 2 && (!(tallyPolicy == null ? void 0 : tallyPolicy.headToHead) || !tallyPolicy.headToHead.disabled && !disableHeadToHead)) {
|
|
16187
16256
|
const result2 = headToHeadWinner({ participantIds, participantResults });
|
|
16188
16257
|
if (result2)
|
|
16189
|
-
return result2;
|
|
16258
|
+
return { order: [result2], headToHeadWinner: result2[0].participantId };
|
|
16190
16259
|
}
|
|
16260
|
+
const directives = (tallyPolicy == null ? void 0 : tallyPolicy.tallyDirectives) || headToHeadTallyDirectives;
|
|
16261
|
+
const excludedDirectives = [];
|
|
16262
|
+
const report = [];
|
|
16191
16263
|
let result;
|
|
16192
|
-
|
|
16193
|
-
(
|
|
16194
|
-
|
|
16195
|
-
|
|
16196
|
-
|
|
16197
|
-
|
|
16198
|
-
|
|
16199
|
-
|
|
16200
|
-
|
|
16201
|
-
|
|
16202
|
-
|
|
16203
|
-
|
|
16204
|
-
|
|
16205
|
-
|
|
16206
|
-
|
|
16207
|
-
|
|
16208
|
-
|
|
16209
|
-
|
|
16210
|
-
|
|
16211
|
-
|
|
16212
|
-
|
|
16264
|
+
const filteredDirectives = directives.filter((directive) => {
|
|
16265
|
+
const keepDirective = isNumeric(directive.maxParticipants) && (participantIds == null ? void 0 : participantIds.length) > directive.maxParticipants ? false : true;
|
|
16266
|
+
if (!keepDirective)
|
|
16267
|
+
excludedDirectives.push(directive);
|
|
16268
|
+
return keepDirective;
|
|
16269
|
+
});
|
|
16270
|
+
if (excludedDirectives.length)
|
|
16271
|
+
report.push({ excludedDirectives, participantIds });
|
|
16272
|
+
filteredDirectives.every(
|
|
16273
|
+
({ attribute, reversed, idsFilter, disableHeadToHead: disableHeadToHead2 }) => {
|
|
16274
|
+
result = processAttribute({
|
|
16275
|
+
disableHeadToHead: disableHeadToHead2,
|
|
16276
|
+
participantIds,
|
|
16277
|
+
matchUpFormat,
|
|
16278
|
+
tallyPolicy,
|
|
16279
|
+
attribute,
|
|
16280
|
+
idsFilter,
|
|
16281
|
+
matchUps,
|
|
16282
|
+
reversed
|
|
16283
|
+
});
|
|
16284
|
+
report.push(result.report);
|
|
16285
|
+
return result.order ? false : true;
|
|
16286
|
+
}
|
|
16287
|
+
);
|
|
16288
|
+
if (result.order)
|
|
16289
|
+
return { order: result.order, report };
|
|
16290
|
+
return {
|
|
16291
|
+
order: participantIds == null ? void 0 : participantIds.map((participantId) => ({ participantId })),
|
|
16292
|
+
report
|
|
16293
|
+
};
|
|
16213
16294
|
}
|
|
16214
16295
|
function headToHeadWinner({ participantIds, participantResults }) {
|
|
16215
16296
|
if (!participantIds)
|
|
@@ -16248,6 +16329,7 @@ function getResultsArray({ participantResults, participantIds }) {
|
|
|
16248
16329
|
|
|
16249
16330
|
function tallyParticipantResults({
|
|
16250
16331
|
policyDefinitions,
|
|
16332
|
+
generateReport,
|
|
16251
16333
|
matchUpFormat,
|
|
16252
16334
|
matchUps = [],
|
|
16253
16335
|
subOrderMap,
|
|
@@ -16260,7 +16342,7 @@ function tallyParticipantResults({
|
|
|
16260
16342
|
[]
|
|
16261
16343
|
);
|
|
16262
16344
|
if (structureIds.length !== 1)
|
|
16263
|
-
return { error: INVALID_VALUES };
|
|
16345
|
+
return { error: INVALID_VALUES, info: "Maximum one structureId" };
|
|
16264
16346
|
const relevantMatchUps = matchUps.filter(
|
|
16265
16347
|
(matchUp) => matchUp && matchUp.matchUpStatus !== BYE
|
|
16266
16348
|
);
|
|
@@ -16278,7 +16360,8 @@ function tallyParticipantResults({
|
|
|
16278
16360
|
tallyPolicy,
|
|
16279
16361
|
perPlayer
|
|
16280
16362
|
});
|
|
16281
|
-
|
|
16363
|
+
let report, order;
|
|
16364
|
+
const { groupOrder, report: groupOrderReport } = getGroupOrder({
|
|
16282
16365
|
matchUps: consideredMatchUps,
|
|
16283
16366
|
participantResults,
|
|
16284
16367
|
participantsCount,
|
|
@@ -16287,6 +16370,8 @@ function tallyParticipantResults({
|
|
|
16287
16370
|
subOrderMap
|
|
16288
16371
|
});
|
|
16289
16372
|
if (bracketComplete && groupOrder) {
|
|
16373
|
+
report = groupOrderReport;
|
|
16374
|
+
order = groupOrder;
|
|
16290
16375
|
groupOrder.forEach((finishingPosition) => {
|
|
16291
16376
|
const { participantId, groupOrder: groupOrder2, rankOrder, subOrder, ties, GEMscore } = finishingPosition;
|
|
16292
16377
|
const participantResult = participantResults[participantId];
|
|
@@ -16299,7 +16384,7 @@ function tallyParticipantResults({
|
|
|
16299
16384
|
});
|
|
16300
16385
|
});
|
|
16301
16386
|
} else {
|
|
16302
|
-
const
|
|
16387
|
+
const { groupOrder: provisionalOrder, report: provisionalOrderReport } = getGroupOrder({
|
|
16303
16388
|
requireCompletion: false,
|
|
16304
16389
|
participantResults,
|
|
16305
16390
|
participantsCount,
|
|
@@ -16308,8 +16393,10 @@ function tallyParticipantResults({
|
|
|
16308
16393
|
subOrderMap,
|
|
16309
16394
|
matchUps
|
|
16310
16395
|
});
|
|
16311
|
-
|
|
16312
|
-
|
|
16396
|
+
report = provisionalOrderReport;
|
|
16397
|
+
order = provisionalOrder;
|
|
16398
|
+
if (provisionalOrder) {
|
|
16399
|
+
provisionalOrder.forEach((finishingPosition) => {
|
|
16313
16400
|
const { participantId, groupOrder: groupOrder2, GEMscore } = finishingPosition;
|
|
16314
16401
|
const participantResult = participantResults[participantId];
|
|
16315
16402
|
Object.assign(participantResult, {
|
|
@@ -16319,7 +16406,14 @@ function tallyParticipantResults({
|
|
|
16319
16406
|
});
|
|
16320
16407
|
}
|
|
16321
16408
|
}
|
|
16322
|
-
|
|
16409
|
+
const result = { participantResults, bracketComplete, report };
|
|
16410
|
+
if (generateReport || getDevContext({ tally: true })) {
|
|
16411
|
+
const readable = getTallyReport({ matchUps, report, order });
|
|
16412
|
+
if (getDevContext({ tally: true }))
|
|
16413
|
+
console.log(readable);
|
|
16414
|
+
result.readableReport = readable;
|
|
16415
|
+
}
|
|
16416
|
+
return result;
|
|
16323
16417
|
}
|
|
16324
16418
|
|
|
16325
16419
|
const hasParticipantId = (o) => o == null ? void 0 : o.participantId;
|
|
@@ -16391,7 +16485,7 @@ function updateAssignmentParticipantResults({
|
|
|
16391
16485
|
});
|
|
16392
16486
|
if (result.error)
|
|
16393
16487
|
return result;
|
|
16394
|
-
const { participantResults, bracketComplete } = result;
|
|
16488
|
+
const { participantResults, bracketComplete, report } = result;
|
|
16395
16489
|
const participantIds = Object.keys(participantResults);
|
|
16396
16490
|
positionAssignments.forEach((assignment) => {
|
|
16397
16491
|
const { participantId } = assignment;
|
|
@@ -16419,7 +16513,11 @@ function updateAssignmentParticipantResults({
|
|
|
16419
16513
|
}
|
|
16420
16514
|
});
|
|
16421
16515
|
modifyDrawNotice({ drawDefinition });
|
|
16422
|
-
return __spreadProps$j(__spreadValues$B({}, SUCCESS), {
|
|
16516
|
+
return __spreadProps$j(__spreadValues$B({}, SUCCESS), {
|
|
16517
|
+
participantResults,
|
|
16518
|
+
bracketComplete,
|
|
16519
|
+
report
|
|
16520
|
+
});
|
|
16423
16521
|
}
|
|
16424
16522
|
|
|
16425
16523
|
const toBePlayed = {
|