1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719 |
- 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()
- }
|