tods-competition-factory 1.7.5 → 1.7.7
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 +41 -16
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.mjs +22 -14
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +22 -14
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/forge/utilities.mjs.map +1 -1
- package/dist/index.mjs +247 -81
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +275 -87
- 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 +6 -6
package/dist/forge/transform.mjs
CHANGED
|
@@ -3163,7 +3163,7 @@ const DECISIVE = "DECISIVE";
|
|
|
3163
3163
|
const POLICY_COMPETITIVE_BANDS_DEFAULT = {
|
|
3164
3164
|
[POLICY_TYPE_COMPETITIVE_BANDS]: {
|
|
3165
3165
|
policyName: "Competitive Bands Default",
|
|
3166
|
-
|
|
3166
|
+
profileBands: {
|
|
3167
3167
|
[DECISIVE]: 20,
|
|
3168
3168
|
[ROUTINE]: 50
|
|
3169
3169
|
}
|
|
@@ -3217,7 +3217,8 @@ function getCollectionPositionMatchUps({ matchUps }) {
|
|
|
3217
3217
|
|
|
3218
3218
|
const add = (a, b) => (a || 0) + (b || 0);
|
|
3219
3219
|
function getBand(spread, bandProfiles) {
|
|
3220
|
-
|
|
3220
|
+
const spreadValue = Array.isArray(spread) ? spread[0] : spread;
|
|
3221
|
+
return isNaN(spreadValue) && WALKOVER || spreadValue <= bandProfiles[DECISIVE] && DECISIVE || spreadValue <= bandProfiles[ROUTINE] && ROUTINE || COMPETITIVE;
|
|
3221
3222
|
}
|
|
3222
3223
|
function getScoreComponents({ score }) {
|
|
3223
3224
|
const sets = score?.sets || [];
|
|
@@ -3248,7 +3249,7 @@ function gamesPercent(scoreComponents) {
|
|
|
3248
3249
|
return Math.round(minGames / maxGames * 100);
|
|
3249
3250
|
}
|
|
3250
3251
|
function pctSpread(pcts) {
|
|
3251
|
-
return pcts.map(gamesPercent).sort().map((p) => p.toFixed(2));
|
|
3252
|
+
return pcts.map(gamesPercent).sort().map((p) => parseFloat(p.toFixed(2)));
|
|
3252
3253
|
}
|
|
3253
3254
|
|
|
3254
3255
|
function findPolicy({
|
|
@@ -3269,8 +3270,8 @@ function findPolicy({
|
|
|
3269
3270
|
return appliedPolicies?.[policyType] ? { policy: appliedPolicies[policyType] } : { error: POLICY_NOT_FOUND };
|
|
3270
3271
|
}
|
|
3271
3272
|
|
|
3272
|
-
function
|
|
3273
|
-
|
|
3273
|
+
function getMatchUpCompetitiveProfile({
|
|
3274
|
+
profileBands,
|
|
3274
3275
|
tournamentRecord,
|
|
3275
3276
|
matchUp
|
|
3276
3277
|
}) {
|
|
@@ -3279,15 +3280,16 @@ function getMatchUpCompetitiveness({
|
|
|
3279
3280
|
const { score, winningSide } = matchUp;
|
|
3280
3281
|
if (!winningSide)
|
|
3281
3282
|
return { error: INVALID_VALUES };
|
|
3282
|
-
const policy = !
|
|
3283
|
+
const policy = !profileBands && tournamentRecord && findPolicy({
|
|
3283
3284
|
policyType: POLICY_TYPE_COMPETITIVE_BANDS,
|
|
3284
3285
|
tournamentRecord
|
|
3285
3286
|
}).policy;
|
|
3286
|
-
const bandProfiles =
|
|
3287
|
+
const bandProfiles = profileBands || policy?.profileBands || POLICY_COMPETITIVE_BANDS_DEFAULT[POLICY_TYPE_COMPETITIVE_BANDS].profileBands;
|
|
3287
3288
|
const scoreComponents = getScoreComponents({ score });
|
|
3288
3289
|
const spread = pctSpread([scoreComponents]);
|
|
3289
3290
|
const competitiveness = getBand(spread, bandProfiles);
|
|
3290
|
-
|
|
3291
|
+
const pctSpreadValue = Array.isArray(spread) ? spread[0] : spread;
|
|
3292
|
+
return { ...SUCCESS, competitiveness, pctSpread: pctSpreadValue };
|
|
3291
3293
|
}
|
|
3292
3294
|
|
|
3293
3295
|
function findMatchupFormatAverageTimes(params) {
|
|
@@ -5570,6 +5572,9 @@ function isAdHoc({ drawDefinition, structure }) {
|
|
|
5570
5572
|
const POLICY_ROUND_NAMING_DEFAULT = {
|
|
5571
5573
|
[POLICY_TYPE_ROUND_NAMING]: {
|
|
5572
5574
|
policyName: "Round Naming Default",
|
|
5575
|
+
namingConventions: {
|
|
5576
|
+
round: "Round"
|
|
5577
|
+
},
|
|
5573
5578
|
abbreviatedRoundNamingMap: {
|
|
5574
5579
|
// key is matchUpsCount for the round
|
|
5575
5580
|
1: "F",
|
|
@@ -5609,6 +5614,9 @@ function getRoundContextProfile({
|
|
|
5609
5614
|
const roundNamingMap = roundNamingPolicy?.roundNamingMap || defaultRoundNamingPolicy.roundNamingMap || {};
|
|
5610
5615
|
const abbreviatedRoundNamingMap = roundNamingPolicy?.abbreviatedRoundNamingMap || defaultRoundNamingPolicy.abbreviatedRoundNamingMap || {};
|
|
5611
5616
|
const roundNamePrefix = roundNamingPolicy?.affixes || defaultRoundNamingPolicy.affixes;
|
|
5617
|
+
const roundNumberAffix = roundNamePrefix.roundNumber || defaultRoundNamingPolicy.affixes.roundNumber;
|
|
5618
|
+
const namingConventions = roundNamingPolicy?.namingConventions || defaultRoundNamingPolicy.namingConventions;
|
|
5619
|
+
const roundNameFallback = namingConventions.round;
|
|
5612
5620
|
const stageInitial = stage && stage !== MAIN && stage[0];
|
|
5613
5621
|
const stageConstants = roundNamingPolicy?.stageConstants;
|
|
5614
5622
|
const stageConstant = stage && stageConstants?.[stage] || stageInitial;
|
|
@@ -5617,8 +5625,8 @@ function getRoundContextProfile({
|
|
|
5617
5625
|
Object.assign(
|
|
5618
5626
|
roundNamingProfile,
|
|
5619
5627
|
...roundProfileKeys.map((key) => {
|
|
5620
|
-
const roundName =
|
|
5621
|
-
const abbreviatedRoundName =
|
|
5628
|
+
const roundName = `${roundNameFallback} ${key}`;
|
|
5629
|
+
const abbreviatedRoundName = `${roundNumberAffix}${key}`;
|
|
5622
5630
|
return { [key]: { roundName, abbreviatedRoundName } };
|
|
5623
5631
|
})
|
|
5624
5632
|
);
|
|
@@ -5965,7 +5973,7 @@ function getAllStructureMatchUps({
|
|
|
5965
5973
|
...collectionDefinition.category
|
|
5966
5974
|
} : context?.category;
|
|
5967
5975
|
const processCodes = matchUp.processCodes?.length && matchUp.processCodes || collectionDefinition?.processCodes?.length && collectionDefinition?.processCodes || structure?.processCodes?.length && structure?.processCodes || drawDefinition?.processCodes?.length && drawDefinition?.processCodes || event2?.processCodes?.length && event2?.processCodes || tournamentRecord?.processCodes;
|
|
5968
|
-
const
|
|
5976
|
+
const competitiveProfile = contextProfile?.withCompetitiveness && getMatchUpCompetitiveProfile({ ...contextContent, matchUp });
|
|
5969
5977
|
const finishingPositionRange = matchUp.finishingPositionRange || additionalContext.finishingPositionRange;
|
|
5970
5978
|
const onlyDefined = (obj) => definedAttributes(obj, void 0, true);
|
|
5971
5979
|
const matchUpWithContext = {
|
|
@@ -5981,7 +5989,7 @@ function getAllStructureMatchUps({
|
|
|
5981
5989
|
finishingPositionRange,
|
|
5982
5990
|
abbreviatedRoundName,
|
|
5983
5991
|
drawPositionsRange,
|
|
5984
|
-
|
|
5992
|
+
competitiveProfile,
|
|
5985
5993
|
structureName,
|
|
5986
5994
|
stageSequence,
|
|
5987
5995
|
drawPositions,
|
|
@@ -16537,8 +16545,8 @@ function modifyMatchUpFormatTiming({
|
|
|
16537
16545
|
recoveryTimes
|
|
16538
16546
|
});
|
|
16539
16547
|
addTournamentExtension({
|
|
16540
|
-
|
|
16541
|
-
|
|
16548
|
+
extension: { name, value },
|
|
16549
|
+
tournamentRecord
|
|
16542
16550
|
});
|
|
16543
16551
|
}
|
|
16544
16552
|
return { ...SUCCESS };
|