mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-25 02:24:36 +00:00
29 lines
644 B
TypeScript
29 lines
644 B
TypeScript
import { GameView } from "../../../core/game/GameView";
|
|
import { Layer } from "./Layer";
|
|
|
|
const AD_SHOW_TICKS = 5 * 60 * 10; // 5 minutes
|
|
|
|
export class AdTimer implements Layer {
|
|
private isHidden: boolean = false;
|
|
|
|
constructor(private g: GameView) {}
|
|
|
|
init() {}
|
|
|
|
public async tick() {
|
|
if (this.isHidden) {
|
|
return;
|
|
}
|
|
|
|
const gameTicks = this.g.ticks() - this.g.config().numSpawnPhaseTurns();
|
|
if (gameTicks > AD_SHOW_TICKS) {
|
|
console.log("destroying sticky ads");
|
|
window.fusetag?.que?.push(() => {
|
|
window.fusetag?.destroySticky?.();
|
|
});
|
|
this.isHidden = true;
|
|
return;
|
|
}
|
|
}
|
|
}
|