2021-05-11 00:26:50 +02:00
|
|
|
import { Factions } from "./Faction/Factions";
|
|
|
|
import { IPlayer } from "./PersonObjects/IPlayer";
|
|
|
|
|
2021-05-29 18:48:58 +02:00
|
|
|
export let LastExportBonus = 0;
|
2021-05-11 00:26:50 +02:00
|
|
|
|
|
|
|
const bonusTimer = 24*60*60*1000; // 24h
|
|
|
|
export function canGetBonus(): boolean {
|
|
|
|
const now = (new Date()).getTime()
|
|
|
|
if(now - LastExportBonus > bonusTimer) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function onExport(p: IPlayer): void {
|
|
|
|
if(!canGetBonus()) return;
|
|
|
|
for (const facName of p.factions) {
|
|
|
|
Factions[facName].favor++;
|
|
|
|
}
|
|
|
|
LastExportBonus = (new Date()).getTime();
|
2021-05-29 20:48:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export function setLastExportBonus(unixTime: number): void {
|
|
|
|
LastExportBonus = unixTime;
|
2021-05-11 00:26:50 +02:00
|
|
|
}
|