function initSplash() { gameState = "splash"; resizeCanvas(); splash = new Elements.Splash(assetLib.getData("splash"), canvas.width, canvas.height); previousTime = (new Date).getTime(); updateSplashScreenEvent() } function resetDeck() { aDeck = new Array; for (var e = 0; e < 52; e++) { aDeck.push({ id: e, value: e % 13 + 1 }) } } function initStartScreen() { sdr(); } function sdr() { gameState = "start"; if (allowSound) {} bet = 0; bank = 1e3; userInput.addHitArea("mute", butEventHandler, null, { type: "rect", aRect: [455, 0, canvas.width, 75] }, true); userInput.addHitArea("help", butEventHandler, null, { type: "rect", aRect: [0, 0, 80, 75] }, true); userInput.addHitArea("moregames", butEventHandler, null, { type: "rect", aRect: [canvas.width / 2 - 100, 100, canvas.width / 2 + 100, 150] }, true); var e = new Array(canvas.width / 2, 600); var t = new Array(canvas.width / 2, 750); screens = new Elements.Screens({ startImageData: assetLib.getData("titleScreen") }, { moregames: { imageData: assetLib.getData("sgLogo"), pos: t }, play: { imageData: assetLib.getData("playBut"), pos: e } }, canvas.width, canvas.height); screens.setRenderFunc("start"); userInput.addHitArea("startGame", butEventHandler, e, { type: "image", oImageData: assetLib.getData("playBut"), aCentrePos: e }); userInput.addHitArea("moregames", SG.redirectToPortal, t, { type: "image", oImageData: assetLib.getData("sgLogo"), aCentrePos: t }); previousTime = (new Date).getTime(); updateStartScreenEvent() } function initBetting() { gameState = "betting"; insuranceTaken = false; if (bank < 2e3) { chipLevel = 0 } else if (bank < 1e4) { chipLevel = 1 } else { chipLevel = 2 } if (allowSound) {} playSound("chipIntro"); userInput.addHitArea("quitGameBetting", butEventHandler, null, { type: "rect", aRect: [0, 0, 80, 75] }, true); userInput.addHitArea("addChip", butEventHandler, { id: 0 }, { type: "rect", aRect: [0, 630, 133, 758] }); userInput.addHitArea("addChip", butEventHandler, { id: 1 }, { type: "rect", aRect: [133, 630, 266, 758] }); userInput.addHitArea("addChip", butEventHandler, { id: 2 }, { type: "rect", aRect: [266, 630, 399, 758] }); userInput.addHitArea("addChip", butEventHandler, { id: 3 }, { type: "rect", aRect: [399, 630, 533, 758] }); userInput.addHitArea("removeChip", butEventHandler, null, { type: "rect", aRect: [170, 390, 360, 530] }); userInput.addHitArea("deal", butEventHandler, null, { type: "rect", aRect: [390, 390, canvas.width, 530] }); background = new Elements.Background(assetLib.getData("background"), canvas.width, canvas.height); numbers = new Elements.Numbers(assetLib.getData("numbers"), canvas.width, canvas.height); numbers.setAmounts(bet, bank); panel = new Elements.Panel(assetLib.getData("panels"), assetLib.getData("numbers"), canvas.width, canvas.height); panel.setUp("betting"); chips = new Elements.Chips(assetLib.getData("chips"), chipLevel, aChipAmounts, canvas.width, canvas.height); chips.setAmounts(bet, bank); chips.setUp("betting"); previousTime = (new Date).getTime(); updateBettingEvent() } function initHelp() { gameState = "help"; userInput.addHitArea("quitHelp", butEventHandler, null, { type: "rect", aRect: [0, 0, 80, 75] }, true); ctx.drawImage(assetLib.getData("helpScreen").img, 0, 0) } function initDeal() { gameState = "dealing"; resetDeck(); playSound("cardHard"); userInput.addHitArea("quitGameDealing", butEventHandler, null, { type: "rect", aRect: [0, 0, 80, 75] }, true); userInput.addHitArea("hit", butEventHandler, null, { type: "rect", aRect: [266, 630, 399, 758] }); userInput.addHitArea("stand", butEventHandler, null, { type: "rect", aRect: [399, 630, 533, 758] }); aPCards2 = new Array; aPCards1 = aCurPlayerCards = getCards(2); aCompCards = getCards(1); if (roundToTen(this.aCurPlayerCards[0].value) + roundToTen(this.aCurPlayerCards[1].value) == 11 && (this.aCurPlayerCards[0].value == 1 || this.aCurPlayerCards[1].value == 1)) { dealType = "blackjack" } else if (roundToTen(this.aCurPlayerCards[0].value) == roundToTen(this.aCurPlayerCards[1].value) && bank >= bet) { dealType = "split"; userInput.addHitArea("split", butEventHandler, null, { type: "rect", aRect: [0, 630, 133, 758] }) } else { dealType = "normal" } var e = false; var t = false; if (aCompCards[0].value == 1 && bank >= bet) { userInput.addHitArea("insure", butEventHandler, null, { type: "rect", aRect: [0, 200, 150, 350] }); e = true } if (bank >= bet) { userInput.addHitArea("double", butEventHandler, null, { type: "rect", aRect: [133, 630, 266, 758] }); t = true } panel.setUp("firstDeal", { dealType: dealType, insuranceIsOn: e, value: getBestValue(this.aCurPlayerCards), callback: initBlackjackCompare }); cards = new Elements.Cards(assetLib.getData("cards"), canvas.width, canvas.height); cards.setUp("firstDeal", { aPlayerDealtCards: this.aCurPlayerCards, aCompDealtCards: this.aCompCards, dealType: dealType }); chips.setUp("firstDeal"); previousTime = (new Date).getTime(); buttons = new Elements.Buttons(assetLib.getData("buttons"), canvas.width, canvas.height); buttons.setUp("firstDeal", { dealType: dealType, doubleIsOn: t }); updateDealingEvent() } function initBlackjackCompare() { var e = getCards(1)[0]; aCompCards.push(e); panel.setUp("compPlay", { value: getBestValue(aCompCards) }); cards.setUp("compPlay", { oHoleCard: e, callback: checkBlackjack }) } function initCompPlay() { var e; if (!insuranceTaken) { e = getCards(1)[0] } else { e = insuranceCard } aCompCards.push(e); playSound("cardSoft"); panel.setUp("compPlay", { value: getBestValue(aCompCards) }); cards.setUp("compPlay", { oHoleCard: e, callback: checkHands }) } function dealNewCompCard() { var e = getCards(1)[0]; aCompCards.push(e); playSound("cardSoft"); panel.setUp("newCompCard", { value: getBestValue(aCompCards) }); cards.setUp("newCompCard", { oNewCard: e, callback: checkHands }) } function initCompShow() { var e = getCards(1)[0]; aCompCards.push(e); playSound("cardSoft"); cards.setUp("compShow", { oHoleCard: e }) } function initCompInsuranceShow() { aCompCards.push(insuranceCard); playSound("cardSoft"); panel.setUp("compPlay", { value: getBestValue(aCompCards) }); cards.setUp("compInsuranceShow", { oHoleCard: insuranceCard, callback: checkInsuranceHand }) } function checkInsuranceHand() { var e = getBestValue(aCompCards); if (e == 21) { bank += Math.round(bet * 1.5); bet = 0; // Play68.setRankingScoreDesc(bank); numbers.setAmounts(bet, bank); userInput.removeHitArea("split"); userInput.removeHitArea("double"); userInput.removeHitArea("hit"); userInput.removeHitArea("stand"); panel.setUp("insuranceWin"); buttons.setUp("insuranceWin"); userInput.addHitArea("replay", butEventHandler, null, { type: "rect", aRect: [390, 390, canvas.width, 530] }) } else { buttons.canHit = true } } function checkHands() { var e = getBestValue(aCompCards); var t = getBestValue2(aPCards1, aPCards2); if (e > 21) { console.log("1"); SG.trigger({ type: "gameOver" }); panel.setUp("compBust"); playSound("win"); bank += bet * 2; bet = 0; // Play68.setRankingScoreDesc(bank); numbers.setAmounts(bet, bank); userInput.removeHitArea("split"); userInput.removeHitArea("double"); userInput.removeHitArea("hit"); userInput.removeHitArea("stand"); userInput.addHitArea("replay", butEventHandler, null, { type: "rect", aRect: [390, 390, canvas.width, 530] }) } else if (e > 16) { if (e > t) { console.log("2"); SG.trigger({ type: "gameOver" }); panel.setUp("compWin", { bank: bank }); playSound("bust"); if (bank < 5) { bank = 1e3 } bet = 0; // Play68.setRankingScoreDesc(bank); numbers.setAmounts(bet, bank); userInput.removeHitArea("split"); userInput.removeHitArea("double"); userInput.removeHitArea("hit"); userInput.removeHitArea("stand"); userInput.addHitArea("replay", butEventHandler, null, { type: "rect", aRect: [390, 390, canvas.width, 530] }) } else if (e < t) { console.log("3"); SG.trigger({ type: "gameOver" }); panel.setUp("playerWin"); playSound("win"); bank += bet * 2; bet = 0; // Play68.setRankingScoreDesc(bank); numbers.setAmounts(bet, bank); userInput.removeHitArea("split"); userInput.removeHitArea("double"); userInput.removeHitArea("hit"); userInput.removeHitArea("stand"); userInput.addHitArea("replay", butEventHandler, null, { type: "rect", aRect: [390, 390, canvas.width, 530] }) } else { console.log("4"); SG.trigger({ type: "gameOver" }); panel.setUp("push"); playSound("push"); bank += bet; bet = 0; // Play68.setRankingScoreDesc(bank); numbers.setAmounts(bet, bank); userInput.removeHitArea("split"); userInput.removeHitArea("double"); userInput.removeHitArea("hit"); userInput.removeHitArea("stand"); userInput.addHitArea("replay", butEventHandler, null, { type: "rect", aRect: [390, 390, canvas.width, 530] }) } } else { dealNewCompCard() } } function checkBlackjack() { var e = getBestValue(aCompCards); if (e == 21) { console.log("push"); panel.setUp("push"); playSound("push"); bank += bet; bet = 0; // Play68.setRankingScoreDesc(bank); numbers.setAmounts(bet, bank); userInput.removeHitArea("split"); userInput.removeHitArea("double"); userInput.removeHitArea("hit"); userInput.removeHitArea("stand"); userInput.addHitArea("replay", butEventHandler, null, { type: "rect", aRect: [390, 390, canvas.width, 530] }) } else { panel.setUp("blackjack"); playSound("blackjack"); bank += bet + Math.round(bet *= 1.5); bet = 0; // Play68.setRankingScoreDesc(bank); numbers.setAmounts(bet, bank); userInput.removeHitArea("split"); userInput.removeHitArea("double"); userInput.removeHitArea("hit"); userInput.removeHitArea("stand"); userInput.addHitArea("replay", butEventHandler, null, { type: "rect", aRect: [390, 390, canvas.width, 530] }) } } function roundToTen(e) { if (e > 10) { e = 10 } return e } function getBestValue(e) { var t = 0; var n = 0; for (var r = 0; r < e.length; r++) { if (e[r].value == 1) { n++; t += 11 } else { t += roundToTen(e[r].value) } } if (t > 21) { for (var r = 0; r < n; r++) { t -= 10; if (t <= 21) { break } } } return t } function getBestValue2(e, t) { var n = getBestValue(e); var r = getBestValue(t); if (n > 22) { return r } else if (r > 22) { return n } else { if (n > r) { return n } else { return r } } } function getCards(e) { var t = new Array; for (var n = 0; n < e; n++) { if (aDeck.length > 0) { var r = Math.floor(Math.random() * aDeck.length); t.push(aDeck[r]); aDeck.splice(r, 1) } else { break } } return t } function dealNewPlayerCard(e) { if (typeof e === "undefined") { e = false } var t = getCards(1)[0]; aCurPlayerCards.push(t); panel.setUp("newPlayerCard", { value: getBestValue(aCurPlayerCards) }); if (getBestValue(aCurPlayerCards) > 21) { if (!splitTaken) { if (getBestValue(aPCards1) > 21) { console.log("5"); SG.trigger({ type: "gameOver" }); panel.setUp("bust", { bank: bank }); if (bank < 5) { bank = 1e3 } buttons.setUp("bust"); chips.setUp("bust"); playSound("bust"); bet = 0; // Play68.setRankingScoreDesc(bank); numbers.setAmounts(bet, bank); userInput.removeHitArea("split"); userInput.removeHitArea("double"); userInput.removeHitArea("hit"); userInput.removeHitArea("stand"); userInput.addHitArea("replay", butEventHandler, null, { type: "rect", aRect: [390, 390, canvas.width, 530] }); cards.setUp("newPlayerCard", { newCard: t, callback: initCompShow }) } else { console.log("6"); SG.trigger({ type: "gameOver" }); userInput.removeHitArea("split"); userInput.removeHitArea("double"); userInput.removeHitArea("hit"); userInput.removeHitArea("stand"); buttons.setUp("stand"); panel.setUp("stand"); initCompPlay() } } else { splitTaken = false; cards.setUp("newPlayerCard", { newCard: t }); panel.setUp("switchHands", { callback: dealNewPlayerCard, event: "bust" }); bet /= 2; // Play68.setRankingScoreDesc(bank); numbers.setAmounts(bet, bank); cards.setUp("switchHands"); aCurPlayerCards = aPCards2 } } else if (e) { cards.setUp("newPlayerCard", { newCard: t, callback: initCompPlay }) } else { cards.setUp("newPlayerCard", { newCard: t }) } } function butEventHandler(e, t) { switch (e) { case "langSelect": curLang = t.lang; ctx.clearRect(0, 0, canvas.width, canvas.height); userInput.removeHitArea("langSelect"); initLoadAssets(); break; case "replay": playSound("click"); userInput.removeHitArea("replay"); userInput.removeHitArea("quitGameDealing"); bet = 0; numbers.setAmounts(bet, bank); initBetting(); break; case "split": if (buttons.canHit) { playSound("click"); splitTaken = true; aPCards2 = new Array; aPCards2.push(aCurPlayerCards.pop()); aPCards1 = aCurPlayerCards; bank -= bet; bet *= 2; numbers.setAmounts(bet, bank); userInput.removeHitArea("split"); userInput.removeHitArea("double"); buttons.setUp("split"); cards.setUp("split"); dealNewPlayerCard(); panel.setUp("split", { playerHandTotal1: getBestValue(aPCards1), playerHandTotal2: getBestValue(aPCards2) }); if (insuranceTaken) { panel.setUp("hidePlayOn") } } break; case "double": if (buttons.canHit) { playSound("cardSoft"); bank -= bet; bet *= 2; userInput.removeHitArea("split"); userInput.removeHitArea("double"); userInput.removeHitArea("hit"); userInput.removeHitArea("stand"); numbers.setAmounts(bet, bank); buttons.setUp("double"); chips.setUp("double"); dealNewPlayerCard(true); if (insuranceTaken) { panel.setUp("hidePlayOn") } } break; case "hit": if (buttons.canHit) { playSound("cardSoft"); userInput.removeHitArea("split"); userInput.removeHitArea("double"); buttons.setUp("hit"); dealNewPlayerCard(); if (insuranceTaken) { panel.setUp("hidePlayOn") } } break; case "stand": if (buttons.canHit) { playSound("click"); if (!splitTaken) { userInput.removeHitArea("split"); userInput.removeHitArea("double"); userInput.removeHitArea("hit"); userInput.removeHitArea("stand"); buttons.setUp("stand"); panel.setUp("stand"); initCompPlay() } else { splitTaken = false; panel.setUp("switchHands", { callback: dealNewPlayerCard }); cards.setUp("switchHands"); aCurPlayerCards = aPCards2 } if (insuranceTaken) { panel.setUp("hidePlayOn") } } break; case "startGame": playSound("click"); userInput.removeHitArea("startGame"); userInput.removeHitArea("help"); initBetting(); break; case "help": playSound("click"); userInput.removeHitArea("startGame"); userInput.removeHitArea("help"); initHelp(); break; case "quitHelp": playSound("click"); userInput.removeHitArea("quitHelp"); initStartScreen(); break; case "mute": playSound("click"); toggleMute(); break; case "quitGameBetting": playSound("click"); userInput.removeHitArea("quitGameBetting"); userInput.removeHitArea("addChip"); userInput.removeHitArea("removeChip"); userInput.removeHitArea("deal"); initStartScreen(); break; case "quitGameDealing": playSound("click"); userInput.removeHitArea("quitGameDealing"); userInput.removeHitArea("split"); userInput.removeHitArea("double"); userInput.removeHitArea("hit"); userInput.removeHitArea("stand"); userInput.removeHitArea("insure"); userInput.removeHitArea("replay"); initStartScreen(); break; case "addChip": if (aChipAmounts[t.id] <= bank) { playSound("chip"); panel.showDealBut(); bet += aChipAmounts[t.id + chipLevel]; bank -= aChipAmounts[t.id + chipLevel]; numbers.setAmounts(bet, bank); chips.addChip(t.id, bet, bank) } break; case "removeChip": if (bet >= 5) { playSound("click"); bet -= aChipAmounts[chips.aBetChips[chips.aBetChips.length - 1] + chipLevel]; bank += aChipAmounts[chips.aBetChips[chips.aBetChips.length - 1] + chipLevel]; numbers.setAmounts(bet, bank); chips.removeChip(bet, bank); if (bet <= 0) { panel.hideDealBut() } } break; case "deal": if (bet > 0) { playSound("click"); userInput.removeHitArea("quitGameBetting"); userInput.removeHitArea("addChip"); userInput.removeHitArea("removeChip"); userInput.removeHitArea("deal"); initDeal() } break; case "insure": playSound("click"); insuranceCard = getCards(1)[0]; bank -= Math.round(bet / 2); numbers.setAmounts(bet, bank); insuranceTaken = true; if (roundToTen(insuranceCard.value) == 10) { panel.setUp("insuranceTaken"); initCompInsuranceShow(); buttons.canHit = false } else { panel.setUp("insuranceLose") } break } } function updateDealingEvent() { if (rotatePause || gameState != "dealing") { return } var e = getDelta(); background.render(ctx); numbers.render(ctx); chips.render(ctx); cards.render(ctx); buttons.render(ctx); panel.render(ctx); requestAnimFrame(updateDealingEvent) } function updateBettingEvent() { if (rotatePause || gameState != "betting") { return } var e = getDelta(); background.render(ctx); numbers.render(ctx); chips.render(ctx); panel.render(ctx); requestAnimFrame(updateBettingEvent) } function updateSplashScreenEvent() { if (rotatePause || gameState != "splash") { return } var e = getDelta(); splashTimer += e; if (splashTimer > 2.5) { initStartScreen(); return } splash.render(ctx, e); requestAnimFrame(updateSplashScreenEvent) } function updateStartScreenEvent() { if (rotatePause || gameState != "start") { return } var e = getDelta(); screens.render(ctx, e); requestAnimFrame(updateStartScreenEvent) } function getDelta() { var e = (new Date).getTime(); var t = (e - previousTime) / 1e3; previousTime = e; if (t > .5) { t = 0 } return t } function renderSprite(e) { ctx.save(); ctx.translate(e.x, e.y); ctx.rotate(e.rotation); e.render(ctx); ctx.restore() } function loadPreAssets() { if (aLangs.length > 1) { preAssetLib = new Utils.AssetLoader(curLang, [{ id: "langSelect", file: "images/langSelect.jpg" }, { id: "preloadImage", file: "images/preloadImage.jpg" }], ctx, canvas.width, canvas.height, false); if (curLang == null) preAssetLib.onReady(initLangSelect); else preAssetLib.onReady(loadAssets) } else { curLang = aLangs[0]; preAssetLib = new Utils.AssetLoader(curLang, [{ id: "preloadImage", file: "images/preloadImage.jpg" }], ctx, canvas.width, canvas.height, false); preAssetLib.onReady(initLoadAssets) } } function initLangSelect() { var e = preAssetLib.getData("langSelect"); ctx.drawImage(e.img, canvas.width / 2 - e.img.width / 2, canvas.height / 2 - e.img.height / 2); var t = 140; for (var n = 0; n < aLangs.length; n++) { var r = canvas.width / 2 - t * aLangs.length / 2 + n * t; var i = canvas.height / 2 - t / 2; userInput.addHitArea("langSelect", butEventHandler, { lang: aLangs[n] }, { type: "rect", aRect: [r, i, r + t, i + 140] }) } } function initLoadAssets() { var e = preAssetLib.getData("preloadImage"); ctx.drawImage(e.img, canvas.width / 2 - e.img.width / 2, canvas.height / 2 - e.img.height - 10); loadAssets() } function loadAssets() { assetLib = new Utils.AssetLoader(curLang, [{ id: "background", file: "images/" + curLang + "/background.jpg" }, { id: "helpScreen", file: "images/" + curLang + "/helpScreen.jpg" }, { id: "titleScreen", file: "images/" + curLang + "/titleScreen.jpg" }, { id: "rotateDeviceMessage", file: "images/rotateDeviceMessage.jpg" }, { id: "splash", file: "images/splashScreen.jpg" }, { id: "playBut", file: "images/" + curLang + "/playBut.png" }, { id: "sgLogo", file: SG.getLogoUrl() }, { id: "panels", file: "images/" + curLang + "/panels_379x159.png", oData: { columns: 4, spriteWidth: 379, spriteHeight: 159 } }, { id: "numbers", file: "images/numbers_17x36.png", oData: { columns: 3, spriteWidth: 17, spriteHeight: 36 } }, { id: "cards", file: "images/cards_128x173.png", oData: { columns: 9, spriteWidth: 128, spriteHeight: 173 } }, { id: "buttons", file: "images/" + curLang + "/buttons_131x133.png", oData: { columns: 4, spriteWidth: 131, spriteHeight: 133 } }, { id: "chips", file: "images/chips_133x133.png", oData: { columns: 2, spriteWidth: 133, spriteHeight: 133 } }], ctx, canvas.width, canvas.height); if (allowSound && !muted) {} assetLib.onReady(initStartScreen) } function resizeCanvas() { var e = window.innerWidth; var t = window.innerHeight; if (e > 480) { e -= 1; t -= 1 } if (window.innerWidth > window.innerHeight && isMobile) { if (gameState != "loading") { rotatePauseOn() } if (e / canvas.width < t / canvas.height) { canvas.style.width = e + "px"; canvas.style.height = e / canvas.width * canvas.height + "px"; canvasX = 0; canvasY = (t - e / canvas.width * canvas.height) / 2; canvasScaleX = canvasScaleY = canvas.width / e; div.style.marginTop = canvasY + "px"; div.style.marginLeft = canvasX + "px" } else { canvas.style.width = t / canvas.height * canvas.width + "px"; canvas.style.height = t + "px"; canvasX = (e - t / canvas.height * canvas.width) / 2; canvasY = 0; canvasScaleX = canvasScaleY = canvas.height / t; div.style.marginTop = canvasY + "px"; div.style.marginLeft = canvasX + "px" } } else if (!isMobile) { if (rotatePause) { rotatePauseOff() } if (e / canvas.width < t / canvas.height) { canvas.style.width = e + "px"; canvas.style.height = e / canvas.width * canvas.height + "px"; canvasX = 0; canvasY = (t - e / canvas.width * canvas.height) / 2; canvasScaleX = canvasScaleY = canvas.width / e; div.style.marginTop = canvasY + "px"; div.style.marginLeft = canvasX + "px" } else { canvas.style.width = t / canvas.height * canvas.width + "px"; canvas.style.height = t + "px"; canvasX = (e - t / canvas.height * canvas.width) / 2; canvasY = 0; canvasScaleX = canvasScaleY = canvas.height / t; div.style.marginTop = canvasY + "px"; div.style.marginLeft = canvasX + "px" } } else { if (rotatePause) { rotatePauseOff() } canvasX = canvasY = 0; canvasScaleX = canvas.width / e; canvasScaleY = canvas.height / t; canvas.style.width = e + "px"; canvas.style.height = t + "px"; div.style.marginTop = 0 + "px"; div.style.marginLeft = 0 + "px" } userInput.setCanvas(canvasX, canvasY, canvasScaleX, canvasScaleY) } function playSound(e) { if (allowSound) { sound.play(e) } } function toggleMute() { muted = !muted; if (allowSound) { if (muted) { Howler.mute() } else { Howler.unmute() } } } function toggleManualPause() { if (!manualPause) { manualPause = true; if (allowSound) { Howler.mute() } pauseCoreOn() } else { manualPause = false; if (allowSound) { if (!muted) { Howler.unmute() } } pauseCoreOff() } } function rotatePauseOn() { rotatePause = true; ctx.drawImage(assetLib.getImg("rotateDeviceMessage"), 0, 0); pauseCoreOn() } function rotatePauseOff() { rotatePause = false; pauseCoreOff() } function pauseCoreOn() { userInput.pauseIsOn = true; switch (gameState) { case "start": break; case "betting": break; case "dealing": break } } function pauseCoreOff() { previousTime = (new Date).getTime(); userInput.pauseIsOn = false; switch (gameState) { case "splash": updateSplashScreenEvent(); break; case "start": initStartScreen(); break; case "help": initHelp(); break; case "betting": updateBettingEvent(); break; case "dealing": updateDealingEvent(); break } } var Utils; (function(e) { var t = function() { function e(e, t, n, r, i, s) { if (typeof s === "undefined") { s = true } this.oAssetData = {}; this.assetsLoaded = 0; this.totalAssets = t.length; this.ctx = n; this.canvasWidth = r; this.canvasHeight = i; this.showBar = s; this.topLeftX = this.canvasWidth / 2 - r / 4; this.topLeftY = this.canvasHeight / 2; if (this.showBar) { var o; if (e == "EN" || e == "") { o = "加载中..." } else if (e == "ES") { o = "Cargando..." } else if (e == "FR") { o = "Chargement..." } else if (e == "TR") { o = "Yükleme..." } ctx.fillStyle = "#aaaaaa"; ctx.textAlign = "center"; ctx.font = "14px Helvetica"; ctx.fillText(o, this.canvasWidth / 2, this.topLeftY + 35); ctx.strokeStyle = "#aaaaaa"; ctx.lineWidth = 2; ctx.fillStyle = "#ffffff"; ctx.moveTo(this.topLeftX, this.topLeftY); ctx.lineTo(this.topLeftX + r / 2, this.topLeftY + 0); ctx.lineTo(this.topLeftX + r / 2, this.topLeftY + 20); ctx.lineTo(this.topLeftX + 0, this.topLeftY + 20); ctx.lineTo(this.topLeftX + 0, this.topLeftY + 0); ctx.stroke() } for (var u = 0; u < t.length; u++) { this.loadImage(t[u]) } } e.prototype.loadImage = function(e) { var t = this; var n = new Image; n.onload = function() { t.oAssetData[e.id] = {}; t.oAssetData[e.id].img = n; if (e.oData != undefined) { t.oAssetData[e.id].oData = e.oData }++t.assetsLoaded; if (t.showBar) { ctx.fillRect(t.topLeftX + 2, t.topLeftY + 2, (t.canvasWidth / 2 - 4) / t.totalAssets * t.assetsLoaded, 16) } t.checkLoadComplete() }; n.src = e.file }; e.prototype.checkLoadComplete = function() { if (this.assetsLoaded == this.totalAssets) { this.loadedCallback() } }; e.prototype.onReady = function(e) { this.loadedCallback = e }; e.prototype.getImg = function(e) { return this.oAssetData[e].img }; e.prototype.getData = function(e) { return this.oAssetData[e] }; return e }(); e.AssetLoader = t })(Utils || (Utils = {})); var Utils; (function(e) { var t = function() { function e(e, t, n, r) { this.x = 0; this.y = 0; this.rotation = 0; this.radius = 10; this.removeMe = false; this.frameInc = 0; this.animType = "loop"; this.oImgData = e; this.oAnims = this.oImgData.oData.oAnims; this.fps = t; this.radius = n; this.animId = r } e.prototype.updateAnimation = function(e) { this.frameInc += this.fps * e }; e.prototype.resetAnim = function() { this.frameInc = 0 }; e.prototype.setFrame = function(e) { this.fixedFrame = e }; e.prototype.setAnimType = function(e, t) { this.animId = t; this.animType = e; switch (e) { case "loop": break; case "once": this.resetAnim(); this.maxIdx = this.oAnims[this.animId].length - 1; break } }; e.prototype.render = function(e) { if (this.animId != null) { var t = this.oAnims[this.animId].length; var n = Math.floor(this.frameInc); var r = this.oAnims[this.animId][n % t]; var i = r * this.oImgData.oData.spriteWidth % this.oImgData.img.width; var s = Math.floor(r / (this.oImgData.img.width / this.oImgData.oData.spriteWidth)) * this.oImgData.oData.spriteHeight; if (this.animType == "once") { if (n > this.maxIdx) { this.fixedFrame = this.oAnims[this.animId][t - 1]; this.animId = null; this.animEndedFunc(); var i = this.fixedFrame * this.oImgData.oData.spriteWidth % this.oImgData.img.width; var s = Math.floor(this.fixedFrame / (this.oImgData.img.width / this.oImgData.oData.spriteWidth)) * this.oImgData.oData.spriteHeight } } } else { var i = this.fixedFrame * this.oImgData.oData.spriteWidth % this.oImgData.img.width; var s = Math.floor(this.fixedFrame / (this.oImgData.img.width / this.oImgData.oData.spriteWidth)) * this.oImgData.oData.spriteHeight } e.drawImage(this.oImgData.img, i, s, this.oImgData.oData.spriteWidth, this.oImgData.oData.spriteHeight, -this.oImgData.oData.spriteWidth / 2, -this.oImgData.oData.spriteHeight / 2, this.oImgData.oData.spriteWidth, this.oImgData.oData.spriteHeight) }; return e }(); e.AnimSprite = t })(Utils || (Utils = {})); var Utils; (function(e) { var t = function() { function e(e, t) { this.x = 0; this.y = 0; this.rotation = 0; this.radius = 10; this.removeMe = false; this.oImgData = e; this.radius = t } e.prototype.setFrame = function(e) { this.frameNum = e }; e.prototype.render = function(e) { var t = this.frameNum * this.oImgData.oData.spriteWidth % this.oImgData.img.width; var n = Math.floor(this.frameNum / (this.oImgData.img.width / this.oImgData.oData.spriteWidth)) * this.oImgData.oData.spriteHeight; e.drawImage(this.oImgData.img, t, n, this.oImgData.oData.spriteWidth, this.oImgData.oData.spriteHeight, -this.oImgData.oData.spriteWidth / 2, -this.oImgData.oData.spriteHeight / 2, this.oImgData.oData.spriteWidth, this.oImgData.oData.spriteHeight) }; return e }(); e.BasicSprite = t })(Utils || (Utils = {})); var Utils; (function(e) { var t = function() { function e(e, t) { var n = this; this.isDown = false; this.canvasX = 0; this.canvasY = 0; this.canvasScaleX = 1; this.canvasScaleY = 1; this.prevHitTime = 0; this.pauseIsOn = false; this.isBugBrowser = t; e.addEventListener("touchstart", function(e) { n.hitDown(e, e.touches[0].pageX, e.touches[0].pageY) }, false); e.addEventListener("touchend", function(e) { n.hitUp(e, e.changedTouches[0].pageX, e.changedTouches[0].pageY) }, false); e.addEventListener("mousedown", function(e) { n.hitDown(e, e.pageX, e.pageY) }, false); e.addEventListener("mouseup", function(e) { n.hitUp(e, e.pageX, e.pageY) }, false); this.aHitAreas = new Array } e.prototype.setCanvas = function(e, t, n, r) { this.canvasX = e; this.canvasY = t; this.canvasScaleX = n; this.canvasScaleY = r }; e.prototype.hitDown = function(e, t, n) { if (this.pauseIsOn) { return } var r = (new Date).getTime(); if (r - this.prevHitTime < 500 && isBugBrowser) { return } this.prevHitTime = r; e.preventDefault(); e.stopPropagation(); t = (t - this.canvasX) * this.canvasScaleX; n = (n - this.canvasY) * this.canvasScaleY; for (var i = 0; i < this.aHitAreas.length; i++) { if (this.aHitAreas[i].rect) { if (t > this.aHitAreas[i].area[0] && n > this.aHitAreas[i].area[1] && t < this.aHitAreas[i].area[2] && n < this.aHitAreas[i].area[3]) { this.aHitAreas[i].oData.hitX = t; this.aHitAreas[i].oData.hitY = n; this.aHitAreas[i].callback(this.aHitAreas[i].id, this.aHitAreas[i].oData); break } } else {} } }; e.prototype.hitUp = function(e, t, n) { e.preventDefault(); e.stopPropagation() }; e.prototype.addHitArea = function(e, t, n, r, i) { if (typeof i === "undefined") { i = false } if (n == null) { n = new Object } if (i) { this.removeHitArea(e) } switch (r.type) { case "image": if (r.oImageData.isSpriteSheet) { this.aHitAreas.push({ id: e, callback: t, oData: n, rect: true, area: [r.aCentrePos[0] - r.oImageData.oData.spriteHeight / 2, r.aCentrePos[1] - r.oImageData.oData.spriteHeight / 2, r.aCentrePos[0] + r.oImageData.oData.spriteWidth / 2, r.aCentrePos[1] + r.oImageData.oData.spriteHeight / 2] }) } else { this.aHitAreas.push({ id: e, callback: t, oData: n, rect: true, area: [r.aCentrePos[0] - r.oImageData.img.width / 2, r.aCentrePos[1] - r.oImageData.img.height / 2, r.aCentrePos[0] + r.oImageData.img.width / 2, r.aCentrePos[1] + r.oImageData.img.height / 2] }) } break; case "rect": this.aHitAreas.push({ id: e, callback: t, oData: n, rect: true, area: r.aRect }); break } }; e.prototype.removeHitArea = function(e) { for (var t = 0; t < this.aHitAreas.length; t++) { if (this.aHitAreas[t].id == e) { this.aHitAreas.splice(t, 1); t -= 1 } } }; return e }(); e.UserInput = t })(Utils || (Utils = {})); var Utils; (function(e) { var t = function() { function e(e) { this.updateFreq = 10; this.updateInc = 0; this.frameAverage = 0; this.display = 1; this.log = ""; this.render = function(e) { this.frameAverage += this.delta / this.updateFreq; if (++this.updateInc >= this.updateFreq) { this.updateInc = 0; this.display = this.frameAverage; this.frameAverage = 0 } e.textAlign = "left"; ctx.font = "10px Helvetica"; e.fillStyle = "#333333"; e.beginPath(); e.rect(0, this.canvasHeight - 15, 40, 15); e.closePath(); e.fill(); e.fillStyle = "#ffffff"; e.fillText(Math.round(1e3 / (this.display * 1e3)) + " fps " + this.log, 5, this.canvasHeight - 5) }; this.canvasHeight = e } e.prototype.update = function(e) { this.delta = e }; return e }(); e.FpsMeter = t })(Utils || (Utils = {})); var Elements; (function(e) { var t = function() { function e(e, t, n) { this.oImgData = e; this.canvasWidth = t; this.canvasHeight = n } e.prototype.update = function(e) {}; e.prototype.render = function(e) { e.drawImage(this.oImgData.img, 0, 0) }; return e }(); e.Background = t })(Elements || (Elements = {})); var Elements; (function(e) { var t = function() { function e(e, t, n, r) { this.incY = 0; this.score = 0; this.highestScore = 0; this.posY = 0; this.oScreens = e; this.oButs = t; this.canvasWidth = n; this.canvasHeight = r; this.posY = -this.canvasHeight } e.prototype.setRenderFunc = function(e) { this.posY = -this.canvasHeight; switch (e) { case "start": this.renderFunc = this.renderStartScreen; TweenLite.to(this, .5, { posY: 0 }); break; case "help": break; case "end": break } }; e.prototype.render = function(e, t) { this.renderFunc(e, t) }; e.prototype.renderStartScreen = function(e, t) { this.incY += 5 * t; e.drawImage(this.oScreens.startImageData.img, 0, 0); e.drawImage(this.oButs.play.imageData.img, this.oButs.play.pos[0] - this.oButs.play.imageData.img.width / 2, this.oButs.play.pos[1] - this.oButs.play.imageData.img.height / 2 - Math.sin(this.incY) * 5 - this.posY); e.drawImage(this.oButs.moregames.imageData.img, this.oButs.moregames.pos[0] - this.oButs.moregames.imageData.img.width / 2, this.oButs.moregames.pos[1] - this.oButs.moregames.imageData.img.height / 2 - Math.sin(this.incY) * 5 - this.posY) }; return e }(); e.Screens = t })(Elements || (Elements = {})); var Elements; (function(e) { var t = function() { function e(e, t, n) { this.inc = 0; this.oSplashScreenImgData = e; this.canvasWidth = t; this.canvasHeight = n; this.posY = this.canvasHeight; TweenLite.to(this, .7, { posY: 0, ease: "Power2.easeOut" }) } e.prototype.render = function(e, t) { e.drawImage(this.oSplashScreenImgData.img, 0, this.posY) }; return e }(); e.Splash = t })(Elements || (Elements = {})); var Elements; (function(e) { var t = function() { function e(e, t, n, r) { this.frameNum = 0; this.x = 0; this.y = 0; this.playerHandTotal1 = 0; this.playerHandTotal2 = 0; this.compHandTotal = 0; this.letterSpace = 17; this.handSide = "right"; this.oPanelsImgData = e; this.oNumbersImgData = t; this.canvasWidth = n; this.canvasHeight = r } e.prototype.setUp = function(e, t) { if (typeof t === "undefined") { t = null } this.type = e; switch (this.type) { case "betting": this.aPanels = new Array({ id: 0, posX: this.canvasWidth / 2 - this.oPanelsImgData.oData.spriteWidth / 2, posY: -160 }, { id: 7, posX: this.canvasWidth, posY: 385 }); this.renderFunc = this.renderInGame; TweenLite.to(this.aPanels[0], .5, { posY: -20 }); break; case "firstDeal": this.hideDealBut(); this.renderFunc = this.renderInGame; TweenLite.to(this.aPanels[0], .5, { posY: -160, onComplete: this.hideDealTweenComplete, onCompleteParams: [this] }); if (t.dealType != "blackjack") { this.insuranceIsOn = t.insuranceIsOn } if (this.insuranceIsOn) { this.aPanels.push({ id: 8, posX: -380, posY: 200 }); TweenLite.to(this.aPanels[this.aPanels.length - 1], .5, { posX: -225, delay: 1 }) } this.aPanels.push({ id: 4, posX: this.canvasWidth, posY: 420 }); this.playerValuePanel1 = this.aPanels[this.aPanels.length - 1]; TweenLite.to(this.aPanels[this.aPanels.length - 1], .5, { posX: 445, delay: 1 }); this.playerHandTotal1 = t.value; if (dealType == "blackjack") { this.actionCompleteCallback = t.callback; TweenLite.to(this.aPanels[this.aPanels.length - 1], .5, { posX: 445, delay: 1, onComplete: this.blackjackDealComplete, onCompleteParams: [this] }) } else { TweenLite.to(this.aPanels[this.aPanels.length - 1], .5, { posX: 445, delay: 1 }) } break; case "newPlayerCard": if (this.handSide == "right") { this.playerHandTotal1 = t.value } else { this.playerHandTotal2 = t.value } for (var n = 0; n < this.aPanels.length; n++) { if (this.insuranceIsOn && this.aPanels[n].id == 8) { TweenLite.to(this.aPanels[n], .5, { posX: -380 }) } } break; case "newCompCard": this.compHandTotal = t.value; break; case "bust": this.aPanels.push({ id: 3, posX: this.canvasWidth / 2 - this.oPanelsImgData.oData.spriteWidth / 2, posY: -160 }); TweenLite.to(this.aPanels[this.aPanels.length - 1], 1, { posY: 213, delay: 1, ease: "Back.easeOut" }); this.aPanels.push({ id: 9, posX: this.canvasWidth, posY: 385 }); TweenLite.killTweensOf(this.aPanels[this.aPanels.length - 1]); TweenLite.to(this.aPanels[this.aPanels.length - 1], .3, { posX: 383, delay: 2.3 }); if (this.handSide == "right") { TweenLite.to(this.playerValuePanel1, .3, { posX: this.canvasWidth, delay: 2 }) } if (t.bank < 5) { this.aPanels.push({ id: 14, posX: this.canvasWidth / 2 - this.oPanelsImgData.oData.spriteWidth / 2, posY: this.canvasHeight }); TweenLite.to(this.aPanels[this.aPanels.length - 1], .3, { posY: 600, delay: 2, ease: "Back.easeOut" }) } break; case "blackjack": this.aPanels.push({ id: 1, posX: this.canvasWidth / 2 - this.oPanelsImgData.oData.spriteWidth / 2, posY: -160 }); TweenLite.to(this.aPanels[this.aPanels.length - 1], 1, { posY: 213, delay: 1, ease: "Elastic.easeOut" }); this.aPanels.push({ id: 9, posX: this.canvasWidth, posY: 385 }); TweenLite.to(this.aPanels[this.aPanels.length - 1], .3, { posX: 383, delay: 2.3 }); for (var n = 0; n < this.aPanels.length; n++) { if (this.aPanels[n].id == 4) { TweenLite.to(this.aPanels[n], .3, { posX: this.canvasWidth, delay: 2 }); break } } for (var n = 0; n < this.aPanels.length; n++) { if (this.insuranceIsOn && this.aPanels[n].id == 8) { TweenLite.to(this.aPanels[n], .5, { posX: -380 }) } } break; case "push": this.aPanels.push({ id: 6, posX: this.canvasWidth / 2 - this.oPanelsImgData.oData.spriteWidth / 2, posY: -160 }); TweenLite.to(this.aPanels[this.aPanels.length - 1], 1, { posY: 213, delay: 1, ease: "Back.easeOut" }); this.aPanels.push({ id: 9, posX: this.canvasWidth, posY: 385 }); TweenLite.to(this.aPanels[this.aPanels.length - 1], .3, { posX: 383, delay: 2.3 }); for (var n = 0; n < this.aPanels.length; n++) { if (this.aPanels[n].id == 4) { TweenLite.to(this.aPanels[n], .3, { posX: this.canvasWidth, delay: 2 }); break } } for (var n = 0; n < this.aPanels.length; n++) { if (this.insuranceIsOn && this.aPanels[n].id == 8) { TweenLite.to(this.aPanels[n], .5, { posX: -380 }) } } break; case "compPlay": this.aPanels.push({ id: 5, posX: this.canvasWidth, posY: 80 }); this.compValuePanel = this.aPanels[this.aPanels.length - 1]; TweenLite.to(this.aPanels[this.aPanels.length - 1], .5, { posX: 445, delay: 1 }); this.compHandTotal = t.value; break; case "insuranceTaken": for (var n = 0; n < this.aPanels.length; n++) { if (this.insuranceIsOn && this.aPanels[n].id == 8) { TweenLite.to(this.aPanels[n], .5, { posX: -380 }) } } break; case "insuranceLose": for (var n = 0; n < this.aPanels.length; n++) { if (this.insuranceIsOn && this.aPanels[n].id == 8) { TweenLite.to(this.aPanels[n], .5, { posX: -380 }) } } this.aPanels.push({ id: 13, posX: this.canvasWidth / 2 - this.oPanelsImgData.oData.spriteWidth / 2, posY: -160 }); TweenLite.to(this.aPanels[this.aPanels.length - 1], .5, { posY: -20 }); break; case "hidePlayOn": for (var n = 0; n < this.aPanels.length; n++) { if (this.aPanels[n].id == 13) { TweenLite.to(this.aPanels[n], .5, { posY: -160 }) } } break; case "insuranceWin": this.aPanels.push({ id: 10, posX: this.canvasWidth / 2 - this.oPanelsImgData.oData.spriteWidth / 2, posY: -160 }); TweenLite.to(this.aPanels[this.aPanels.length - 1], 1, { posY: 213, ease: "Back.easeOut" }); this.aPanels.push({ id: 9, posX: this.canvasWidth, posY: 385 }); TweenLite.to(this.aPanels[this.aPanels.length - 1], .3, { posX: 383, delay: 1.3 }); for (var n = 0; n < this.aPanels.length; n++) { if (this.aPanels[n].id == 4) { TweenLite.to(this.aPanels[n], .3, { posX: this.canvasWidth, delay: 1 }); break } } break; case "playerWin": this.aPanels.push({ id: 12, posX: this.canvasWidth / 2 - this.oPanelsImgData.oData.spriteWidth / 2, posY: -160 }); TweenLite.to(this.aPanels[this.aPanels.length - 1], 1, { posY: 213, ease: "Back.easeOut" }); this.aPanels.push({ id: 9, posX: this.canvasWidth, posY: 385 }); TweenLite.to(this.aPanels[this.aPanels.length - 1], .3, { posX: 383, delay: 1.3 }); for (var n = 0; n < this.aPanels.length; n++) { if (this.aPanels[n].id == 4) { TweenLite.to(this.aPanels[n], .3, { posX: this.canvasWidth, delay: 1 }); break } } break; case "compWin": this.aPanels.push({ id: 11, posX: this.canvasWidth / 2 - this.oPanelsImgData.oData.spriteWidth / 2, posY: -160 }); TweenLite.to(this.aPanels[this.aPanels.length - 1], 1, { posY: 213, ease: "Back.easeOut" }); this.aPanels.push({ id: 9, posX: this.canvasWidth, posY: 385 }); TweenLite.to(this.aPanels[this.aPanels.length - 1], .3, { posX: 383, delay: 1.3 }); for (var n = 0; n < this.aPanels.length; n++) { if (this.aPanels[n].id == 4) { TweenLite.to(this.aPanels[n], .3, { posX: this.canvasWidth, delay: 1 }); break } } if (t.bank < 5) { this.aPanels.push({ id: 14, posX: this.canvasWidth / 2 - this.oPanelsImgData.oData.spriteWidth / 2, posY: this.canvasHeight }); TweenLite.to(this.aPanels[this.aPanels.length - 1], .3, { posY: 600, delay: 2, ease: "Back.easeOut" }) } break; case "compBust": this.aPanels.push({ id: 2, posX: this.canvasWidth / 2 - this.oPanelsImgData.oData.spriteWidth / 2, posY: -160 }); TweenLite.to(this.aPanels[this.aPanels.length - 1], 1, { posY: 213, ease: "Back.easeOut" }); this.aPanels.push({ id: 9, posX: this.canvasWidth, posY: 385 }); TweenLite.to(this.aPanels[this.aPanels.length - 1], .3, { posX: 383, delay: 1.3 }); for (var n = 0; n < this.aPanels.length; n++) { if (this.aPanels[n].id == 4) { TweenLite.to(this.aPanels[n], .3, { posX: this.canvasWidth, delay: 1 }); break } } break; case "split": this.playerHandTotal1 = t.playerHandTotal2; this.playerHandTotal2 = t.playerHandTotal1; for (var n = 0; n < this.aPanels.length; n++) { if (this.insuranceIsOn && this.aPanels[n].id == 8) { TweenLite.to(this.aPanels[n], .5, { posX: -380 }) } } TweenLite.to(this.playerValuePanel1, .3, { posX: this.canvasWidth }); this.aPanels.push({ id: 4, posX: -379, posY: 420 }); this.playerValuePanel2 = this.aPanels[this.aPanels.length - 1]; TweenLite.to(this.playerValuePanel2, .3, { posX: -291 }); this.handSide = "left"; break; case "switchHands": this.handSide = "right"; this.actionCompleteCallback = t.callback; TweenLite.to(this.playerValuePanel1, .3, { posX: 445, delay: .5, onComplete: this.panelSwitchRight, onCompleteParams: [this] }); if (t.event == "bust") { TweenLite.to(this.playerValuePanel2, .3, { posX: -379, delay: .5 }) } break } }; e.prototype.panelSwitchRight = function(e) { e.actionCompleteCallback() }; e.prototype.blackjackDealComplete = function(e) { e.actionCompleteCallback() }; e.prototype.hideDealTweenComplete = function(e) { for (var t = 0; t < e.aPanels.length; t++) { if (e.aPanels[t].id == 0 || e.aPanels[t].id == 7) { e.aPanels.splice(t, 1); t -= 1 } } }; e.prototype.showDealBut = function() { TweenLite.killTweensOf(this.aPanels[1]); TweenLite.to(this.aPanels[1], .5, { posX: 383 }) }; e.prototype.hideDealBut = function() { TweenLite.killTweensOf(this.aPanels[1]); TweenLite.to(this.aPanels[1], .5, { posX: this.canvasWidth }) }; e.prototype.render = function(e) { this.renderFunc(e) }; e.prototype.renderInGame = function(e) { for (var t = 0; t < this.aPanels.length; t++) { var n = this.aPanels[t].id * this.oPanelsImgData.oData.spriteWidth % this.oPanelsImgData.img.width; var r = Math.floor(this.aPanels[t].id / (this.oPanelsImgData.img.width / this.oPanelsImgData.oData.spriteWidth)) * this.oPanelsImgData.oData.spriteHeight; e.drawImage(this.oPanelsImgData.img, n, r, this.oPanelsImgData.oData.spriteWidth, this.oPanelsImgData.oData.spriteHeight, this.aPanels[t].posX, this.aPanels[t].posY, this.oPanelsImgData.oData.spriteWidth, this.oPanelsImgData.oData.spriteHeight) } if (this.playerHandTotal1 > 0) { for (var t = 0; t < this.playerHandTotal1.toString().length; t++) { var i = parseFloat(this.playerHandTotal1.toString().charAt(t)); var n = i * this.oNumbersImgData.oData.spriteWidth % this.oNumbersImgData.img.width; var r = Math.floor(i / (this.oNumbersImgData.img.width / this.oNumbersImgData.oData.spriteWidth)) * this.oNumbersImgData.oData.spriteHeight; var s; s = t * this.letterSpace + 50 - this.letterSpace * this.playerHandTotal1.toString().length / 2; e.drawImage(this.oNumbersImgData.img, n, r, this.oNumbersImgData.oData.spriteWidth, this.oNumbersImgData.oData.spriteHeight, this.playerValuePanel1.posX + s, this.playerValuePanel1.posY + 60, this.oNumbersImgData.oData.spriteWidth, this.oNumbersImgData.oData.spriteHeight) } } if (this.playerHandTotal2 > 0) { for (var t = 0; t < this.playerHandTotal2.toString().length; t++) { var i = parseFloat(this.playerHandTotal2.toString().charAt(t)); var n = i * this.oNumbersImgData.oData.spriteWidth % this.oNumbersImgData.img.width; var r = Math.floor(i / (this.oNumbersImgData.img.width / this.oNumbersImgData.oData.spriteWidth)) * this.oNumbersImgData.oData.spriteHeight; var s; s = t * this.letterSpace + 329 - this.letterSpace * this.playerHandTotal2.toString().length / 2; e.drawImage(this.oNumbersImgData.img, n, r, this.oNumbersImgData.oData.spriteWidth, this.oNumbersImgData.oData.spriteHeight, this.playerValuePanel2.posX + s, this.playerValuePanel2.posY + 60, this.oNumbersImgData.oData.spriteWidth, this.oNumbersImgData.oData.spriteHeight) } } if (this.compHandTotal > 0) { for (var t = 0; t < this.compHandTotal.toString().length; t++) { var i = parseFloat(this.compHandTotal.toString().charAt(t)); var n = i * this.oNumbersImgData.oData.spriteWidth % this.oNumbersImgData.img.width; var r = Math.floor(i / (this.oNumbersImgData.img.width / this.oNumbersImgData.oData.spriteWidth)) * this.oNumbersImgData.oData.spriteHeight; e.drawImage(this.oNumbersImgData.img, n, r, this.oNumbersImgData.oData.spriteWidth, this.oNumbersImgData.oData.spriteHeight, this.compValuePanel.posX + t * this.letterSpace + 50 - this.letterSpace * this.compHandTotal.toString().length / 2, this.compValuePanel.posY + 60, this.oNumbersImgData.oData.spriteWidth, this.oNumbersImgData.oData.spriteHeight) } } }; return e }(); e.Panel = t })(Elements || (Elements = {})); var Elements; (function(e) { var t = function() { function e(e, t, n) { this.bet = 0; this.bank = 0; this.letterSpace = 17; this.oNumbersImgData = e; this.canvasWidth = t; this.canvasHeight = n } e.prototype.setAmounts = function(e, t) { this.bet = e; this.bank = t; // updateShareScore(t); // Play68.setRankingScoreDesc(t); }; e.prototype.render = function(e) { for (var t = 0; t < this.bet.toString().length; t++) { var n = parseFloat(this.bet.toString().charAt(t)); var r = n * this.oNumbersImgData.oData.spriteWidth % this.oNumbersImgData.img.width; var i = Math.floor(n / (this.oNumbersImgData.img.width / this.oNumbersImgData.oData.spriteWidth)) * this.oNumbersImgData.oData.spriteHeight; e.drawImage(this.oNumbersImgData.img, r, i, this.oNumbersImgData.oData.spriteWidth, this.oNumbersImgData.oData.spriteHeight, 75 + t * this.letterSpace, 580, this.oNumbersImgData.oData.spriteWidth, this.oNumbersImgData.oData.spriteHeight) } for (var t = 0; t < this.bank.toString().length; t++) { var n = parseFloat(this.bank.toString().charAt(t)); var r = n * this.oNumbersImgData.oData.spriteWidth % this.oNumbersImgData.img.width; var i = Math.floor(n / (this.oNumbersImgData.img.width / this.oNumbersImgData.oData.spriteWidth)) * this.oNumbersImgData.oData.spriteHeight; e.drawImage(this.oNumbersImgData.img, r, i, this.oNumbersImgData.oData.spriteWidth, this.oNumbersImgData.oData.spriteHeight, 232 + t * this.letterSpace, 761, this.oNumbersImgData.oData.spriteWidth, this.oNumbersImgData.oData.spriteHeight) } }; return e }(); e.Numbers = t })(Elements || (Elements = {})); var Elements; (function(e) { var t = function() { function e(e, t, n, r, i) { this.bet = 0; this.bank = 0; this.oChipImgData = e; this.chipLevel = t; this.aChipAmounts = n; this.canvasWidth = r; this.canvasHeight = i; this.aChipStacks = new Array({ targX: 3, targY: 630, x: 200, y: 800 }, { targX: 133, targY: 630, x: 200, y: 800 }, { targX: 266, targY: 630, x: 200, y: 800 }, { targX: 399, targY: 630, x: 200, y: 800 }) } e.prototype.setAmounts = function(e, t) { this.bet = e; this.bank = t }; e.prototype.updateChipStacks = function() { if (this.bank < this.aChipAmounts[0 + this.chipLevel]) { this.aChipStacks[0].y = 800; this.aChipStacks[1].y = 800; this.aChipStacks[2].y = 800; this.aChipStacks[3].y = 800 } else { this.aChipStacks[0].y = this.aChipStacks[0].targY; if (this.bank < this.aChipAmounts[1 + this.chipLevel]) { this.aChipStacks[1].y = 800; this.aChipStacks[2].y = 800; this.aChipStacks[3].y = 800 } else { this.aChipStacks[1].y = this.aChipStacks[1].targY; if (this.bank < this.aChipAmounts[2 + this.chipLevel]) { this.aChipStacks[2].y = 800; this.aChipStacks[3].y = 800 } else { this.aChipStacks[2].y = this.aChipStacks[2].targY; if (this.bank < this.aChipAmounts[3 + this.chipLevel]) { this.aChipStacks[3].y = 800 } else { this.aChipStacks[3].y = this.aChipStacks[3].targY } } } } }; e.prototype.setUp = function(e) { switch (e) { case "betting": this.aBetChips = new Array; this.renderFunc = this.renderStart; var t; if (this.bank >= this.aChipAmounts[3 + this.chipLevel]) { t = 4 } else if (this.bank >= this.aChipAmounts[2 + this.chipLevel]) { t = 3 } else if (this.bank >= this.aChipAmounts[1 + this.chipLevel]) { t = 2 } else if (this.bank >= this.aChipAmounts[0 + this.chipLevel]) { t = 1 } for (var n = 0; n < t; n++) { TweenLite.to(this.aChipStacks[n], .5, { y: this.aChipStacks[n].targY, x: this.aChipStacks[n].targX, ease: "Back.easeOut", delay: n * .1 }) } break; case "firstDeal": this.renderFunc = this.renderSmall; this.aSmallBetChips = new Array; for (var n = 0; n < Math.min(this.aBetChips.length, 5); n++) { var r = { id: this.aBetChips[this.aBetChips.length - n - 1], posX: 170 + n * n * 3 + 1 * n, posY: 400, scale: 1 }; this.aSmallBetChips.push(r); TweenLite.killTweensOf(this); TweenLite.to(this.aSmallBetChips[n], .3, { scale: .5, posX: Math.random() * 90 + 190, posY: Math.random() * 10 + 550, delay: n * .1 }) } for (var n = 0; n < this.aChipStacks.length; n++) { TweenLite.to(this.aChipStacks[n], .3, { y: 800, x: 200, delay: n * .1 }) } break; case "double": this.renderFunc = this.renderDouble; this.aDoubleBetChips = new Array; for (var n = 0; n < this.aSmallBetChips.length; n++) { var r = { id: this.aSmallBetChips[n].id, posX: 200, posY: 800, scale: 1 }; this.aDoubleBetChips.push(r); TweenLite.to(this.aDoubleBetChips[n], .5, { posX: Math.random() * 90 + 190, posY: Math.random() * 10 + 550, ease: "Back.easeOut", delay: .3 + n * .1 }) } break } }; e.prototype.addChip = function(e, t, n) { this.setAmounts(t, n); this.updateChipStacks(); this.curChipX = this.aChipStacks[e].targX; this.curChipY = this.aChipStacks[e].targY; this.curChipId = e; var r = Math.min(this.aBetChips.length, 4); TweenLite.killTweensOf(this); TweenLite.to(this, .3, { curChipX: 170 + r * r * 3 + 1 * r, curChipY: 400, ease: "Back.easeOut", onComplete: this.betTweenComplete, onCompleteParams: [this] }); this.aBetChips.push(e); this.renderFunc = this.renderAdding }; e.prototype.betTweenComplete = function(e) { e.renderFunc = e.renderWaiting }; e.prototype.removeChip = function(e, t) { this.setAmounts(e, t); this.updateChipStacks(); var n = Math.min(this.aBetChips.length, 4); this.curChipX = 170 + n * n * 3 + 1 * n; this.curChipY = 400; this.curChipId = this.aBetChips[this.aBetChips.length - 1]; this.aBetChips.pop(); TweenLite.killTweensOf(this); TweenLite.to(this, .3, { curChipX: this.aChipStacks[this.curChipId].targX, curChipY: this.aChipStacks[this.curChipId].targY, ease: "Back.easeIn", onComplete: this.betTweenComplete, onCompleteParams: [this] }); this.renderFunc = this.renderRemoving }; e.prototype.render = function(e) { this.renderFunc(e) }; e.prototype.renderStart = function(e) { for (var t = 0; t < this.aChipStacks.length; t++) { var n = (t + this.chipLevel) * this.oChipImgData.oData.spriteWidth % this.oChipImgData.img.width; var r = Math.floor((t + this.chipLevel) / (this.oChipImgData.img.width / this.oChipImgData.oData.spriteWidth)) * this.oChipImgData.oData.spriteHeight; e.drawImage(this.oChipImgData.img, n, r, this.oChipImgData.oData.spriteWidth, this.oChipImgData.oData.spriteHeight, this.aChipStacks[t].x, this.aChipStacks[t].y, this.oChipImgData.oData.spriteWidth, this.oChipImgData.oData.spriteHeight) } }; e.prototype.renderAdding = function(e) { for (var t = 0; t < this.aChipStacks.length; t++) { var n = (t + this.chipLevel) * this.oChipImgData.oData.spriteWidth % this.oChipImgData.img.width; var r = Math.floor((t + this.chipLevel) / (this.oChipImgData.img.width / this.oChipImgData.oData.spriteWidth)) * this.oChipImgData.oData.spriteHeight; e.drawImage(this.oChipImgData.img, n, r, this.oChipImgData.oData.spriteWidth, this.oChipImgData.oData.spriteHeight, this.aChipStacks[t].x, this.aChipStacks[t].y, this.oChipImgData.oData.spriteWidth, this.oChipImgData.oData.spriteHeight) } for (var t = 0; t < Math.min(this.aBetChips.length - 1, 4); t++) { var i = this.aBetChips[this.aBetChips.length - 1 - Math.min(this.aBetChips.length - 1, 4) + t] + this.chipLevel; var n = i * this.oChipImgData.oData.spriteWidth % this.oChipImgData.img.width; var r = Math.floor(i / (this.oChipImgData.img.width / this.oChipImgData.oData.spriteWidth)) * this.oChipImgData.oData.spriteHeight; e.drawImage(this.oChipImgData.img, n, r, this.oChipImgData.oData.spriteWidth, this.oChipImgData.oData.spriteHeight, 170 + t * t * 3 + 1 * t, 400, this.oChipImgData.oData.spriteWidth, this.oChipImgData.oData.spriteHeight) } var n = (this.curChipId + this.chipLevel) * this.oChipImgData.oData.spriteWidth % this.oChipImgData.img.width; var r = Math.floor((this.curChipId + this.chipLevel) / (this.oChipImgData.img.width / this.oChipImgData.oData.spriteWidth)) * this.oChipImgData.oData.spriteHeight; e.drawImage(this.oChipImgData.img, n, r, this.oChipImgData.oData.spriteWidth, this.oChipImgData.oData.spriteHeight, this.curChipX, this.curChipY, this.oChipImgData.oData.spriteWidth, this.oChipImgData.oData.spriteHeight) }; e.prototype.renderRemoving = function(e) { for (var t = 0; t < this.aChipStacks.length; t++) { var n = (t + this.chipLevel) * this.oChipImgData.oData.spriteWidth % this.oChipImgData.img.width; var r = Math.floor((t + this.chipLevel) / (this.oChipImgData.img.width / this.oChipImgData.oData.spriteWidth)) * this.oChipImgData.oData.spriteHeight; e.drawImage(this.oChipImgData.img, n, r, this.oChipImgData.oData.spriteWidth, this.oChipImgData.oData.spriteHeight, this.aChipStacks[t].x, this.aChipStacks[t].y, this.oChipImgData.oData.spriteWidth, this.oChipImgData.oData.spriteHeight) } for (var t = 0; t < Math.min(this.aBetChips.length, 4); t++) { var i = this.aBetChips[this.aBetChips.length - Math.min(this.aBetChips.length, 4) + t] + this.chipLevel; var n = i * this.oChipImgData.oData.spriteWidth % this.oChipImgData.img.width; var r = Math.floor(i / (this.oChipImgData.img.width / this.oChipImgData.oData.spriteWidth)) * this.oChipImgData.oData.spriteHeight; e.drawImage(this.oChipImgData.img, n, r, this.oChipImgData.oData.spriteWidth, this.oChipImgData.oData.spriteHeight, 170 + t * t * 3 + 1 * t, 400, this.oChipImgData.oData.spriteWidth, this.oChipImgData.oData.spriteHeight) } var n = (this.curChipId + this.chipLevel) * this.oChipImgData.oData.spriteWidth % this.oChipImgData.img.width; var r = Math.floor((this.curChipId + this.chipLevel) / (this.oChipImgData.img.width / this.oChipImgData.oData.spriteWidth)) * this.oChipImgData.oData.spriteHeight; e.drawImage(this.oChipImgData.img, n, r, this.oChipImgData.oData.spriteWidth, this.oChipImgData.oData.spriteHeight, this.curChipX, this.curChipY, this.oChipImgData.oData.spriteWidth, this.oChipImgData.oData.spriteHeight) }; e.prototype.renderWaiting = function(e) { for (var t = 0; t < this.aChipStacks.length; t++) { var n = (t + this.chipLevel) * this.oChipImgData.oData.spriteWidth % this.oChipImgData.img.width; var r = Math.floor((t + this.chipLevel) / (this.oChipImgData.img.width / this.oChipImgData.oData.spriteWidth)) * this.oChipImgData.oData.spriteHeight; e.drawImage(this.oChipImgData.img, n, r, this.oChipImgData.oData.spriteWidth, this.oChipImgData.oData.spriteHeight, this.aChipStacks[t].x, this.aChipStacks[t].y, this.oChipImgData.oData.spriteWidth, this.oChipImgData.oData.spriteHeight) } for (var t = 0; t < Math.min(this.aBetChips.length, 5); t++) { var i = this.aBetChips[this.aBetChips.length - Math.min(this.aBetChips.length, 5) + t] + this.chipLevel; var n = i * this.oChipImgData.oData.spriteWidth % this.oChipImgData.img.width; var r = Math.floor(i / (this.oChipImgData.img.width / this.oChipImgData.oData.spriteWidth)) * this.oChipImgData.oData.spriteHeight; e.drawImage(this.oChipImgData.img, n, r, this.oChipImgData.oData.spriteWidth, this.oChipImgData.oData.spriteHeight, 170 + t * t * 3 + 1 * t, 400, this.oChipImgData.oData.spriteWidth, this.oChipImgData.oData.spriteHeight) } }; e.prototype.renderSmall = function(e) { for (var t = 0; t < this.aChipStacks.length; t++) { var n = (t + this.chipLevel) * this.oChipImgData.oData.spriteWidth % this.oChipImgData.img.width; var r = Math.floor((t + this.chipLevel) / (this.oChipImgData.img.width / this.oChipImgData.oData.spriteWidth)) * this.oChipImgData.oData.spriteHeight; e.drawImage(this.oChipImgData.img, n, r, this.oChipImgData.oData.spriteWidth, this.oChipImgData.oData.spriteHeight, this.aChipStacks[t].x, this.aChipStacks[t].y, this.oChipImgData.oData.spriteWidth, this.oChipImgData.oData.spriteHeight) } for (var t = 0; t < this.aSmallBetChips.length; t++) { var i = this.aSmallBetChips[t].id + this.chipLevel; var n = i * this.oChipImgData.oData.spriteWidth % this.oChipImgData.img.width; var r = Math.floor(i / (this.oChipImgData.img.width / this.oChipImgData.oData.spriteWidth)) * this.oChipImgData.oData.spriteHeight; e.drawImage(this.oChipImgData.img, n, r, this.oChipImgData.oData.spriteWidth, this.oChipImgData.oData.spriteHeight, this.aSmallBetChips[t].posX, this.aSmallBetChips[t].posY, this.oChipImgData.oData.spriteWidth * this.aSmallBetChips[t].scale, this.oChipImgData.oData.spriteHeight * this.aSmallBetChips[t].scale) } }; e.prototype.renderDouble = function(e) { for (var t = 0; t < this.aSmallBetChips.length; t++) { var n = this.aSmallBetChips[t].id + this.chipLevel; var r = n * this.oChipImgData.oData.spriteWidth % this.oChipImgData.img.width; var i = Math.floor(n / (this.oChipImgData.img.width / this.oChipImgData.oData.spriteWidth)) * this.oChipImgData.oData.spriteHeight; e.drawImage(this.oChipImgData.img, r, i, this.oChipImgData.oData.spriteWidth, this.oChipImgData.oData.spriteHeight, this.aSmallBetChips[t].posX, this.aSmallBetChips[t].posY, this.oChipImgData.oData.spriteWidth * this.aSmallBetChips[t].scale, this.oChipImgData.oData.spriteHeight * this.aSmallBetChips[t].scale) } for (var t = 0; t < this.aDoubleBetChips.length; t++) { var n = this.aDoubleBetChips[t].id + this.chipLevel; var r = n * this.oChipImgData.oData.spriteWidth % this.oChipImgData.img.width; var i = Math.floor(n / (this.oChipImgData.img.width / this.oChipImgData.oData.spriteWidth)) * this.oChipImgData.oData.spriteHeight; e.drawImage(this.oChipImgData.img, r, i, this.oChipImgData.oData.spriteWidth, this.oChipImgData.oData.spriteHeight, this.aDoubleBetChips[t].posX, this.aDoubleBetChips[t].posY, this.oChipImgData.oData.spriteWidth * this.aSmallBetChips[t].scale, this.oChipImgData.oData.spriteHeight * this.aSmallBetChips[t].scale) } }; return e }(); e.Chips = t })(Elements || (Elements = {})); var Elements; (function(e) { var t = function() { function e(e, t, n) { this.centreId = 0; this.oCardsImgData = e; this.canvasWidth = t; this.canvasHeight = n } e.prototype.setUp = function(e, t) { if (typeof t === "undefined") { t = null } switch (e) { case "firstDeal": this.aPlayerCards1 = new Array; this.aPlayerCards2 = new Array; this.aCurPlayerCards = this.aPlayerCards1; this.aCompCards = new Array; this.aCurPlayerCards.push({ id: t.aPlayerDealtCards[0].id, posX: 200, posY: -200, rotation: 0 }); this.aCurPlayerCards.push({ id: t.aPlayerDealtCards[1].id, posX: 200, posY: -200, rotation: 0 }); this.aCompCards.push({ id: t.aCompDealtCards[0].id, posX: 200, posY: -200, rotation: 0, scaleX: 1 }); this.aCompCards.push({ id: 52, posX: 200, posY: -200, rotation: 0, scaleX: 1 }); for (var n = 0; n < this.aCurPlayerCards.length; n++) { var r = this.getCentreX(n, this.aCurPlayerCards.length, this.centreId); TweenLite.to(this.aCurPlayerCards[n], 1, { rotation: this.getRotation(r), posX: this.getCentreX(n, this.aCurPlayerCards.length, this.centreId), posY: 460, delay: n * .1 }); var r = this.getCentreX(n, this.aCompCards.length, this.centreId); TweenLite.to(this.aCompCards[n], 1, { rotation: this.getRotation(r), posX: this.getCentreX(n, this.aCompCards.length, this.centreId), posY: 130, delay: n * .1 + .2 }) } break; case "newPlayerCard": this.aCurPlayerCards.push({ id: t.newCard.id, posX: 200, posY: -200, rotation: 0 }); for (var n = 0; n < this.aCurPlayerCards.length; n++) { var r = this.getCentreX(n, this.aCurPlayerCards.length, this.centreId); if (t.callback && n == this.aCurPlayerCards.length - 1) { this.actionCompleteCallback = t.callback; TweenLite.to(this.aCurPlayerCards[n], 1, { rotation: this.getRotation(r), posX: r, posY: 460, onComplete: this.handComplete, onCompleteParams: [this] }); break } TweenLite.to(this.aCurPlayerCards[n], 1, { rotation: this.getRotation(r), posX: r, posY: 460 }) } break; case "newCompCard": this.centreId = 0; this.aCompCards.push({ id: t.oNewCard.id, posX: 200, posY: -200, rotation: 0, scaleX: 1 }); for (var n = 0; n < this.aCompCards.length; n++) { var r = this.getCentreX(n, this.aCompCards.length, this.centreId); if (t.callback && n == this.aCompCards.length - 1) { this.actionCompleteCallback = t.callback; TweenLite.to(this.aCompCards[n], 1, { rotation: this.getRotation(r), posX: r, posY: 130, onComplete: this.handComplete, onCompleteParams: [this] }); break } TweenLite.to(this.aCompCards[n], 1, { rotation: this.getRotation(r), posX: r, posY: 130 }) } break; case "compPlay": this.centreId = 0; TweenLite.to(this.aCompCards[1], .5, { scaleX: 0, ease: "Power1.easeIn" }); this.aCompCards.push({ id: t.oHoleCard.id, posX: this.aCompCards[1].posX, posY: this.aCompCards[1].posY, rotation: this.aCompCards[1].rotation, scaleX: 0 }); TweenLite.to(this.aCompCards[2], .5, { scaleX: 1, delay: .5, onComplete: this.holeCardRevealComplete, onCompleteParams: [this] }); this.actionCompleteCallback = t.callback; break; case "compShow": this.centreId = 0; TweenLite.to(this.aCompCards[1], .5, { scaleX: 0, ease: "Power1.easeIn" }); this.aCompCards.push({ id: t.oHoleCard.id, posX: this.aCompCards[1].posX, posY: this.aCompCards[1].posY, rotation: this.aCompCards[1].rotation, scaleX: 0 }); TweenLite.to(this.aCompCards[2], .5, { scaleX: 1, delay: .5 }); break; case "compInsuranceShow": this.centreId = 0; TweenLite.to(this.aCompCards[1], .5, { scaleX: 0, ease: "Power1.easeIn" }); this.aCompCards.push({ id: t.oHoleCard.id, posX: this.aCompCards[1].posX, posY: this.aCompCards[1].posY, rotation: this.aCompCards[1].rotation, scaleX: 0 }); TweenLite.to(this.aCompCards[2], .5, { scaleX: 1, delay: .5, onComplete: this.holeCardRevealComplete, onCompleteParams: [this] }); this.actionCompleteCallback = t.callback; break; case "split": this.aPlayerCards2 = new Array(this.aPlayerCards1.pop()); this.centreId = 1; var r = this.getCentreX(0, this.aCurPlayerCards.length, 1); TweenLite.to(this.aCurPlayerCards[0], .5, { rotation: this.getRotation(r), posX: r }); var r = this.getCentreX(0, this.aPlayerCards2.length, 2); TweenLite.to(this.aPlayerCards2[0], .5, { rotation: this.getRotation(r), posX: r }); break; case "switchHands": this.centreId = 2; this.aCurPlayerCards = this.aPlayerCards2; break } }; e.prototype.handComplete = function(e) { e.actionCompleteCallback() }; e.prototype.holeCardRevealComplete = function(e) { for (var t = 0; t < e.aCompCards.length; t++) { if (e.aCompCards[t].id == 52) { e.aCompCards.splice(t, 1) } } e.actionCompleteCallback() }; e.prototype.getCentreX = function(e, t, n) { if (typeof n === "undefined") { n = 0 } var r = this.canvasWidth / 2; var i = 50; if (n == 1) { r = this.canvasWidth / 4; i = 25 } else if (n == 2) { r = this.canvasWidth / 4 * 3; i = 25 } return r + e * i - (t - 1) * i / 2 }; e.prototype.getRotation = function(e) { return Math.PI / 8 / this.canvasWidth * e - Math.PI / 16 }; e.prototype.render = function(e) { for (var t = 0; t < this.aCompCards.length; t++) { e.save(); e.translate(this.aCompCards[t].posX, this.aCompCards[t].posY); e.rotate(this.aCompCards[t].rotation); var n = this.aCompCards[t].id; var r = n * this.oCardsImgData.oData.spriteWidth % this.oCardsImgData.img.width; var i = Math.floor(n / (this.oCardsImgData.img.width / this.oCardsImgData.oData.spriteWidth)) * this.oCardsImgData.oData.spriteHeight; e.drawImage(this.oCardsImgData.img, r, i, this.oCardsImgData.oData.spriteWidth, this.oCardsImgData.oData.spriteHeight, -this.oCardsImgData.oData.spriteWidth / 2 + (1 - this.aCompCards[t].scaleX) * (this.oCardsImgData.oData.spriteWidth / 2), -this.oCardsImgData.oData.spriteHeight / 2, this.oCardsImgData.oData.spriteWidth * this.aCompCards[t].scaleX, this.oCardsImgData.oData.spriteHeight); e.restore() } for (var t = 0; t < this.aPlayerCards1.length; t++) { e.save(); ctx.translate(this.aPlayerCards1[t].posX, this.aPlayerCards1[t].posY); ctx.rotate(this.aPlayerCards1[t].rotation); var n = this.aPlayerCards1[t].id; var r = n * this.oCardsImgData.oData.spriteWidth % this.oCardsImgData.img.width; var i = Math.floor(n / (this.oCardsImgData.img.width / this.oCardsImgData.oData.spriteWidth)) * this.oCardsImgData.oData.spriteHeight; e.drawImage(this.oCardsImgData.img, r, i, this.oCardsImgData.oData.spriteWidth, this.oCardsImgData.oData.spriteHeight, -this.oCardsImgData.oData.spriteWidth / 2, -this.oCardsImgData.oData.spriteHeight / 2, this.oCardsImgData.oData.spriteWidth, this.oCardsImgData.oData.spriteHeight); e.restore() } for (var t = 0; t < this.aPlayerCards2.length; t++) { e.save(); ctx.translate(this.aPlayerCards2[t].posX, this.aPlayerCards2[t].posY); ctx.rotate(this.aPlayerCards2[t].rotation); var n = this.aPlayerCards2[t].id; var r = n * this.oCardsImgData.oData.spriteWidth % this.oCardsImgData.img.width; var i = Math.floor(n / (this.oCardsImgData.img.width / this.oCardsImgData.oData.spriteWidth)) * this.oCardsImgData.oData.spriteHeight; e.drawImage(this.oCardsImgData.img, r, i, this.oCardsImgData.oData.spriteWidth, this.oCardsImgData.oData.spriteHeight, -this.oCardsImgData.oData.spriteWidth / 2, -this.oCardsImgData.oData.spriteHeight / 2, this.oCardsImgData.oData.spriteWidth, this.oCardsImgData.oData.spriteHeight); e.restore() } }; return e }(); e.Cards = t })(Elements || (Elements = {})); var Elements; (function(e) { var t = function() { function e(e, t, n) { this.canHit = false; this.oButtonsImgData = e; this.canvasWidth = t; this.canvasHeight = n; this.aButs = new Array({ targX: 3, targY: 630, x: 200, y: 800, isOn: true }, { targX: 133, targY: 630, x: 200, y: 800, isOn: true }, { targX: 266, targY: 630, x: 200, y: 800, isOn: true }, { targX: 399, targY: 630, x: 200, y: 800, isOn: true }) } e.prototype.setUp = function(e, t) { if (typeof t === "undefined") { t = null } switch (e) { case "firstDeal": if (t.dealType == "blackjack") { return } if (t.dealType == "normal") { this.aButs[0].isOn = false } if (!t.doubleIsOn) { this.aButs[1].isOn = false } for (var n = 0; n < this.aButs.length; n++) { if (this.aButs[n].isOn) { TweenLite.to(this.aButs[n], .5, { y: this.aButs[n].targY, x: this.aButs[n].targX, ease: "Back.easeOut", delay: 1 + n * .1, onComplete: this.allowButs, onCompleteParams: [this] }) } } break; case "double": case "stand": for (var n = 0; n < this.aButs.length; n++) { if (this.aButs[n].isOn) { TweenLite.to(this.aButs[n], .3, { y: 800, x: 200, delay: n * .1 }) } } break; case "split": case "hit": for (var n = 0; n < 2; n++) { if (this.aButs[n].isOn) { TweenLite.to(this.aButs[n], .3, { y: 800, x: 200, delay: n * .1 }) } } break; case "bust": case "insuranceWin": for (var n = 0; n < this.aButs.length; n++) { if (this.aButs[n].isOn) { TweenLite.to(this.aButs[n], .3, { y: 800, x: 200, delay: 1 + n * .1 }) } } break } }; e.prototype.allowButs = function(e) { e.canHit = true }; e.prototype.render = function(e) { for (var t = 0; t < this.aButs.length; t++) { if (this.aButs[t].isOn) { var n = t * this.oButtonsImgData.oData.spriteWidth % this.oButtonsImgData.img.width; var r = Math.floor(t / (this.oButtonsImgData.img.width / this.oButtonsImgData.oData.spriteWidth)) * this.oButtonsImgData.oData.spriteHeight; e.drawImage(this.oButtonsImgData.img, n, r, this.oButtonsImgData.oData.spriteWidth, this.oButtonsImgData.oData.spriteHeight, this.aButs[t].x, this.aButs[t].y, this.oButtonsImgData.oData.spriteWidth, this.oButtonsImgData.oData.spriteHeight) } } }; return e }(); e.Buttons = t })(Elements || (Elements = {})); var requestAnimFrame = function() { return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(e) { window.setTimeout(e, 1e3 / 60, (new Date).getTime()) } }(); var previousTime; var canvas = document.getElementById("canvas"); var ctx = canvas.getContext("2d"); canvas.width = 533; canvas.height = 800; var canvasX; var canvasY; var canvasScaleX; var canvasScaleY; var div = document.getElementById("viewporter"); var sound; var music; var allowSound = false; var muted = false; var splash; var splashTimer = 0; var screens; var assetLib; var preAssetLib; var rotatePause = false; var manualPause = false; var isMobile = false; var gameState = "loading"; var aLangs = new Array("EN", "ES", "TR"); var curLang = ""; SG.trigger({ type: "start" }); if (SG.lang != null) curLang = (SG.lang + "").toUpperCase(); var isBugBrowser = false; var deviceAgent = navigator.userAgent.toLowerCase(); if (deviceAgent.match(/(iphone|ipod|ipad)/) || deviceAgent.match(/(android)/) || deviceAgent.match(/(iemobile)/) || deviceAgent.match(/iphone/i) || deviceAgent.match(/ipad/i) || deviceAgent.match(/ipod/i) || deviceAgent.match(/blackberry/i) || deviceAgent.match(/bada/i)) { isMobile = true; if (deviceAgent.match(/(android)/) && !/Chrome/.test(navigator.userAgent)) { isBugBrowser = true } } var userInput = new Utils.UserInput(canvas, isBugBrowser); resizeCanvas(); window.onresize = function() { setTimeout(function() { resizeCanvas() }, 1) }; window.addEventListener("load", function() { setTimeout(function() { resizeCanvas() }, 0); var e = function() { resizeCanvas() }; window.addEventListener("orientationchange", e, false); SG.setOrientationHandler(e); SG.setResizeHandler(e) }); if (typeof window.AudioContext !== "undefined" || typeof window.webkitAudioContext !== "undefined" || navigator.userAgent.indexOf("Android") == -1) {} var panel; var background; var bet = 0; var bank = 0; var numbers; var chips; var aChipAmounts = new Array(5, 10, 25, 100, 500, 1e3); var cards; var aDeck; var dealType; var buttons; var aPCards1; var aPCards2; var aCurPlayerCards; var aCompCards; var insuranceTaken = false; var splitTaken = false; var insuranceCard; var chipLevel = 0; if (aLangs.length > 1) { loadPreAssets() } else { curLang = aLangs[0]; loadAssets() }