import * as ko from "knockout"; import { App } from "../app"; import { appConfig } from "../appconfig"; import { GameActionsQueue } from "../table/gameactionsqueue"; import { PlayerWinInformation } from "../table/handhistory"; import { TableView } from "../table/tableview"; import { PopupBase } from "../ui/popupbase"; declare var app: App; enum HandHistoryDisplayMode { Short = 1, Detailed, } export class HandHistoryPopup extends PopupBase { public detailedOperations: KnockoutObservableArray; public shortOperations: KnockoutObservableArray; public tableView: KnockoutObservable; public mode: KnockoutObservable; public cards: KnockoutObservableArray; public playersData: KnockoutObservableArray; public displayLoginSeparately: boolean; public showHistoryModeSelector = ko.observable(true); public isShortMode: KnockoutComputed; public isDetailedMode: KnockoutComputed; public lastHandTitle: KnockoutObservable; constructor() { super(); this.detailedOperations = ko.observableArray([]); this.shortOperations = ko.observableArray([]); this.tableView = ko.observable(); if (appConfig.game.handHistory.showPictureHistory) { this.mode = ko.observable(HandHistoryDisplayMode.Short); } else { this.mode = ko.observable(HandHistoryDisplayMode.Detailed); } this.isShortMode = ko.computed(() => { return this.mode() === HandHistoryDisplayMode.Short; }); this.isDetailedMode = ko.computed(() => { return this.mode() === HandHistoryDisplayMode.Detailed; }); this.cards = ko.observableArray([]); this.lastHandTitle = ko.observable(""); this.playersData = ko.observableArray([]); this.displayLoginSeparately = false; } public shown(): void { super.shown(); const handHistoryConfig = appConfig.game.handHistory; this.showHistoryModeSelector(handHistoryConfig.showPictureHistory && handHistoryConfig.showTextHistory); const view = this.tableView(); const lastHand = view.lastHandHistory(); this.detailedOperations(lastHand.detailedOperations()); this.shortOperations(lastHand.shortOperations()); this.cards(lastHand.cards()); this.lastHandTitle("История раздачи №" + lastHand.id); this.playersData(lastHand.playersData()); GameActionsQueue.waitDisabled = true; app.tablesPage.tablesShown(false); app.popupClosed.addOnce(function (popupName: string) { if (popupName === "handHistory") { GameActionsQueue.waitDisabled = false; app.tablesPage.tablesShown(true); } }, this, 0); } public selectMode(mode: HandHistoryDisplayMode) { this.mode(mode); } public selectShortMode() { this.mode(HandHistoryDisplayMode.Short); } public selectDetailedMode() { this.mode(HandHistoryDisplayMode.Detailed); } }