tods-competition-factory 1.7.4 → 1.7.6
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.d.ts +9 -2
- package/dist/forge/generate.mjs +47 -23
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.mjs +14 -13
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +12 -11
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +82 -42
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +102 -57
- 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.d.ts
CHANGED
|
@@ -1411,6 +1411,8 @@ type GenerateDrawMaticRoundArgs = {
|
|
|
1411
1411
|
salted?: number | boolean;
|
|
1412
1412
|
participantIds?: string[];
|
|
1413
1413
|
addToStructure?: boolean;
|
|
1414
|
+
encounterValue?: number;
|
|
1415
|
+
sameTeamValue?: number;
|
|
1414
1416
|
maxIterations?: number;
|
|
1415
1417
|
matchUpIds?: string[];
|
|
1416
1418
|
structure?: Structure;
|
|
@@ -1419,12 +1421,14 @@ type GenerateDrawMaticRoundArgs = {
|
|
|
1419
1421
|
scaleName?: string;
|
|
1420
1422
|
drawId?: string;
|
|
1421
1423
|
};
|
|
1422
|
-
declare function generateDrawMaticRound({ maxIterations, generateMatchUps, tournamentParticipants, tournamentRecord, participantIds, addToStructure, drawDefinition, adHocRatings, structureId, salted, matchUpIds, eventType, structure, scaleName, }: GenerateDrawMaticRoundArgs): ResultType | {
|
|
1424
|
+
declare function generateDrawMaticRound({ encounterValue, sameTeamValue, maxIterations, generateMatchUps, tournamentParticipants, tournamentRecord, participantIds, addToStructure, drawDefinition, adHocRatings, structureId, salted, matchUpIds, eventType, structure, scaleName, }: GenerateDrawMaticRoundArgs): ResultType | {
|
|
1423
1425
|
participantIdPairings: string[][];
|
|
1424
1426
|
candidatesCount: number;
|
|
1425
1427
|
matchUps: MatchUp[];
|
|
1426
1428
|
iterations: number;
|
|
1427
1429
|
success: boolean;
|
|
1430
|
+
maxDelta: number;
|
|
1431
|
+
maxDiff: number;
|
|
1428
1432
|
};
|
|
1429
1433
|
|
|
1430
1434
|
type DrawMaticArgs = {
|
|
@@ -1436,8 +1440,11 @@ type DrawMaticArgs = {
|
|
|
1436
1440
|
drawDefinition?: DrawDefinition;
|
|
1437
1441
|
tournamentRecord: Tournament;
|
|
1438
1442
|
generateMatchUps?: boolean;
|
|
1439
|
-
|
|
1443
|
+
salted?: number | boolean;
|
|
1440
1444
|
participantIds?: string[];
|
|
1445
|
+
addToStructure?: boolean;
|
|
1446
|
+
encounterValue?: number;
|
|
1447
|
+
sameTeamValue?: number;
|
|
1441
1448
|
maxIterations?: number;
|
|
1442
1449
|
structure?: Structure;
|
|
1443
1450
|
matchUpIds?: string[];
|
package/dist/forge/generate.mjs
CHANGED
|
@@ -1380,7 +1380,7 @@ function gamesPercent(scoreComponents) {
|
|
|
1380
1380
|
return Math.round(minGames / maxGames * 100);
|
|
1381
1381
|
}
|
|
1382
1382
|
function pctSpread(pcts) {
|
|
1383
|
-
return pcts.map(gamesPercent).sort().map((p) => p.toFixed(2));
|
|
1383
|
+
return pcts.map(gamesPercent).sort().map((p) => parseFloat(p.toFixed(2)));
|
|
1384
1384
|
}
|
|
1385
1385
|
|
|
1386
1386
|
function findPolicy({
|
|
@@ -1415,15 +1415,15 @@ const POLICY_TYPE_DRAWS = "draws";
|
|
|
1415
1415
|
const POLICY_COMPETITIVE_BANDS_DEFAULT = {
|
|
1416
1416
|
[POLICY_TYPE_COMPETITIVE_BANDS]: {
|
|
1417
1417
|
policyName: "Competitive Bands Default",
|
|
1418
|
-
|
|
1418
|
+
profileBands: {
|
|
1419
1419
|
[DECISIVE]: 20,
|
|
1420
1420
|
[ROUTINE]: 50
|
|
1421
1421
|
}
|
|
1422
1422
|
}
|
|
1423
1423
|
};
|
|
1424
1424
|
|
|
1425
|
-
function
|
|
1426
|
-
|
|
1425
|
+
function getMatchUpCompetitiveProfile({
|
|
1426
|
+
profileBands,
|
|
1427
1427
|
tournamentRecord,
|
|
1428
1428
|
matchUp
|
|
1429
1429
|
}) {
|
|
@@ -1432,15 +1432,15 @@ function getMatchUpCompetitiveness({
|
|
|
1432
1432
|
const { score, winningSide } = matchUp;
|
|
1433
1433
|
if (!winningSide)
|
|
1434
1434
|
return { error: INVALID_VALUES };
|
|
1435
|
-
const policy = !
|
|
1435
|
+
const policy = !profileBands && tournamentRecord && findPolicy({
|
|
1436
1436
|
policyType: POLICY_TYPE_COMPETITIVE_BANDS,
|
|
1437
1437
|
tournamentRecord
|
|
1438
1438
|
}).policy;
|
|
1439
|
-
const bandProfiles =
|
|
1439
|
+
const bandProfiles = profileBands || policy?.profileBands || POLICY_COMPETITIVE_BANDS_DEFAULT[POLICY_TYPE_COMPETITIVE_BANDS].profileBands;
|
|
1440
1440
|
const scoreComponents = getScoreComponents({ score });
|
|
1441
1441
|
const spread = pctSpread([scoreComponents]);
|
|
1442
1442
|
const competitiveness = getBand(spread, bandProfiles);
|
|
1443
|
-
return { ...SUCCESS, competitiveness };
|
|
1443
|
+
return { ...SUCCESS, competitiveness, pctSpread: spread };
|
|
1444
1444
|
}
|
|
1445
1445
|
|
|
1446
1446
|
function findMatchupFormatAverageTimes(params) {
|
|
@@ -1576,14 +1576,15 @@ function getScaleValues({ participant }) {
|
|
|
1576
1576
|
for (const itemType of itemTypes) {
|
|
1577
1577
|
const scaleItem = latestScaleItem(itemType);
|
|
1578
1578
|
if (scaleItem) {
|
|
1579
|
-
const [, type, format, scaleName] = scaleItem.itemType.split(".");
|
|
1579
|
+
const [, type, format, scaleName, modifier] = scaleItem.itemType.split(".");
|
|
1580
|
+
const namedScale = modifier ? `${scaleName}.${modifier}` : scaleName;
|
|
1580
1581
|
const scaleType = type === SEEDING && "seedings" || type === RANKING && "rankings" || "ratings";
|
|
1581
1582
|
if (!scales[scaleType][format])
|
|
1582
1583
|
scales[scaleType][format] = [];
|
|
1583
1584
|
scales[scaleType][format].push({
|
|
1584
1585
|
scaleValue: scaleItem.itemValue,
|
|
1585
1586
|
scaleDate: scaleItem.itemDate,
|
|
1586
|
-
scaleName
|
|
1587
|
+
scaleName: namedScale
|
|
1587
1588
|
});
|
|
1588
1589
|
}
|
|
1589
1590
|
}
|
|
@@ -4653,7 +4654,7 @@ function getAllStructureMatchUps({
|
|
|
4653
4654
|
...collectionDefinition.category
|
|
4654
4655
|
} : context?.category;
|
|
4655
4656
|
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;
|
|
4656
|
-
const
|
|
4657
|
+
const competitiveProfile = contextProfile?.withCompetitiveness && getMatchUpCompetitiveProfile({ ...contextContent, matchUp });
|
|
4657
4658
|
const finishingPositionRange = matchUp.finishingPositionRange || additionalContext.finishingPositionRange;
|
|
4658
4659
|
const onlyDefined = (obj) => definedAttributes(obj, void 0, true);
|
|
4659
4660
|
const matchUpWithContext = {
|
|
@@ -4669,7 +4670,7 @@ function getAllStructureMatchUps({
|
|
|
4669
4670
|
finishingPositionRange,
|
|
4670
4671
|
abbreviatedRoundName,
|
|
4671
4672
|
drawPositionsRange,
|
|
4672
|
-
|
|
4673
|
+
competitiveProfile,
|
|
4673
4674
|
structureName,
|
|
4674
4675
|
stageSequence,
|
|
4675
4676
|
drawPositions,
|
|
@@ -13936,7 +13937,7 @@ function treeMatchUps({
|
|
|
13936
13937
|
uuids
|
|
13937
13938
|
}));
|
|
13938
13939
|
roundNumber++;
|
|
13939
|
-
roundLimit = roundLimit || qualifyingRoundNumber
|
|
13940
|
+
roundLimit = roundLimit || qualifyingRoundNumber;
|
|
13940
13941
|
while (roundNodes.length > 1) {
|
|
13941
13942
|
if (qualifyingPositions && roundNodes.length === qualifyingPositions) {
|
|
13942
13943
|
roundLimit = roundNumber - 1;
|
|
@@ -19745,6 +19746,10 @@ function addAdHocMatchUps({
|
|
|
19745
19746
|
return { ...SUCCESS };
|
|
19746
19747
|
}
|
|
19747
19748
|
|
|
19749
|
+
function stringSort(a, b) {
|
|
19750
|
+
return (a || "").localeCompare(b || "");
|
|
19751
|
+
}
|
|
19752
|
+
|
|
19748
19753
|
function generateCandidate({
|
|
19749
19754
|
maxIterations = 4e3,
|
|
19750
19755
|
// cap the processing intensity of the candidate generator
|
|
@@ -19879,7 +19884,7 @@ function roundCandidate({
|
|
|
19879
19884
|
return { value: candidateValue, participantIdPairings, maxDelta, maxDiff };
|
|
19880
19885
|
}
|
|
19881
19886
|
function pairingHash(id1, id2) {
|
|
19882
|
-
return [id1, id2].sort().join("|");
|
|
19887
|
+
return [id1, id2].sort(stringSort).join("|");
|
|
19883
19888
|
}
|
|
19884
19889
|
|
|
19885
19890
|
function getPairingsData({ participantIds }) {
|
|
@@ -19944,13 +19949,19 @@ const UTR = "UTR";
|
|
|
19944
19949
|
const WTN = "WTN";
|
|
19945
19950
|
|
|
19946
19951
|
const ratingsParameters = {
|
|
19947
|
-
[ELO]: {
|
|
19952
|
+
[ELO]: {
|
|
19953
|
+
defaultInitialization: 1500,
|
|
19954
|
+
decimalsCount: 0,
|
|
19955
|
+
range: [0, 3e3],
|
|
19956
|
+
ascending: true
|
|
19957
|
+
},
|
|
19948
19958
|
[NTRP]: {
|
|
19949
19959
|
accessors: ["ntrpRating", "dntrpRatingHundredths"],
|
|
19950
19960
|
attributes: { ustaRatingType: "" },
|
|
19951
19961
|
accessor: "dntrpRatingHundredths",
|
|
19952
19962
|
defaultInitialization: 3,
|
|
19953
19963
|
decimalsCount: 1,
|
|
19964
|
+
ascending: true,
|
|
19954
19965
|
range: [1, 7]
|
|
19955
19966
|
},
|
|
19956
19967
|
[UTR]: {
|
|
@@ -19958,6 +19969,7 @@ const ratingsParameters = {
|
|
|
19958
19969
|
accessors: ["utrRating"],
|
|
19959
19970
|
accessor: "utrRating",
|
|
19960
19971
|
decimalsCount: 2,
|
|
19972
|
+
ascending: true,
|
|
19961
19973
|
range: [1, 16]
|
|
19962
19974
|
},
|
|
19963
19975
|
[WTN]: {
|
|
@@ -19965,6 +19977,7 @@ const ratingsParameters = {
|
|
|
19965
19977
|
accessors: ["wtnRating", "confidence"],
|
|
19966
19978
|
defaultInitialization: 23,
|
|
19967
19979
|
accessor: "wtnRating",
|
|
19980
|
+
ascending: false,
|
|
19968
19981
|
decimalsCount: 2,
|
|
19969
19982
|
range: [40, 1]
|
|
19970
19983
|
}
|
|
@@ -20050,8 +20063,10 @@ function getPairings({
|
|
|
20050
20063
|
|
|
20051
20064
|
const ENCOUNTER_VALUE = 100;
|
|
20052
20065
|
const SAME_TEAM_VALUE = 100;
|
|
20053
|
-
const MAX_ITERATIONS =
|
|
20066
|
+
const MAX_ITERATIONS = 4e3;
|
|
20054
20067
|
function generateDrawMaticRound({
|
|
20068
|
+
encounterValue = ENCOUNTER_VALUE,
|
|
20069
|
+
sameTeamValue = SAME_TEAM_VALUE,
|
|
20055
20070
|
maxIterations = MAX_ITERATIONS,
|
|
20056
20071
|
generateMatchUps = true,
|
|
20057
20072
|
tournamentParticipants,
|
|
@@ -20084,7 +20099,7 @@ function generateDrawMaticRound({
|
|
|
20084
20099
|
for (const pairing of encounters) {
|
|
20085
20100
|
if (!valueObjects[pairing])
|
|
20086
20101
|
valueObjects[pairing] = 0;
|
|
20087
|
-
valueObjects[pairing] +=
|
|
20102
|
+
valueObjects[pairing] += encounterValue;
|
|
20088
20103
|
}
|
|
20089
20104
|
const teamParticipants = tournamentParticipants?.filter(
|
|
20090
20105
|
({ participantType }) => participantType === TEAM
|
|
@@ -20096,7 +20111,7 @@ function generateDrawMaticRound({
|
|
|
20096
20111
|
for (const pairing of uniquePairings2) {
|
|
20097
20112
|
if (!valueObjects[pairing])
|
|
20098
20113
|
valueObjects[pairing] = 0;
|
|
20099
|
-
valueObjects[pairing] +=
|
|
20114
|
+
valueObjects[pairing] += sameTeamValue;
|
|
20100
20115
|
}
|
|
20101
20116
|
}
|
|
20102
20117
|
}
|
|
@@ -20118,7 +20133,7 @@ function generateDrawMaticRound({
|
|
|
20118
20133
|
structure,
|
|
20119
20134
|
salted
|
|
20120
20135
|
};
|
|
20121
|
-
const { candidatesCount, participantIdPairings, iterations } = getPairings(params);
|
|
20136
|
+
const { candidatesCount, participantIdPairings, iterations, candidate } = getPairings(params);
|
|
20122
20137
|
if (!candidatesCount)
|
|
20123
20138
|
return { error: NO_CANDIDATES };
|
|
20124
20139
|
let matchUps;
|
|
@@ -20136,12 +20151,15 @@ function generateDrawMaticRound({
|
|
|
20136
20151
|
return result;
|
|
20137
20152
|
matchUps = result.matchUps;
|
|
20138
20153
|
}
|
|
20154
|
+
const { maxDelta, maxDiff } = candidate;
|
|
20139
20155
|
return {
|
|
20140
20156
|
...SUCCESS,
|
|
20141
20157
|
participantIdPairings,
|
|
20142
20158
|
candidatesCount,
|
|
20143
20159
|
iterations,
|
|
20144
|
-
matchUps
|
|
20160
|
+
matchUps,
|
|
20161
|
+
maxDelta,
|
|
20162
|
+
maxDiff
|
|
20145
20163
|
};
|
|
20146
20164
|
}
|
|
20147
20165
|
|
|
@@ -22680,10 +22698,12 @@ function drawMatic({
|
|
|
22680
22698
|
tournamentParticipants,
|
|
22681
22699
|
restrictEntryStatus,
|
|
22682
22700
|
adHocRatings = {},
|
|
22683
|
-
tournamentRecord,
|
|
22684
22701
|
generateMatchUps,
|
|
22702
|
+
tournamentRecord,
|
|
22685
22703
|
addToStructure,
|
|
22686
22704
|
participantIds,
|
|
22705
|
+
encounterValue,
|
|
22706
|
+
sameTeamValue,
|
|
22687
22707
|
drawDefinition,
|
|
22688
22708
|
scaleAccessor,
|
|
22689
22709
|
maxIterations,
|
|
@@ -22692,6 +22712,7 @@ function drawMatic({
|
|
|
22692
22712
|
scaleName,
|
|
22693
22713
|
// custom rating name to seed dynamic ratings
|
|
22694
22714
|
eventType,
|
|
22715
|
+
salted,
|
|
22695
22716
|
event
|
|
22696
22717
|
}) {
|
|
22697
22718
|
if (typeof drawDefinition !== "object" || drawDefinition.drawType && drawDefinition.drawType !== AD_HOC) {
|
|
@@ -22757,16 +22778,19 @@ function drawMatic({
|
|
|
22757
22778
|
}
|
|
22758
22779
|
return generateDrawMaticRound({
|
|
22759
22780
|
tournamentParticipants,
|
|
22760
|
-
tournamentRecord,
|
|
22761
22781
|
generateMatchUps,
|
|
22762
|
-
|
|
22782
|
+
tournamentRecord,
|
|
22763
22783
|
addToStructure,
|
|
22784
|
+
participantIds,
|
|
22785
|
+
encounterValue,
|
|
22786
|
+
sameTeamValue,
|
|
22764
22787
|
drawDefinition,
|
|
22765
22788
|
maxIterations,
|
|
22766
22789
|
adHocRatings,
|
|
22767
22790
|
matchUpIds,
|
|
22768
22791
|
structure,
|
|
22769
|
-
eventType
|
|
22792
|
+
eventType,
|
|
22793
|
+
salted
|
|
22770
22794
|
});
|
|
22771
22795
|
}
|
|
22772
22796
|
function getScaleValue({
|