RonaldoSetzer/GAME-Minesweeper

View on GitHub
src/minesweeper/mediators/YouWinPopupMediator.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { inject, injectable } from "@robotlegsjs/core";
import { Mediator } from "@robotlegsjs/pixi";

import { LevelModel } from "./../game/models/LevelModel";
import { FlowService } from "./../services/FlowService";
import { GameService } from "./../services/GameService";
import { YouWinPopup } from "./../views/YouWinPopup";

@injectable()
export class YouWinPopupMediator extends Mediator<YouWinPopup> {
    @inject(FlowService) public flowService: FlowService;
    @inject(GameService) public gameService: GameService;
    @inject(LevelModel) public levelModel: LevelModel;

    public initialize(): void {
        this.view.animationIn();
        this.view.showInfo(this.levelModel.clock, this.levelModel.numClicks);
        this.eventMap.mapListener(this.view.homeButton, "click", this.homeButton_onClick, this);
        this.eventMap.mapListener(this.view.retryButton, "click", this.retryButton_onClick, this);
    }
    public destroy(): void {
        this.eventMap.unmapListeners();
    }
    private homeButton_onClick(e: any): void {
        this.flowService.setHomeView();
        this.flowService.closePopup();
    }
    private retryButton_onClick(e: any): void {
        this.flowService.closePopup();
        this.gameService.retryCommand();
    }
}