Skip to content

Commit

Permalink
add medals property to placing
Browse files Browse the repository at this point in the history
  • Loading branch information
tctree333 committed May 28, 2023
1 parent c8bcc63 commit 8de97d1
Show file tree
Hide file tree
Showing 4 changed files with 44,659 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/interpreter/placing.ts
Expand Up @@ -45,6 +45,9 @@ export default class Placing implements Model<PlacingRep> {
pointsAffectedByExhibition?: boolean;
pointsLimitedByMaximumPlace?: boolean;

medal: number | false;
trackMedal: number | false;

_trackExhibitonPlacingsBehind?: number;
_exhibitionPlacingsBehind?: number;

Expand All @@ -60,6 +63,9 @@ export default class Placing implements Model<PlacingRep> {

this.hasRaw = rep.raw !== undefined;
this.didNotParticipate = !this.participated;

this.medal = false;
this.trackMedal = false;
}

link(interpreter: Interpreter): void {
Expand Down Expand Up @@ -132,6 +138,19 @@ export default class Placing implements Model<PlacingRep> {
this.interpreter?.isSuperscore ? Infinity : maxPlace
);
})();

if (!this.tournament.reverseScoring) {
if (
this.isolatedPoints != undefined &&
this.isolatedPoints > 0 &&
this.isolatedPoints <=
((this.event.medals as number) || (this.tournament.medals as number))
) {
this.medal = this.isolatedPoints;
}
} else {
// TODO: figure out how medals work for reverse scoring
}
}

computeTrackPlaces(): void {
Expand Down Expand Up @@ -172,6 +191,19 @@ export default class Placing implements Model<PlacingRep> {
this.interpreter?.isSuperscore ? Infinity : maxPlace
);
})();

if (!this.tournament.reverseScoring) {
if (
this.isolatedTrackPoints != undefined &&
this.isolatedTrackPoints > 0 &&
this.isolatedTrackPoints <=
((this.event.medals as number) || (this.team.track?.medals as number))
) {
this.trackMedal = this.isolatedTrackPoints;
}
} else {
// TODO: figure out how medals work for reverse scoring
}
}

// compute teams worstPlacingsToBeDropped before running this
Expand Down
3 changes: 3 additions & 0 deletions tests/helpers.ts
Expand Up @@ -63,6 +63,9 @@ export function dumpInterpreter(interpreter: Interpreter) {

pointsAffectedByExhibition: p.pointsAffectedByExhibition,
pointsLimitedByMaximumPlace: p.pointsLimitedByMaximumPlace,

medal: p.medal,
trackMedal: p.trackMedal,
}))
.sort(
(a, b) =>
Expand Down

0 comments on commit 8de97d1

Please sign in to comment.