Skip to content

Commit fbd4c0e

Browse files
committed
Refactor
Updates the mod structure to use classes instead of grouped, exported functions. Cleaner.
1 parent e261d8c commit fbd4c0e

19 files changed

+1107
-990
lines changed

src/adjusters/RaidTimeAdjuster.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import type { ILocationBase } from "@spt-aki/models/eft/common/ILocationBase";
2+
import { CustomRaidTimes } from "../CustomRaidTimes";
3+
import { LocationProcessor } from "../processors/LocationProcessor";
4+
5+
/**
6+
* RaidTimeAdjuster class.
7+
*
8+
* Handles the logic needed to set a new raid time.
9+
*/
10+
export class RaidTimeAdjuster {
11+
private location: ILocationBase;
12+
private locationName: { config: string; human: string };
13+
14+
constructor(location: ILocationBase) {
15+
this.location = location;
16+
this.locationName = LocationProcessor.locationNames[location.Id.toString().toLowerCase()];
17+
}
18+
19+
/**
20+
* Adjusts the raid time of the location.
21+
*/
22+
public adjust(): void {
23+
const originalTime = this.location.EscapeTimeLimit;
24+
25+
if (CustomRaidTimes.config.raidTimes.overrideAll) {
26+
this.location.EscapeTimeLimit = Number(CustomRaidTimes.config.raidTimes.override);
27+
} else {
28+
const customTime = CustomRaidTimes.config.raidTimes.customTimes[this.locationName.config];
29+
this.location.EscapeTimeLimit = Number(customTime);
30+
}
31+
32+
if (CustomRaidTimes.config.general.debug && this.location.EscapeTimeLimit !== originalTime) {
33+
CustomRaidTimes.logger.log(
34+
`CustomRaidTimes: ${this.locationName.human} raid time change from ${originalTime} minutes to ${this.location.EscapeTimeLimit} minutes.`,
35+
"gray"
36+
);
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)