Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
Updates the mod structure to use classes instead of grouped, exported functions. Cleaner.
  • Loading branch information
refringe committed Oct 5, 2023
1 parent e261d8c commit fbd4c0e
Show file tree
Hide file tree
Showing 19 changed files with 1,107 additions and 990 deletions.
39 changes: 39 additions & 0 deletions src/adjusters/RaidTimeAdjuster.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import type { ILocationBase } from "@spt-aki/models/eft/common/ILocationBase";
import { CustomRaidTimes } from "../CustomRaidTimes";
import { LocationProcessor } from "../processors/LocationProcessor";

/**
* RaidTimeAdjuster class.
*
* Handles the logic needed to set a new raid time.
*/
export class RaidTimeAdjuster {
private location: ILocationBase;
private locationName: { config: string; human: string };

constructor(location: ILocationBase) {
this.location = location;
this.locationName = LocationProcessor.locationNames[location.Id.toString().toLowerCase()];
}

/**
* Adjusts the raid time of the location.
*/
public adjust(): void {
const originalTime = this.location.EscapeTimeLimit;

if (CustomRaidTimes.config.raidTimes.overrideAll) {
this.location.EscapeTimeLimit = Number(CustomRaidTimes.config.raidTimes.override);
} else {
const customTime = CustomRaidTimes.config.raidTimes.customTimes[this.locationName.config];
this.location.EscapeTimeLimit = Number(customTime);
}

if (CustomRaidTimes.config.general.debug && this.location.EscapeTimeLimit !== originalTime) {
CustomRaidTimes.logger.log(
`CustomRaidTimes: ${this.locationName.human} raid time change from ${originalTime} minutes to ${this.location.EscapeTimeLimit} minutes.`,
"gray"
);
}
}
}
Loading

0 comments on commit fbd4c0e

Please sign in to comment.