UNPKG

slotify.js

Version:

A video slot game session framework for JavaScript

125 lines (124 loc) 6.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ReelGameSession = void 0; var GameSession_1 = require("../../GameSession"); var ReelGameSessionWinCalculator_1 = require("./wincalculator/ReelGameSessionWinCalculator"); var ReelGameSession = /** @class */ (function () { function ReelGameSession(config, reelsController, winningCalculator) { this._reelsItems = []; this._config = config; this._reelsController = reelsController; this._winningCalculator = winningCalculator; this._adaptee = new GameSession_1.GameSession(this._config); this._winningAmount = 0; } ReelGameSession.getLosingCombination = function (winningCalculator, reelsController) { // TODO test var combination; combination = reelsController.getRandomItemsCombination(); winningCalculator.setGameState(1, combination); while (Object.keys(winningCalculator.getWinningLines()).length > 0 || Object.keys(winningCalculator.getWinningScatters()).length > 0) { combination = reelsController.getRandomItemsCombination(); winningCalculator.setGameState(1, combination); } return combination; }; ReelGameSession.getWinningCombinationWithScatter = function (winningCalculator, reelsController) { // TODO test var combination; combination = reelsController.getRandomItemsCombination(); winningCalculator.setGameState(1, combination); while (Object.keys(winningCalculator.getWinningLines()).length > 0 || Object.keys(winningCalculator.getWinningScatters()).length === 0) { combination = reelsController.getRandomItemsCombination(); winningCalculator.setGameState(1, combination); } return combination; }; ReelGameSession.getWinningCombinationForSymbol = function (winningCalculator, reelsController, symbolId, minLinesNumber, allowWilds, wildItemId) { if (minLinesNumber === void 0) { minLinesNumber = 1; } if (allowWilds === void 0) { allowWilds = true; } if (wildItemId === void 0) { wildItemId = ""; } // TODO test var combination; combination = reelsController.getRandomItemsCombination(); winningCalculator.setGameState(1, combination); while (Object.keys(winningCalculator.getWinningLines()).length < minLinesNumber || Object.keys(winningCalculator.getWinningScatters()).length > 0 || ReelGameSessionWinCalculator_1.ReelGameSessionWinCalculator.getLinesWithSymbol(winningCalculator.getWinningLines(), symbolId).length === 0 || !ReelGameSessionWinCalculator_1.ReelGameSessionWinCalculator.isAllLinesHasSameItemId(winningCalculator.getWinningLines()) || (!allowWilds && ReelGameSessionWinCalculator_1.ReelGameSessionWinCalculator.getLinesContainingItem(winningCalculator.getWinningLines(), combination, wildItemId).length > 0)) { combination = reelsController.getRandomItemsCombination(); winningCalculator.setGameState(1, combination); } return combination; }; ReelGameSession.getWinningCombinationWithDifferentSymbols = function (winningCalculator, reelsController) { // TODO test var combination; combination = reelsController.getRandomItemsCombination(); winningCalculator.setGameState(1, combination); while (Object.keys(winningCalculator.getWinningLines()).length <= 1 || Object.keys(winningCalculator.getWinningScatters()).length > 0 || ReelGameSessionWinCalculator_1.ReelGameSessionWinCalculator.getLinesWithDifferentSymbols(winningCalculator.getWinningLines()).length <= 1) { combination = reelsController.getRandomItemsCombination(); winningCalculator.setGameState(1, combination); } return combination; }; ReelGameSession.prototype.getReelsItems = function () { return this._reelsItems; }; ReelGameSession.prototype.getWinningLines = function () { return this._winningCalculator.getWinningLines(); }; ReelGameSession.prototype.getWinningScatters = function () { return this._winningCalculator.getWinningScatters(); }; ReelGameSession.prototype.getPaytable = function () { return this._config.paytable[this.getBet()]; }; ReelGameSession.prototype.getReelsItemsSequences = function () { return this._config.reelsItemsSequences; }; ReelGameSession.prototype.getReelsItemsNumber = function () { return this._config.reelsItemsNumber; }; ReelGameSession.prototype.getReelsNumber = function () { return this._config.reelsNumber; }; ReelGameSession.prototype.canPlayNextGame = function () { return this._adaptee.canPlayNextGame(); }; ReelGameSession.prototype.getAvailableBets = function () { return this._config.availableBets; }; ReelGameSession.prototype.getBet = function () { return this._adaptee.getBet(); }; ReelGameSession.prototype.getCreditsAmount = function () { return this._adaptee.getCreditsAmount(); }; ReelGameSession.prototype.setCreditsAmount = function (value) { this._adaptee.setCreditsAmount(value); }; ReelGameSession.prototype.getWinningAmount = function () { return this._winningAmount; }; ReelGameSession.prototype.isBetAvailable = function (bet) { return this._adaptee.isBetAvailable(bet); }; ReelGameSession.prototype.play = function () { this._adaptee.play(); this._reelsItems = this._reelsController.getRandomItemsCombination(); this._winningCalculator.setGameState(this.getBet(), this._reelsItems); this._winningAmount = this._winningCalculator.getWinningAmount(); this.setCreditsAmount(this.getCreditsAmount() + this._winningAmount); }; ReelGameSession.prototype.setBet = function (bet) { this._adaptee.setBet(bet); }; return ReelGameSession; }()); exports.ReelGameSession = ReelGameSession;