Skip to content

Commit

Permalink
Work around root-level super statement
Browse files Browse the repository at this point in the history
  • Loading branch information
Rian8337 committed Apr 4, 2024
1 parent cab78fd commit 00800ec
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -396,23 +396,21 @@ export class DroidDifficultyCalculator extends DifficultyCalculator<
}

protected override generateDifficultyHitObjects(convertedBeatmap: Beatmap) {
const difficultyObjects: DroidDifficultyHitObject[] = [];
const { objects } = convertedBeatmap.hitObjects;

const difficultyAdjustMod = this.mods.find(
(m) => m instanceof ModDifficultyAdjust,
) as ModDifficultyAdjust | undefined;

const { objects: hitObjects } = this.beatmap.hitObjects;

for (let i = 0; i < hitObjects.length; ++i) {
for (let i = 0; i < objects.length; ++i) {
const difficultyObject = new DroidDifficultyHitObject(
objects[i],
objects[i - 1] ?? null,
objects[i - 2] ?? null,
difficultyObjects,
this.objects,
this.difficultyStatistics.overallSpeedMultiplier,
difficultyAdjustMod?.ar !== undefined,
i - 1,
);

difficultyObject.computeProperties(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,23 @@ export abstract class DifficultyHitObject {
* @param lastLastObject The hitobject before the last hitobject.
* @param difficultyHitObjects All difficulty hitobjects in the processed beatmap.
* @param clockRate The clock rate of the beatmap.
* @param index The index of this hitobject in the list of all hitobjects.
*/
constructor(
protected constructor(
object: PlaceableHitObject,
lastObject: PlaceableHitObject | null,
lastLastObject: PlaceableHitObject | null,
difficultyHitObjects: readonly DifficultyHitObject[],
clockRate: number,
index = difficultyHitObjects.length - 1,
) {
this.object = object;
this.lastObject = lastObject;
this.lastLastObject = lastLastObject;
this.hitObjects = difficultyHitObjects;
this.clockRate = clockRate;

this.index = difficultyHitObjects.length - 1;
this.index = index;

// Capped to 25ms to prevent difficulty calculation breaking from simultaneous objects.
this.startTime = object.startTime / clockRate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export class DroidDifficultyHitObject extends DifficultyHitObject {
* @param difficultyHitObjects All difficulty hitobjects in the processed beatmap.
* @param clockRate The clock rate of the beatmap.
* @param isForceAR Whether force AR is enabled.
* @param index The index of the hitobject in the difficulty hitobjects array.
*/
constructor(
object: PlaceableHitObject,
Expand All @@ -95,13 +96,15 @@ export class DroidDifficultyHitObject extends DifficultyHitObject {
difficultyHitObjects: readonly DifficultyHitObject[],
clockRate: number,
isForceAR: boolean,
index = difficultyHitObjects.length - 1,
) {
super(
object,
lastObject,
lastLastObject,
difficultyHitObjects,
clockRate,
index,
);

this.timePreempt = object.timePreempt;
Expand Down Expand Up @@ -131,6 +134,7 @@ export class DroidDifficultyHitObject extends DifficultyHitObject {
this.clockRate,
// Purposefully set this to true so that time preempt would stay the same.
true,
this.index,
);

difficultyObject.angle = this.angle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,40 @@ export class RawTouchAim extends RawTouchSkill {
private readonly flowSkillMultiplier = 24.55;
private readonly withSliders: boolean;

constructor(copy: RawTouchAim);
constructor(
mods: Mod[],
clockRate: number,
isForceAR: boolean,
objectCache: DifficultyHitObjectCache<DroidDifficultyHitObject>,
withSliders: boolean,
);
constructor(
modsOrCopy: Mod[] | RawTouchAim,
clockRate?: number,
isForceAR?: boolean,
objectCache?: DifficultyHitObjectCache<DroidDifficultyHitObject>,
withSliders?: boolean,
) {
if (modsOrCopy instanceof RawTouchAim) {
super(modsOrCopy);
super(mods, clockRate, isForceAR, objectCache);

this.withSliders = modsOrCopy.withSliders;
this.withSliders = withSliders;
}

return;
}
override clone(): RawTouchAim {
const clone = new RawTouchAim(
this.mods,
this.clockRate,
this.isForceAR,
this.objectCache,
this.withSliders,
);

// These are safe to non-null (see constructor overloads).
super(modsOrCopy, clockRate!, isForceAR!, objectCache!);
clone._currentStrain = this._currentStrain;
clone.lastHand = this.lastHand;

this.withSliders = withSliders!;
}
for (let i = 0; i < this.lastObjects.length; ++i) {
clone.lastObjects[i] = this.lastObjects[i].slice();
}

override clone(): RawTouchAim {
return new RawTouchAim(this);
for (let i = 0; i < this.lastDifficultyObjects.length; ++i) {
clone.lastDifficultyObjects[i] =
this.lastDifficultyObjects[i].slice();
}

return clone;
}

protected override strainValueOf(current: DroidDifficultyHitObject) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,68 +6,40 @@ import { DifficultyHitObjectCache } from "../../utils/DifficultyHitObjectCache";
export abstract class RawTouchSkill {
protected abstract readonly strainDecayBase: number;

private readonly mods: Mod[];
private readonly clockRate: number;
private readonly isForceAR: boolean;
private readonly objectCache: DifficultyHitObjectCache<DroidDifficultyHitObject>;

private readonly lastObjects: [PlaceableHitObject[], PlaceableHitObject[]] =
[[], []];
protected readonly mods: Mod[];
protected readonly clockRate: number;
protected readonly isForceAR: boolean;
protected readonly objectCache: DifficultyHitObjectCache<DroidDifficultyHitObject>;

protected readonly lastObjects: [
PlaceableHitObject[],
PlaceableHitObject[],
] = [[], []];
protected readonly maxObjectsHistory: number = 2;

private readonly lastDifficultyObjects: [
protected readonly lastDifficultyObjects: [
DroidDifficultyHitObject[],
DroidDifficultyHitObject[],
] = [[], []];
protected readonly maxDifficultyObjectsHistory: number = 3;

private lastHand: TouchHand.left | TouchHand.right;
private _currentStrain = 0;
protected lastHand: TouchHand.left | TouchHand.right;
protected _currentStrain = 0;

get currentStrain() {
return this._currentStrain;
}

constructor(copy: RawTouchSkill);
constructor(
mods: Mod[],
clockRate: number,
isForceAR: boolean,
objectCache: DifficultyHitObjectCache<DroidDifficultyHitObject>,
);
constructor(
modsOrCopy: Mod[] | RawTouchSkill,
clockRate?: number,
isForceAR?: boolean,
objectCache?: DifficultyHitObjectCache<DroidDifficultyHitObject>,
) {
if (modsOrCopy instanceof RawTouchSkill) {
this.mods = modsOrCopy.mods.slice();
this.clockRate = modsOrCopy.clockRate;
this.isForceAR = modsOrCopy.isForceAR;
this.objectCache = modsOrCopy.objectCache;

this._currentStrain = modsOrCopy._currentStrain;
this.lastHand = modsOrCopy.lastHand;

for (let i = 0; i < this.lastObjects.length; ++i) {
this.lastObjects[i] = modsOrCopy.lastObjects[i].slice();
}

for (let i = 0; i < this.lastDifficultyObjects.length; ++i) {
this.lastDifficultyObjects[i] =
modsOrCopy.lastDifficultyObjects[i].slice();
}

return;
}

this.mods = modsOrCopy;

// These are safe to non-null (see constructor overloads).
this.clockRate = clockRate!;
this.isForceAR = isForceAR!;
this.objectCache = objectCache!;
this.mods = mods;
this.clockRate = clockRate;
this.isForceAR = isForceAR;
this.objectCache = objectCache;

this.lastHand = TouchHand.right;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,43 @@ export class RawTouchTap extends RawTouchSkill {
private readonly greatWindow: number;
private readonly considerCheesability: boolean;

constructor(copy: RawTouchTap);
constructor(
mods: Mod[],
clockRate: number,
isForceAR: boolean,
objectCache: DifficultyHitObjectCache<DroidDifficultyHitObject>,
greatWindow: number,
considerCheesability: boolean,
);
constructor(
modsOrCopy: Mod[] | RawTouchTap,
clockRate?: number,
isForceAR?: boolean,
objectCache?: DifficultyHitObjectCache<DroidDifficultyHitObject>,
greatWindow?: number,
considerCheesability?: boolean,
) {
if (modsOrCopy instanceof RawTouchTap) {
super(modsOrCopy);
super(mods, clockRate, isForceAR, objectCache);

this.greatWindow = modsOrCopy.greatWindow;
this.considerCheesability = modsOrCopy.considerCheesability;
this.greatWindow = greatWindow;
this.considerCheesability = considerCheesability;
}

return;
}
override clone(): RawTouchTap {
const clone = new RawTouchTap(
this.mods,
this.clockRate,
this.isForceAR,
this.objectCache,
this.greatWindow,
this.considerCheesability,
);

// These are safe to non-null (see constructor overloads).
super(modsOrCopy, clockRate!, isForceAR!, objectCache!);
clone._currentStrain = this._currentStrain;
clone.lastHand = this.lastHand;

this.greatWindow = greatWindow!;
this.considerCheesability = considerCheesability!;
}
for (let i = 0; i < this.lastObjects.length; ++i) {
clone.lastObjects[i] = this.lastObjects[i].slice();
}

override clone(): RawTouchTap {
return new RawTouchTap(this);
for (let i = 0; i < this.lastDifficultyObjects.length; ++i) {
clone.lastDifficultyObjects[i] =
this.lastDifficultyObjects[i].slice();
}

return clone;
}

protected override strainValueOf(current: DroidDifficultyHitObject) {
Expand Down

0 comments on commit 00800ec

Please sign in to comment.