bitburner-src/src/ExportBonus.tsx

23 lines
569 B
TypeScript
Raw Normal View History

2021-05-11 00:26:50 +02:00
import { Factions } from "./Faction/Factions";
2022-09-06 15:07:12 +02:00
import { Player } from "./Player";
2021-05-11 00:26:50 +02:00
export let LastExportBonus = 0;
2021-05-11 00:26:50 +02:00
2021-09-05 01:09:30 +02:00
const bonusTimer = 24 * 60 * 60 * 1000; // 24h
2021-05-11 00:26:50 +02:00
export function canGetBonus(): boolean {
2021-09-05 01:09:30 +02:00
const now = new Date().getTime();
2022-03-01 20:37:47 +01:00
return now - LastExportBonus > bonusTimer;
2021-05-11 00:26:50 +02:00
}
2022-09-06 15:07:12 +02:00
export function onExport(): void {
2021-09-05 01:09:30 +02:00
if (!canGetBonus()) return;
2022-09-06 15:07:12 +02:00
for (const facName of Player.factions) {
2021-09-05 01:09:30 +02:00
Factions[facName].favor++;
}
LastExportBonus = new Date().getTime();
2021-05-29 20:48:56 +02:00
}
export function setLastExportBonus(unixTime: number): void {
2021-09-05 01:09:30 +02:00
LastExportBonus = unixTime;
}