app.min.js 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719
  1. function initSplash() {
  2. gameState = "splash";
  3. resizeCanvas();
  4. splash = new Elements.Splash(assetLib.getData("splash"), canvas.width, canvas.height);
  5. previousTime = (new Date).getTime();
  6. updateSplashScreenEvent()
  7. }
  8. function resetDeck() {
  9. aDeck = new Array;
  10. for (var e = 0; e < 52; e++) {
  11. aDeck.push({
  12. id: e,
  13. value: e % 13 + 1
  14. })
  15. }
  16. }
  17. function initStartScreen() {
  18. sdr();
  19. }
  20. function sdr() {
  21. gameState = "start";
  22. if (allowSound) {}
  23. bet = 0;
  24. bank = 1e3;
  25. userInput.addHitArea("mute", butEventHandler, null, {
  26. type: "rect",
  27. aRect: [455, 0, canvas.width, 75]
  28. }, true);
  29. userInput.addHitArea("help", butEventHandler, null, {
  30. type: "rect",
  31. aRect: [0, 0, 80, 75]
  32. }, true);
  33. userInput.addHitArea("moregames", butEventHandler, null, {
  34. type: "rect",
  35. aRect: [canvas.width / 2 - 100, 100, canvas.width / 2 + 100, 150]
  36. }, true);
  37. var e = new Array(canvas.width / 2, 600);
  38. var t = new Array(canvas.width / 2, 750);
  39. screens = new Elements.Screens({
  40. startImageData: assetLib.getData("titleScreen")
  41. }, {
  42. moregames: {
  43. imageData: assetLib.getData("sgLogo"),
  44. pos: t
  45. },
  46. play: {
  47. imageData: assetLib.getData("playBut"),
  48. pos: e
  49. }
  50. }, canvas.width, canvas.height);
  51. screens.setRenderFunc("start");
  52. userInput.addHitArea("startGame", butEventHandler, e, {
  53. type: "image",
  54. oImageData: assetLib.getData("playBut"),
  55. aCentrePos: e
  56. });
  57. userInput.addHitArea("moregames", SG.redirectToPortal, t, {
  58. type: "image",
  59. oImageData: assetLib.getData("sgLogo"),
  60. aCentrePos: t
  61. });
  62. previousTime = (new Date).getTime();
  63. updateStartScreenEvent()
  64. }
  65. function initBetting() {
  66. gameState = "betting";
  67. insuranceTaken = false;
  68. if (bank < 2e3) {
  69. chipLevel = 0
  70. } else if (bank < 1e4) {
  71. chipLevel = 1
  72. } else {
  73. chipLevel = 2
  74. }
  75. if (allowSound) {}
  76. playSound("chipIntro");
  77. userInput.addHitArea("quitGameBetting", butEventHandler, null, {
  78. type: "rect",
  79. aRect: [0, 0, 80, 75]
  80. }, true);
  81. userInput.addHitArea("addChip", butEventHandler, {
  82. id: 0
  83. }, {
  84. type: "rect",
  85. aRect: [0, 630, 133, 758]
  86. });
  87. userInput.addHitArea("addChip", butEventHandler, {
  88. id: 1
  89. }, {
  90. type: "rect",
  91. aRect: [133, 630, 266, 758]
  92. });
  93. userInput.addHitArea("addChip", butEventHandler, {
  94. id: 2
  95. }, {
  96. type: "rect",
  97. aRect: [266, 630, 399, 758]
  98. });
  99. userInput.addHitArea("addChip", butEventHandler, {
  100. id: 3
  101. }, {
  102. type: "rect",
  103. aRect: [399, 630, 533, 758]
  104. });
  105. userInput.addHitArea("removeChip", butEventHandler, null, {
  106. type: "rect",
  107. aRect: [170, 390, 360, 530]
  108. });
  109. userInput.addHitArea("deal", butEventHandler, null, {
  110. type: "rect",
  111. aRect: [390, 390, canvas.width, 530]
  112. });
  113. background = new Elements.Background(assetLib.getData("background"), canvas.width, canvas.height);
  114. numbers = new Elements.Numbers(assetLib.getData("numbers"), canvas.width, canvas.height);
  115. numbers.setAmounts(bet, bank);
  116. panel = new Elements.Panel(assetLib.getData("panels"), assetLib.getData("numbers"), canvas.width, canvas.height);
  117. panel.setUp("betting");
  118. chips = new Elements.Chips(assetLib.getData("chips"), chipLevel, aChipAmounts, canvas.width, canvas.height);
  119. chips.setAmounts(bet, bank);
  120. chips.setUp("betting");
  121. previousTime = (new Date).getTime();
  122. updateBettingEvent()
  123. }
  124. function initHelp() {
  125. gameState = "help";
  126. userInput.addHitArea("quitHelp", butEventHandler, null, {
  127. type: "rect",
  128. aRect: [0, 0, 80, 75]
  129. }, true);
  130. ctx.drawImage(assetLib.getData("helpScreen").img, 0, 0)
  131. }
  132. function initDeal() {
  133. gameState = "dealing";
  134. resetDeck();
  135. playSound("cardHard");
  136. userInput.addHitArea("quitGameDealing", butEventHandler, null, {
  137. type: "rect",
  138. aRect: [0, 0, 80, 75]
  139. }, true);
  140. userInput.addHitArea("hit", butEventHandler, null, {
  141. type: "rect",
  142. aRect: [266, 630, 399, 758]
  143. });
  144. userInput.addHitArea("stand", butEventHandler, null, {
  145. type: "rect",
  146. aRect: [399, 630, 533, 758]
  147. });
  148. aPCards2 = new Array;
  149. aPCards1 = aCurPlayerCards = getCards(2);
  150. aCompCards = getCards(1);
  151. if (roundToTen(this.aCurPlayerCards[0].value) + roundToTen(this.aCurPlayerCards[1].value) == 11 && (this.aCurPlayerCards[0].value == 1 || this.aCurPlayerCards[1].value == 1)) {
  152. dealType = "blackjack"
  153. } else if (roundToTen(this.aCurPlayerCards[0].value) == roundToTen(this.aCurPlayerCards[1].value) && bank >= bet) {
  154. dealType = "split";
  155. userInput.addHitArea("split", butEventHandler, null, {
  156. type: "rect",
  157. aRect: [0, 630, 133, 758]
  158. })
  159. } else {
  160. dealType = "normal"
  161. }
  162. var e = false;
  163. var t = false;
  164. if (aCompCards[0].value == 1 && bank >= bet) {
  165. userInput.addHitArea("insure", butEventHandler, null, {
  166. type: "rect",
  167. aRect: [0, 200, 150, 350]
  168. });
  169. e = true
  170. }
  171. if (bank >= bet) {
  172. userInput.addHitArea("double", butEventHandler, null, {
  173. type: "rect",
  174. aRect: [133, 630, 266, 758]
  175. });
  176. t = true
  177. }
  178. panel.setUp("firstDeal", {
  179. dealType: dealType,
  180. insuranceIsOn: e,
  181. value: getBestValue(this.aCurPlayerCards),
  182. callback: initBlackjackCompare
  183. });
  184. cards = new Elements.Cards(assetLib.getData("cards"), canvas.width, canvas.height);
  185. cards.setUp("firstDeal", {
  186. aPlayerDealtCards: this.aCurPlayerCards,
  187. aCompDealtCards: this.aCompCards,
  188. dealType: dealType
  189. });
  190. chips.setUp("firstDeal");
  191. previousTime = (new Date).getTime();
  192. buttons = new Elements.Buttons(assetLib.getData("buttons"), canvas.width, canvas.height);
  193. buttons.setUp("firstDeal", {
  194. dealType: dealType,
  195. doubleIsOn: t
  196. });
  197. updateDealingEvent()
  198. }
  199. function initBlackjackCompare() {
  200. var e = getCards(1)[0];
  201. aCompCards.push(e);
  202. panel.setUp("compPlay", {
  203. value: getBestValue(aCompCards)
  204. });
  205. cards.setUp("compPlay", {
  206. oHoleCard: e,
  207. callback: checkBlackjack
  208. })
  209. }
  210. function initCompPlay() {
  211. var e;
  212. if (!insuranceTaken) {
  213. e = getCards(1)[0]
  214. } else {
  215. e = insuranceCard
  216. }
  217. aCompCards.push(e);
  218. playSound("cardSoft");
  219. panel.setUp("compPlay", {
  220. value: getBestValue(aCompCards)
  221. });
  222. cards.setUp("compPlay", {
  223. oHoleCard: e,
  224. callback: checkHands
  225. })
  226. }
  227. function dealNewCompCard() {
  228. var e = getCards(1)[0];
  229. aCompCards.push(e);
  230. playSound("cardSoft");
  231. panel.setUp("newCompCard", {
  232. value: getBestValue(aCompCards)
  233. });
  234. cards.setUp("newCompCard", {
  235. oNewCard: e,
  236. callback: checkHands
  237. })
  238. }
  239. function initCompShow() {
  240. var e = getCards(1)[0];
  241. aCompCards.push(e);
  242. playSound("cardSoft");
  243. cards.setUp("compShow", {
  244. oHoleCard: e
  245. })
  246. }
  247. function initCompInsuranceShow() {
  248. aCompCards.push(insuranceCard);
  249. playSound("cardSoft");
  250. panel.setUp("compPlay", {
  251. value: getBestValue(aCompCards)
  252. });
  253. cards.setUp("compInsuranceShow", {
  254. oHoleCard: insuranceCard,
  255. callback: checkInsuranceHand
  256. })
  257. }
  258. function checkInsuranceHand() {
  259. var e = getBestValue(aCompCards);
  260. if (e == 21) {
  261. bank += Math.round(bet * 1.5);
  262. bet = 0;
  263. // Play68.setRankingScoreDesc(bank);
  264. numbers.setAmounts(bet, bank);
  265. userInput.removeHitArea("split");
  266. userInput.removeHitArea("double");
  267. userInput.removeHitArea("hit");
  268. userInput.removeHitArea("stand");
  269. panel.setUp("insuranceWin");
  270. buttons.setUp("insuranceWin");
  271. userInput.addHitArea("replay", butEventHandler, null, {
  272. type: "rect",
  273. aRect: [390, 390, canvas.width, 530]
  274. })
  275. } else {
  276. buttons.canHit = true
  277. }
  278. }
  279. function checkHands() {
  280. var e = getBestValue(aCompCards);
  281. var t = getBestValue2(aPCards1, aPCards2);
  282. if (e > 21) {
  283. console.log("1");
  284. SG.trigger({
  285. type: "gameOver"
  286. });
  287. panel.setUp("compBust");
  288. playSound("win");
  289. bank += bet * 2;
  290. bet = 0;
  291. // Play68.setRankingScoreDesc(bank);
  292. numbers.setAmounts(bet, bank);
  293. userInput.removeHitArea("split");
  294. userInput.removeHitArea("double");
  295. userInput.removeHitArea("hit");
  296. userInput.removeHitArea("stand");
  297. userInput.addHitArea("replay", butEventHandler, null, {
  298. type: "rect",
  299. aRect: [390, 390, canvas.width, 530]
  300. })
  301. } else if (e > 16) {
  302. if (e > t) {
  303. console.log("2");
  304. SG.trigger({
  305. type: "gameOver"
  306. });
  307. panel.setUp("compWin", {
  308. bank: bank
  309. });
  310. playSound("bust");
  311. if (bank < 5) {
  312. bank = 1e3
  313. }
  314. bet = 0;
  315. // Play68.setRankingScoreDesc(bank);
  316. numbers.setAmounts(bet, bank);
  317. userInput.removeHitArea("split");
  318. userInput.removeHitArea("double");
  319. userInput.removeHitArea("hit");
  320. userInput.removeHitArea("stand");
  321. userInput.addHitArea("replay", butEventHandler, null, {
  322. type: "rect",
  323. aRect: [390, 390, canvas.width, 530]
  324. })
  325. } else if (e < t) {
  326. console.log("3");
  327. SG.trigger({
  328. type: "gameOver"
  329. });
  330. panel.setUp("playerWin");
  331. playSound("win");
  332. bank += bet * 2;
  333. bet = 0;
  334. // Play68.setRankingScoreDesc(bank);
  335. numbers.setAmounts(bet, bank);
  336. userInput.removeHitArea("split");
  337. userInput.removeHitArea("double");
  338. userInput.removeHitArea("hit");
  339. userInput.removeHitArea("stand");
  340. userInput.addHitArea("replay", butEventHandler, null, {
  341. type: "rect",
  342. aRect: [390, 390, canvas.width, 530]
  343. })
  344. } else {
  345. console.log("4");
  346. SG.trigger({
  347. type: "gameOver"
  348. });
  349. panel.setUp("push");
  350. playSound("push");
  351. bank += bet;
  352. bet = 0;
  353. // Play68.setRankingScoreDesc(bank);
  354. numbers.setAmounts(bet, bank);
  355. userInput.removeHitArea("split");
  356. userInput.removeHitArea("double");
  357. userInput.removeHitArea("hit");
  358. userInput.removeHitArea("stand");
  359. userInput.addHitArea("replay", butEventHandler, null, {
  360. type: "rect",
  361. aRect: [390, 390, canvas.width, 530]
  362. })
  363. }
  364. } else {
  365. dealNewCompCard()
  366. }
  367. }
  368. function checkBlackjack() {
  369. var e = getBestValue(aCompCards);
  370. if (e == 21) {
  371. console.log("push");
  372. panel.setUp("push");
  373. playSound("push");
  374. bank += bet;
  375. bet = 0;
  376. // Play68.setRankingScoreDesc(bank);
  377. numbers.setAmounts(bet, bank);
  378. userInput.removeHitArea("split");
  379. userInput.removeHitArea("double");
  380. userInput.removeHitArea("hit");
  381. userInput.removeHitArea("stand");
  382. userInput.addHitArea("replay", butEventHandler, null, {
  383. type: "rect",
  384. aRect: [390, 390, canvas.width, 530]
  385. })
  386. } else {
  387. panel.setUp("blackjack");
  388. playSound("blackjack");
  389. bank += bet + Math.round(bet *= 1.5);
  390. bet = 0;
  391. // Play68.setRankingScoreDesc(bank);
  392. numbers.setAmounts(bet, bank);
  393. userInput.removeHitArea("split");
  394. userInput.removeHitArea("double");
  395. userInput.removeHitArea("hit");
  396. userInput.removeHitArea("stand");
  397. userInput.addHitArea("replay", butEventHandler, null, {
  398. type: "rect",
  399. aRect: [390, 390, canvas.width, 530]
  400. })
  401. }
  402. }
  403. function roundToTen(e) {
  404. if (e > 10) {
  405. e = 10
  406. }
  407. return e
  408. }
  409. function getBestValue(e) {
  410. var t = 0;
  411. var n = 0;
  412. for (var r = 0; r < e.length; r++) {
  413. if (e[r].value == 1) {
  414. n++;
  415. t += 11
  416. } else {
  417. t += roundToTen(e[r].value)
  418. }
  419. }
  420. if (t > 21) {
  421. for (var r = 0; r < n; r++) {
  422. t -= 10;
  423. if (t <= 21) {
  424. break
  425. }
  426. }
  427. }
  428. return t
  429. }
  430. function getBestValue2(e, t) {
  431. var n = getBestValue(e);
  432. var r = getBestValue(t);
  433. if (n > 22) {
  434. return r
  435. } else if (r > 22) {
  436. return n
  437. } else {
  438. if (n > r) {
  439. return n
  440. } else {
  441. return r
  442. }
  443. }
  444. }
  445. function getCards(e) {
  446. var t = new Array;
  447. for (var n = 0; n < e; n++) {
  448. if (aDeck.length > 0) {
  449. var r = Math.floor(Math.random() * aDeck.length);
  450. t.push(aDeck[r]);
  451. aDeck.splice(r, 1)
  452. } else {
  453. break
  454. }
  455. }
  456. return t
  457. }
  458. function dealNewPlayerCard(e) {
  459. if (typeof e === "undefined") {
  460. e = false
  461. }
  462. var t = getCards(1)[0];
  463. aCurPlayerCards.push(t);
  464. panel.setUp("newPlayerCard", {
  465. value: getBestValue(aCurPlayerCards)
  466. });
  467. if (getBestValue(aCurPlayerCards) > 21) {
  468. if (!splitTaken) {
  469. if (getBestValue(aPCards1) > 21) {
  470. console.log("5");
  471. SG.trigger({
  472. type: "gameOver"
  473. });
  474. panel.setUp("bust", {
  475. bank: bank
  476. });
  477. if (bank < 5) {
  478. bank = 1e3
  479. }
  480. buttons.setUp("bust");
  481. chips.setUp("bust");
  482. playSound("bust");
  483. bet = 0;
  484. // Play68.setRankingScoreDesc(bank);
  485. numbers.setAmounts(bet, bank);
  486. userInput.removeHitArea("split");
  487. userInput.removeHitArea("double");
  488. userInput.removeHitArea("hit");
  489. userInput.removeHitArea("stand");
  490. userInput.addHitArea("replay", butEventHandler, null, {
  491. type: "rect",
  492. aRect: [390, 390, canvas.width, 530]
  493. });
  494. cards.setUp("newPlayerCard", {
  495. newCard: t,
  496. callback: initCompShow
  497. })
  498. } else {
  499. console.log("6");
  500. SG.trigger({
  501. type: "gameOver"
  502. });
  503. userInput.removeHitArea("split");
  504. userInput.removeHitArea("double");
  505. userInput.removeHitArea("hit");
  506. userInput.removeHitArea("stand");
  507. buttons.setUp("stand");
  508. panel.setUp("stand");
  509. initCompPlay()
  510. }
  511. } else {
  512. splitTaken = false;
  513. cards.setUp("newPlayerCard", {
  514. newCard: t
  515. });
  516. panel.setUp("switchHands", {
  517. callback: dealNewPlayerCard,
  518. event: "bust"
  519. });
  520. bet /= 2;
  521. // Play68.setRankingScoreDesc(bank);
  522. numbers.setAmounts(bet, bank);
  523. cards.setUp("switchHands");
  524. aCurPlayerCards = aPCards2
  525. }
  526. } else if (e) {
  527. cards.setUp("newPlayerCard", {
  528. newCard: t,
  529. callback: initCompPlay
  530. })
  531. } else {
  532. cards.setUp("newPlayerCard", {
  533. newCard: t
  534. })
  535. }
  536. }
  537. function butEventHandler(e, t) {
  538. switch (e) {
  539. case "langSelect":
  540. curLang = t.lang;
  541. ctx.clearRect(0, 0, canvas.width, canvas.height);
  542. userInput.removeHitArea("langSelect");
  543. initLoadAssets();
  544. break;
  545. case "replay":
  546. playSound("click");
  547. userInput.removeHitArea("replay");
  548. userInput.removeHitArea("quitGameDealing");
  549. bet = 0;
  550. numbers.setAmounts(bet, bank);
  551. initBetting();
  552. break;
  553. case "split":
  554. if (buttons.canHit) {
  555. playSound("click");
  556. splitTaken = true;
  557. aPCards2 = new Array;
  558. aPCards2.push(aCurPlayerCards.pop());
  559. aPCards1 = aCurPlayerCards;
  560. bank -= bet;
  561. bet *= 2;
  562. numbers.setAmounts(bet, bank);
  563. userInput.removeHitArea("split");
  564. userInput.removeHitArea("double");
  565. buttons.setUp("split");
  566. cards.setUp("split");
  567. dealNewPlayerCard();
  568. panel.setUp("split", {
  569. playerHandTotal1: getBestValue(aPCards1),
  570. playerHandTotal2: getBestValue(aPCards2)
  571. });
  572. if (insuranceTaken) {
  573. panel.setUp("hidePlayOn")
  574. }
  575. }
  576. break;
  577. case "double":
  578. if (buttons.canHit) {
  579. playSound("cardSoft");
  580. bank -= bet;
  581. bet *= 2;
  582. userInput.removeHitArea("split");
  583. userInput.removeHitArea("double");
  584. userInput.removeHitArea("hit");
  585. userInput.removeHitArea("stand");
  586. numbers.setAmounts(bet, bank);
  587. buttons.setUp("double");
  588. chips.setUp("double");
  589. dealNewPlayerCard(true);
  590. if (insuranceTaken) {
  591. panel.setUp("hidePlayOn")
  592. }
  593. }
  594. break;
  595. case "hit":
  596. if (buttons.canHit) {
  597. playSound("cardSoft");
  598. userInput.removeHitArea("split");
  599. userInput.removeHitArea("double");
  600. buttons.setUp("hit");
  601. dealNewPlayerCard();
  602. if (insuranceTaken) {
  603. panel.setUp("hidePlayOn")
  604. }
  605. }
  606. break;
  607. case "stand":
  608. if (buttons.canHit) {
  609. playSound("click");
  610. if (!splitTaken) {
  611. userInput.removeHitArea("split");
  612. userInput.removeHitArea("double");
  613. userInput.removeHitArea("hit");
  614. userInput.removeHitArea("stand");
  615. buttons.setUp("stand");
  616. panel.setUp("stand");
  617. initCompPlay()
  618. } else {
  619. splitTaken = false;
  620. panel.setUp("switchHands", {
  621. callback: dealNewPlayerCard
  622. });
  623. cards.setUp("switchHands");
  624. aCurPlayerCards = aPCards2
  625. }
  626. if (insuranceTaken) {
  627. panel.setUp("hidePlayOn")
  628. }
  629. }
  630. break;
  631. case "startGame":
  632. playSound("click");
  633. userInput.removeHitArea("startGame");
  634. userInput.removeHitArea("help");
  635. initBetting();
  636. break;
  637. case "help":
  638. playSound("click");
  639. userInput.removeHitArea("startGame");
  640. userInput.removeHitArea("help");
  641. initHelp();
  642. break;
  643. case "quitHelp":
  644. playSound("click");
  645. userInput.removeHitArea("quitHelp");
  646. initStartScreen();
  647. break;
  648. case "mute":
  649. playSound("click");
  650. toggleMute();
  651. break;
  652. case "quitGameBetting":
  653. playSound("click");
  654. userInput.removeHitArea("quitGameBetting");
  655. userInput.removeHitArea("addChip");
  656. userInput.removeHitArea("removeChip");
  657. userInput.removeHitArea("deal");
  658. initStartScreen();
  659. break;
  660. case "quitGameDealing":
  661. playSound("click");
  662. userInput.removeHitArea("quitGameDealing");
  663. userInput.removeHitArea("split");
  664. userInput.removeHitArea("double");
  665. userInput.removeHitArea("hit");
  666. userInput.removeHitArea("stand");
  667. userInput.removeHitArea("insure");
  668. userInput.removeHitArea("replay");
  669. initStartScreen();
  670. break;
  671. case "addChip":
  672. if (aChipAmounts[t.id] <= bank) {
  673. playSound("chip");
  674. panel.showDealBut();
  675. bet += aChipAmounts[t.id + chipLevel];
  676. bank -= aChipAmounts[t.id + chipLevel];
  677. numbers.setAmounts(bet, bank);
  678. chips.addChip(t.id, bet, bank)
  679. }
  680. break;
  681. case "removeChip":
  682. if (bet >= 5) {
  683. playSound("click");
  684. bet -= aChipAmounts[chips.aBetChips[chips.aBetChips.length - 1] + chipLevel];
  685. bank += aChipAmounts[chips.aBetChips[chips.aBetChips.length - 1] + chipLevel];
  686. numbers.setAmounts(bet, bank);
  687. chips.removeChip(bet, bank);
  688. if (bet <= 0) {
  689. panel.hideDealBut()
  690. }
  691. }
  692. break;
  693. case "deal":
  694. if (bet > 0) {
  695. playSound("click");
  696. userInput.removeHitArea("quitGameBetting");
  697. userInput.removeHitArea("addChip");
  698. userInput.removeHitArea("removeChip");
  699. userInput.removeHitArea("deal");
  700. initDeal()
  701. }
  702. break;
  703. case "insure":
  704. playSound("click");
  705. insuranceCard = getCards(1)[0];
  706. bank -= Math.round(bet / 2);
  707. numbers.setAmounts(bet, bank);
  708. insuranceTaken = true;
  709. if (roundToTen(insuranceCard.value) == 10) {
  710. panel.setUp("insuranceTaken");
  711. initCompInsuranceShow();
  712. buttons.canHit = false
  713. } else {
  714. panel.setUp("insuranceLose")
  715. }
  716. break
  717. }
  718. }
  719. function updateDealingEvent() {
  720. if (rotatePause || gameState != "dealing") {
  721. return
  722. }
  723. var e = getDelta();
  724. background.render(ctx);
  725. numbers.render(ctx);
  726. chips.render(ctx);
  727. cards.render(ctx);
  728. buttons.render(ctx);
  729. panel.render(ctx);
  730. requestAnimFrame(updateDealingEvent)
  731. }
  732. function updateBettingEvent() {
  733. if (rotatePause || gameState != "betting") {
  734. return
  735. }
  736. var e = getDelta();
  737. background.render(ctx);
  738. numbers.render(ctx);
  739. chips.render(ctx);
  740. panel.render(ctx);
  741. requestAnimFrame(updateBettingEvent)
  742. }
  743. function updateSplashScreenEvent() {
  744. if (rotatePause || gameState != "splash") {
  745. return
  746. }
  747. var e = getDelta();
  748. splashTimer += e;
  749. if (splashTimer > 2.5) {
  750. initStartScreen();
  751. return
  752. }
  753. splash.render(ctx, e);
  754. requestAnimFrame(updateSplashScreenEvent)
  755. }
  756. function updateStartScreenEvent() {
  757. if (rotatePause || gameState != "start") {
  758. return
  759. }
  760. var e = getDelta();
  761. screens.render(ctx, e);
  762. requestAnimFrame(updateStartScreenEvent)
  763. }
  764. function getDelta() {
  765. var e = (new Date).getTime();
  766. var t = (e - previousTime) / 1e3;
  767. previousTime = e;
  768. if (t > .5) {
  769. t = 0
  770. }
  771. return t
  772. }
  773. function renderSprite(e) {
  774. ctx.save();
  775. ctx.translate(e.x, e.y);
  776. ctx.rotate(e.rotation);
  777. e.render(ctx);
  778. ctx.restore()
  779. }
  780. function loadPreAssets() {
  781. if (aLangs.length > 1) {
  782. preAssetLib = new Utils.AssetLoader(curLang, [{
  783. id: "langSelect",
  784. file: "images/langSelect.jpg"
  785. }, {
  786. id: "preloadImage",
  787. file: "images/preloadImage.jpg"
  788. }], ctx, canvas.width, canvas.height, false);
  789. if (curLang == null) preAssetLib.onReady(initLangSelect);
  790. else preAssetLib.onReady(loadAssets)
  791. } else {
  792. curLang = aLangs[0];
  793. preAssetLib = new Utils.AssetLoader(curLang, [{
  794. id: "preloadImage",
  795. file: "images/preloadImage.jpg"
  796. }], ctx, canvas.width, canvas.height, false);
  797. preAssetLib.onReady(initLoadAssets)
  798. }
  799. }
  800. function initLangSelect() {
  801. var e = preAssetLib.getData("langSelect");
  802. ctx.drawImage(e.img, canvas.width / 2 - e.img.width / 2, canvas.height / 2 - e.img.height / 2);
  803. var t = 140;
  804. for (var n = 0; n < aLangs.length; n++) {
  805. var r = canvas.width / 2 - t * aLangs.length / 2 + n * t;
  806. var i = canvas.height / 2 - t / 2;
  807. userInput.addHitArea("langSelect", butEventHandler, {
  808. lang: aLangs[n]
  809. }, {
  810. type: "rect",
  811. aRect: [r, i, r + t, i + 140]
  812. })
  813. }
  814. }
  815. function initLoadAssets() {
  816. var e = preAssetLib.getData("preloadImage");
  817. ctx.drawImage(e.img, canvas.width / 2 - e.img.width / 2, canvas.height / 2 - e.img.height - 10);
  818. loadAssets()
  819. }
  820. function loadAssets() {
  821. assetLib = new Utils.AssetLoader(curLang, [{
  822. id: "background",
  823. file: "images/" + curLang + "/background.jpg"
  824. }, {
  825. id: "helpScreen",
  826. file: "images/" + curLang + "/helpScreen.jpg"
  827. }, {
  828. id: "titleScreen",
  829. file: "images/" + curLang + "/titleScreen.jpg"
  830. }, {
  831. id: "rotateDeviceMessage",
  832. file: "images/rotateDeviceMessage.jpg"
  833. }, {
  834. id: "splash",
  835. file: "images/splashScreen.jpg"
  836. }, {
  837. id: "playBut",
  838. file: "images/" + curLang + "/playBut.png"
  839. }, {
  840. id: "sgLogo",
  841. file: SG.getLogoUrl()
  842. }, {
  843. id: "panels",
  844. file: "images/" + curLang + "/panels_379x159.png",
  845. oData: {
  846. columns: 4,
  847. spriteWidth: 379,
  848. spriteHeight: 159
  849. }
  850. }, {
  851. id: "numbers",
  852. file: "images/numbers_17x36.png",
  853. oData: {
  854. columns: 3,
  855. spriteWidth: 17,
  856. spriteHeight: 36
  857. }
  858. }, {
  859. id: "cards",
  860. file: "images/cards_128x173.png",
  861. oData: {
  862. columns: 9,
  863. spriteWidth: 128,
  864. spriteHeight: 173
  865. }
  866. }, {
  867. id: "buttons",
  868. file: "images/" + curLang + "/buttons_131x133.png",
  869. oData: {
  870. columns: 4,
  871. spriteWidth: 131,
  872. spriteHeight: 133
  873. }
  874. }, {
  875. id: "chips",
  876. file: "images/chips_133x133.png",
  877. oData: {
  878. columns: 2,
  879. spriteWidth: 133,
  880. spriteHeight: 133
  881. }
  882. }], ctx, canvas.width, canvas.height);
  883. if (allowSound && !muted) {}
  884. assetLib.onReady(initStartScreen)
  885. }
  886. function resizeCanvas() {
  887. var e = window.innerWidth;
  888. var t = window.innerHeight;
  889. if (e > 480) {
  890. e -= 1;
  891. t -= 1
  892. }
  893. if (window.innerWidth > window.innerHeight && isMobile) {
  894. if (gameState != "loading") {
  895. rotatePauseOn()
  896. }
  897. if (e / canvas.width < t / canvas.height) {
  898. canvas.style.width = e + "px";
  899. canvas.style.height = e / canvas.width * canvas.height + "px";
  900. canvasX = 0;
  901. canvasY = (t - e / canvas.width * canvas.height) / 2;
  902. canvasScaleX = canvasScaleY = canvas.width / e;
  903. div.style.marginTop = canvasY + "px";
  904. div.style.marginLeft = canvasX + "px"
  905. } else {
  906. canvas.style.width = t / canvas.height * canvas.width + "px";
  907. canvas.style.height = t + "px";
  908. canvasX = (e - t / canvas.height * canvas.width) / 2;
  909. canvasY = 0;
  910. canvasScaleX = canvasScaleY = canvas.height / t;
  911. div.style.marginTop = canvasY + "px";
  912. div.style.marginLeft = canvasX + "px"
  913. }
  914. } else if (!isMobile) {
  915. if (rotatePause) {
  916. rotatePauseOff()
  917. }
  918. if (e / canvas.width < t / canvas.height) {
  919. canvas.style.width = e + "px";
  920. canvas.style.height = e / canvas.width * canvas.height + "px";
  921. canvasX = 0;
  922. canvasY = (t - e / canvas.width * canvas.height) / 2;
  923. canvasScaleX = canvasScaleY = canvas.width / e;
  924. div.style.marginTop = canvasY + "px";
  925. div.style.marginLeft = canvasX + "px"
  926. } else {
  927. canvas.style.width = t / canvas.height * canvas.width + "px";
  928. canvas.style.height = t + "px";
  929. canvasX = (e - t / canvas.height * canvas.width) / 2;
  930. canvasY = 0;
  931. canvasScaleX = canvasScaleY = canvas.height / t;
  932. div.style.marginTop = canvasY + "px";
  933. div.style.marginLeft = canvasX + "px"
  934. }
  935. } else {
  936. if (rotatePause) {
  937. rotatePauseOff()
  938. }
  939. canvasX = canvasY = 0;
  940. canvasScaleX = canvas.width / e;
  941. canvasScaleY = canvas.height / t;
  942. canvas.style.width = e + "px";
  943. canvas.style.height = t + "px";
  944. div.style.marginTop = 0 + "px";
  945. div.style.marginLeft = 0 + "px"
  946. }
  947. userInput.setCanvas(canvasX, canvasY, canvasScaleX, canvasScaleY)
  948. }
  949. function playSound(e) {
  950. if (allowSound) {
  951. sound.play(e)
  952. }
  953. }
  954. function toggleMute() {
  955. muted = !muted;
  956. if (allowSound) {
  957. if (muted) {
  958. Howler.mute()
  959. } else {
  960. Howler.unmute()
  961. }
  962. }
  963. }
  964. function toggleManualPause() {
  965. if (!manualPause) {
  966. manualPause = true;
  967. if (allowSound) {
  968. Howler.mute()
  969. }
  970. pauseCoreOn()
  971. } else {
  972. manualPause = false;
  973. if (allowSound) {
  974. if (!muted) {
  975. Howler.unmute()
  976. }
  977. }
  978. pauseCoreOff()
  979. }
  980. }
  981. function rotatePauseOn() {
  982. rotatePause = true;
  983. ctx.drawImage(assetLib.getImg("rotateDeviceMessage"), 0, 0);
  984. pauseCoreOn()
  985. }
  986. function rotatePauseOff() {
  987. rotatePause = false;
  988. pauseCoreOff()
  989. }
  990. function pauseCoreOn() {
  991. userInput.pauseIsOn = true;
  992. switch (gameState) {
  993. case "start":
  994. break;
  995. case "betting":
  996. break;
  997. case "dealing":
  998. break
  999. }
  1000. }
  1001. function pauseCoreOff() {
  1002. previousTime = (new Date).getTime();
  1003. userInput.pauseIsOn = false;
  1004. switch (gameState) {
  1005. case "splash":
  1006. updateSplashScreenEvent();
  1007. break;
  1008. case "start":
  1009. initStartScreen();
  1010. break;
  1011. case "help":
  1012. initHelp();
  1013. break;
  1014. case "betting":
  1015. updateBettingEvent();
  1016. break;
  1017. case "dealing":
  1018. updateDealingEvent();
  1019. break
  1020. }
  1021. }
  1022. var Utils;
  1023. (function(e) {
  1024. var t = function() {
  1025. function e(e, t, n, r, i, s) {
  1026. if (typeof s === "undefined") {
  1027. s = true
  1028. }
  1029. this.oAssetData = {};
  1030. this.assetsLoaded = 0;
  1031. this.totalAssets = t.length;
  1032. this.ctx = n;
  1033. this.canvasWidth = r;
  1034. this.canvasHeight = i;
  1035. this.showBar = s;
  1036. this.topLeftX = this.canvasWidth / 2 - r / 4;
  1037. this.topLeftY = this.canvasHeight / 2;
  1038. if (this.showBar) {
  1039. var o;
  1040. if (e == "EN" || e == "") {
  1041. o = "加载中..."
  1042. } else if (e == "ES") {
  1043. o = "Cargando..."
  1044. } else if (e == "FR") {
  1045. o = "Chargement..."
  1046. } else if (e == "TR") {
  1047. o = "Yükleme..."
  1048. }
  1049. ctx.fillStyle = "#aaaaaa";
  1050. ctx.textAlign = "center";
  1051. ctx.font = "14px Helvetica";
  1052. ctx.fillText(o, this.canvasWidth / 2, this.topLeftY + 35);
  1053. ctx.strokeStyle = "#aaaaaa";
  1054. ctx.lineWidth = 2;
  1055. ctx.fillStyle = "#ffffff";
  1056. ctx.moveTo(this.topLeftX, this.topLeftY);
  1057. ctx.lineTo(this.topLeftX + r / 2, this.topLeftY + 0);
  1058. ctx.lineTo(this.topLeftX + r / 2, this.topLeftY + 20);
  1059. ctx.lineTo(this.topLeftX + 0, this.topLeftY + 20);
  1060. ctx.lineTo(this.topLeftX + 0, this.topLeftY + 0);
  1061. ctx.stroke()
  1062. }
  1063. for (var u = 0; u < t.length; u++) {
  1064. this.loadImage(t[u])
  1065. }
  1066. }
  1067. e.prototype.loadImage = function(e) {
  1068. var t = this;
  1069. var n = new Image;
  1070. n.onload = function() {
  1071. t.oAssetData[e.id] = {};
  1072. t.oAssetData[e.id].img = n;
  1073. if (e.oData != undefined) {
  1074. t.oAssetData[e.id].oData = e.oData
  1075. }++t.assetsLoaded;
  1076. if (t.showBar) {
  1077. ctx.fillRect(t.topLeftX + 2, t.topLeftY + 2, (t.canvasWidth / 2 - 4) / t.totalAssets * t.assetsLoaded, 16)
  1078. }
  1079. t.checkLoadComplete()
  1080. };
  1081. n.src = e.file
  1082. };
  1083. e.prototype.checkLoadComplete = function() {
  1084. if (this.assetsLoaded == this.totalAssets) {
  1085. this.loadedCallback()
  1086. }
  1087. };
  1088. e.prototype.onReady = function(e) {
  1089. this.loadedCallback = e
  1090. };
  1091. e.prototype.getImg = function(e) {
  1092. return this.oAssetData[e].img
  1093. };
  1094. e.prototype.getData = function(e) {
  1095. return this.oAssetData[e]
  1096. };
  1097. return e
  1098. }();
  1099. e.AssetLoader = t
  1100. })(Utils || (Utils = {}));
  1101. var Utils;
  1102. (function(e) {
  1103. var t = function() {
  1104. function e(e, t, n, r) {
  1105. this.x = 0;
  1106. this.y = 0;
  1107. this.rotation = 0;
  1108. this.radius = 10;
  1109. this.removeMe = false;
  1110. this.frameInc = 0;
  1111. this.animType = "loop";
  1112. this.oImgData = e;
  1113. this.oAnims = this.oImgData.oData.oAnims;
  1114. this.fps = t;
  1115. this.radius = n;
  1116. this.animId = r
  1117. }
  1118. e.prototype.updateAnimation = function(e) {
  1119. this.frameInc += this.fps * e
  1120. };
  1121. e.prototype.resetAnim = function() {
  1122. this.frameInc = 0
  1123. };
  1124. e.prototype.setFrame = function(e) {
  1125. this.fixedFrame = e
  1126. };
  1127. e.prototype.setAnimType = function(e, t) {
  1128. this.animId = t;
  1129. this.animType = e;
  1130. switch (e) {
  1131. case "loop":
  1132. break;
  1133. case "once":
  1134. this.resetAnim();
  1135. this.maxIdx = this.oAnims[this.animId].length - 1;
  1136. break
  1137. }
  1138. };
  1139. e.prototype.render = function(e) {
  1140. if (this.animId != null) {
  1141. var t = this.oAnims[this.animId].length;
  1142. var n = Math.floor(this.frameInc);
  1143. var r = this.oAnims[this.animId][n % t];
  1144. var i = r * this.oImgData.oData.spriteWidth % this.oImgData.img.width;
  1145. var s = Math.floor(r / (this.oImgData.img.width / this.oImgData.oData.spriteWidth)) * this.oImgData.oData.spriteHeight;
  1146. if (this.animType == "once") {
  1147. if (n > this.maxIdx) {
  1148. this.fixedFrame = this.oAnims[this.animId][t - 1];
  1149. this.animId = null;
  1150. this.animEndedFunc();
  1151. var i = this.fixedFrame * this.oImgData.oData.spriteWidth % this.oImgData.img.width;
  1152. var s = Math.floor(this.fixedFrame / (this.oImgData.img.width / this.oImgData.oData.spriteWidth)) * this.oImgData.oData.spriteHeight
  1153. }
  1154. }
  1155. } else {
  1156. var i = this.fixedFrame * this.oImgData.oData.spriteWidth % this.oImgData.img.width;
  1157. var s = Math.floor(this.fixedFrame / (this.oImgData.img.width / this.oImgData.oData.spriteWidth)) * this.oImgData.oData.spriteHeight
  1158. }
  1159. 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)
  1160. };
  1161. return e
  1162. }();
  1163. e.AnimSprite = t
  1164. })(Utils || (Utils = {}));
  1165. var Utils;
  1166. (function(e) {
  1167. var t = function() {
  1168. function e(e, t) {
  1169. this.x = 0;
  1170. this.y = 0;
  1171. this.rotation = 0;
  1172. this.radius = 10;
  1173. this.removeMe = false;
  1174. this.oImgData = e;
  1175. this.radius = t
  1176. }
  1177. e.prototype.setFrame = function(e) {
  1178. this.frameNum = e
  1179. };
  1180. e.prototype.render = function(e) {
  1181. var t = this.frameNum * this.oImgData.oData.spriteWidth % this.oImgData.img.width;
  1182. var n = Math.floor(this.frameNum / (this.oImgData.img.width / this.oImgData.oData.spriteWidth)) * this.oImgData.oData.spriteHeight;
  1183. 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)
  1184. };
  1185. return e
  1186. }();
  1187. e.BasicSprite = t
  1188. })(Utils || (Utils = {}));
  1189. var Utils;
  1190. (function(e) {
  1191. var t = function() {
  1192. function e(e, t) {
  1193. var n = this;
  1194. this.isDown = false;
  1195. this.canvasX = 0;
  1196. this.canvasY = 0;
  1197. this.canvasScaleX = 1;
  1198. this.canvasScaleY = 1;
  1199. this.prevHitTime = 0;
  1200. this.pauseIsOn = false;
  1201. this.isBugBrowser = t;
  1202. e.addEventListener("touchstart", function(e) {
  1203. n.hitDown(e, e.touches[0].pageX, e.touches[0].pageY)
  1204. }, false);
  1205. e.addEventListener("touchend", function(e) {
  1206. n.hitUp(e, e.changedTouches[0].pageX, e.changedTouches[0].pageY)
  1207. }, false);
  1208. e.addEventListener("mousedown", function(e) {
  1209. n.hitDown(e, e.pageX, e.pageY)
  1210. }, false);
  1211. e.addEventListener("mouseup", function(e) {
  1212. n.hitUp(e, e.pageX, e.pageY)
  1213. }, false);
  1214. this.aHitAreas = new Array
  1215. }
  1216. e.prototype.setCanvas = function(e, t, n, r) {
  1217. this.canvasX = e;
  1218. this.canvasY = t;
  1219. this.canvasScaleX = n;
  1220. this.canvasScaleY = r
  1221. };
  1222. e.prototype.hitDown = function(e, t, n) {
  1223. if (this.pauseIsOn) {
  1224. return
  1225. }
  1226. var r = (new Date).getTime();
  1227. if (r - this.prevHitTime < 500 && isBugBrowser) {
  1228. return
  1229. }
  1230. this.prevHitTime = r;
  1231. e.preventDefault();
  1232. e.stopPropagation();
  1233. t = (t - this.canvasX) * this.canvasScaleX;
  1234. n = (n - this.canvasY) * this.canvasScaleY;
  1235. for (var i = 0; i < this.aHitAreas.length; i++) {
  1236. if (this.aHitAreas[i].rect) {
  1237. 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]) {
  1238. this.aHitAreas[i].oData.hitX = t;
  1239. this.aHitAreas[i].oData.hitY = n;
  1240. this.aHitAreas[i].callback(this.aHitAreas[i].id, this.aHitAreas[i].oData);
  1241. break
  1242. }
  1243. } else {}
  1244. }
  1245. };
  1246. e.prototype.hitUp = function(e, t, n) {
  1247. e.preventDefault();
  1248. e.stopPropagation()
  1249. };
  1250. e.prototype.addHitArea = function(e, t, n, r, i) {
  1251. if (typeof i === "undefined") {
  1252. i = false
  1253. }
  1254. if (n == null) {
  1255. n = new Object
  1256. }
  1257. if (i) {
  1258. this.removeHitArea(e)
  1259. }
  1260. switch (r.type) {
  1261. case "image":
  1262. if (r.oImageData.isSpriteSheet) {
  1263. this.aHitAreas.push({
  1264. id: e,
  1265. callback: t,
  1266. oData: n,
  1267. rect: true,
  1268. 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]
  1269. })
  1270. } else {
  1271. this.aHitAreas.push({
  1272. id: e,
  1273. callback: t,
  1274. oData: n,
  1275. rect: true,
  1276. 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]
  1277. })
  1278. }
  1279. break;
  1280. case "rect":
  1281. this.aHitAreas.push({
  1282. id: e,
  1283. callback: t,
  1284. oData: n,
  1285. rect: true,
  1286. area: r.aRect
  1287. });
  1288. break
  1289. }
  1290. };
  1291. e.prototype.removeHitArea = function(e) {
  1292. for (var t = 0; t < this.aHitAreas.length; t++) {
  1293. if (this.aHitAreas[t].id == e) {
  1294. this.aHitAreas.splice(t, 1);
  1295. t -= 1
  1296. }
  1297. }
  1298. };
  1299. return e
  1300. }();
  1301. e.UserInput = t
  1302. })(Utils || (Utils = {}));
  1303. var Utils;
  1304. (function(e) {
  1305. var t = function() {
  1306. function e(e) {
  1307. this.updateFreq = 10;
  1308. this.updateInc = 0;
  1309. this.frameAverage = 0;
  1310. this.display = 1;
  1311. this.log = "";
  1312. this.render = function(e) {
  1313. this.frameAverage += this.delta / this.updateFreq;
  1314. if (++this.updateInc >= this.updateFreq) {
  1315. this.updateInc = 0;
  1316. this.display = this.frameAverage;
  1317. this.frameAverage = 0
  1318. }
  1319. e.textAlign = "left";
  1320. ctx.font = "10px Helvetica";
  1321. e.fillStyle = "#333333";
  1322. e.beginPath();
  1323. e.rect(0, this.canvasHeight - 15, 40, 15);
  1324. e.closePath();
  1325. e.fill();
  1326. e.fillStyle = "#ffffff";
  1327. e.fillText(Math.round(1e3 / (this.display * 1e3)) + " fps " + this.log, 5, this.canvasHeight - 5)
  1328. };
  1329. this.canvasHeight = e
  1330. }
  1331. e.prototype.update = function(e) {
  1332. this.delta = e
  1333. };
  1334. return e
  1335. }();
  1336. e.FpsMeter = t
  1337. })(Utils || (Utils = {}));
  1338. var Elements;
  1339. (function(e) {
  1340. var t = function() {
  1341. function e(e, t, n) {
  1342. this.oImgData = e;
  1343. this.canvasWidth = t;
  1344. this.canvasHeight = n
  1345. }
  1346. e.prototype.update = function(e) {};
  1347. e.prototype.render = function(e) {
  1348. e.drawImage(this.oImgData.img, 0, 0)
  1349. };
  1350. return e
  1351. }();
  1352. e.Background = t
  1353. })(Elements || (Elements = {}));
  1354. var Elements;
  1355. (function(e) {
  1356. var t = function() {
  1357. function e(e, t, n, r) {
  1358. this.incY = 0;
  1359. this.score = 0;
  1360. this.highestScore = 0;
  1361. this.posY = 0;
  1362. this.oScreens = e;
  1363. this.oButs = t;
  1364. this.canvasWidth = n;
  1365. this.canvasHeight = r;
  1366. this.posY = -this.canvasHeight
  1367. }
  1368. e.prototype.setRenderFunc = function(e) {
  1369. this.posY = -this.canvasHeight;
  1370. switch (e) {
  1371. case "start":
  1372. this.renderFunc = this.renderStartScreen;
  1373. TweenLite.to(this, .5, {
  1374. posY: 0
  1375. });
  1376. break;
  1377. case "help":
  1378. break;
  1379. case "end":
  1380. break
  1381. }
  1382. };
  1383. e.prototype.render = function(e, t) {
  1384. this.renderFunc(e, t)
  1385. };
  1386. e.prototype.renderStartScreen = function(e, t) {
  1387. this.incY += 5 * t;
  1388. e.drawImage(this.oScreens.startImageData.img, 0, 0);
  1389. 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);
  1390. 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)
  1391. };
  1392. return e
  1393. }();
  1394. e.Screens = t
  1395. })(Elements || (Elements = {}));
  1396. var Elements;
  1397. (function(e) {
  1398. var t = function() {
  1399. function e(e, t, n) {
  1400. this.inc = 0;
  1401. this.oSplashScreenImgData = e;
  1402. this.canvasWidth = t;
  1403. this.canvasHeight = n;
  1404. this.posY = this.canvasHeight;
  1405. TweenLite.to(this, .7, {
  1406. posY: 0,
  1407. ease: "Power2.easeOut"
  1408. })
  1409. }
  1410. e.prototype.render = function(e, t) {
  1411. e.drawImage(this.oSplashScreenImgData.img, 0, this.posY)
  1412. };
  1413. return e
  1414. }();
  1415. e.Splash = t
  1416. })(Elements || (Elements = {}));
  1417. var Elements;
  1418. (function(e) {
  1419. var t = function() {
  1420. function e(e, t, n, r) {
  1421. this.frameNum = 0;
  1422. this.x = 0;
  1423. this.y = 0;
  1424. this.playerHandTotal1 = 0;
  1425. this.playerHandTotal2 = 0;
  1426. this.compHandTotal = 0;
  1427. this.letterSpace = 17;
  1428. this.handSide = "right";
  1429. this.oPanelsImgData = e;
  1430. this.oNumbersImgData = t;
  1431. this.canvasWidth = n;
  1432. this.canvasHeight = r
  1433. }
  1434. e.prototype.setUp = function(e, t) {
  1435. if (typeof t === "undefined") {
  1436. t = null
  1437. }
  1438. this.type = e;
  1439. switch (this.type) {
  1440. case "betting":
  1441. this.aPanels = new Array({
  1442. id: 0,
  1443. posX: this.canvasWidth / 2 - this.oPanelsImgData.oData.spriteWidth / 2,
  1444. posY: -160
  1445. }, {
  1446. id: 7,
  1447. posX: this.canvasWidth,
  1448. posY: 385
  1449. });
  1450. this.renderFunc = this.renderInGame;
  1451. TweenLite.to(this.aPanels[0], .5, {
  1452. posY: -20
  1453. });
  1454. break;
  1455. case "firstDeal":
  1456. this.hideDealBut();
  1457. this.renderFunc = this.renderInGame;
  1458. TweenLite.to(this.aPanels[0], .5, {
  1459. posY: -160,
  1460. onComplete: this.hideDealTweenComplete,
  1461. onCompleteParams: [this]
  1462. });
  1463. if (t.dealType != "blackjack") {
  1464. this.insuranceIsOn = t.insuranceIsOn
  1465. }
  1466. if (this.insuranceIsOn) {
  1467. this.aPanels.push({
  1468. id: 8,
  1469. posX: -380,
  1470. posY: 200
  1471. });
  1472. TweenLite.to(this.aPanels[this.aPanels.length - 1], .5, {
  1473. posX: -225,
  1474. delay: 1
  1475. })
  1476. }
  1477. this.aPanels.push({
  1478. id: 4,
  1479. posX: this.canvasWidth,
  1480. posY: 420
  1481. });
  1482. this.playerValuePanel1 = this.aPanels[this.aPanels.length - 1];
  1483. TweenLite.to(this.aPanels[this.aPanels.length - 1], .5, {
  1484. posX: 445,
  1485. delay: 1
  1486. });
  1487. this.playerHandTotal1 = t.value;
  1488. if (dealType == "blackjack") {
  1489. this.actionCompleteCallback = t.callback;
  1490. TweenLite.to(this.aPanels[this.aPanels.length - 1], .5, {
  1491. posX: 445,
  1492. delay: 1,
  1493. onComplete: this.blackjackDealComplete,
  1494. onCompleteParams: [this]
  1495. })
  1496. } else {
  1497. TweenLite.to(this.aPanels[this.aPanels.length - 1], .5, {
  1498. posX: 445,
  1499. delay: 1
  1500. })
  1501. }
  1502. break;
  1503. case "newPlayerCard":
  1504. if (this.handSide == "right") {
  1505. this.playerHandTotal1 = t.value
  1506. } else {
  1507. this.playerHandTotal2 = t.value
  1508. }
  1509. for (var n = 0; n < this.aPanels.length; n++) {
  1510. if (this.insuranceIsOn && this.aPanels[n].id == 8) {
  1511. TweenLite.to(this.aPanels[n], .5, {
  1512. posX: -380
  1513. })
  1514. }
  1515. }
  1516. break;
  1517. case "newCompCard":
  1518. this.compHandTotal = t.value;
  1519. break;
  1520. case "bust":
  1521. this.aPanels.push({
  1522. id: 3,
  1523. posX: this.canvasWidth / 2 - this.oPanelsImgData.oData.spriteWidth / 2,
  1524. posY: -160
  1525. });
  1526. TweenLite.to(this.aPanels[this.aPanels.length - 1], 1, {
  1527. posY: 213,
  1528. delay: 1,
  1529. ease: "Back.easeOut"
  1530. });
  1531. this.aPanels.push({
  1532. id: 9,
  1533. posX: this.canvasWidth,
  1534. posY: 385
  1535. });
  1536. TweenLite.killTweensOf(this.aPanels[this.aPanels.length - 1]);
  1537. TweenLite.to(this.aPanels[this.aPanels.length - 1], .3, {
  1538. posX: 383,
  1539. delay: 2.3
  1540. });
  1541. if (this.handSide == "right") {
  1542. TweenLite.to(this.playerValuePanel1, .3, {
  1543. posX: this.canvasWidth,
  1544. delay: 2
  1545. })
  1546. }
  1547. if (t.bank < 5) {
  1548. this.aPanels.push({
  1549. id: 14,
  1550. posX: this.canvasWidth / 2 - this.oPanelsImgData.oData.spriteWidth / 2,
  1551. posY: this.canvasHeight
  1552. });
  1553. TweenLite.to(this.aPanels[this.aPanels.length - 1], .3, {
  1554. posY: 600,
  1555. delay: 2,
  1556. ease: "Back.easeOut"
  1557. })
  1558. }
  1559. break;
  1560. case "blackjack":
  1561. this.aPanels.push({
  1562. id: 1,
  1563. posX: this.canvasWidth / 2 - this.oPanelsImgData.oData.spriteWidth / 2,
  1564. posY: -160
  1565. });
  1566. TweenLite.to(this.aPanels[this.aPanels.length - 1], 1, {
  1567. posY: 213,
  1568. delay: 1,
  1569. ease: "Elastic.easeOut"
  1570. });
  1571. this.aPanels.push({
  1572. id: 9,
  1573. posX: this.canvasWidth,
  1574. posY: 385
  1575. });
  1576. TweenLite.to(this.aPanels[this.aPanels.length - 1], .3, {
  1577. posX: 383,
  1578. delay: 2.3
  1579. });
  1580. for (var n = 0; n < this.aPanels.length; n++) {
  1581. if (this.aPanels[n].id == 4) {
  1582. TweenLite.to(this.aPanels[n], .3, {
  1583. posX: this.canvasWidth,
  1584. delay: 2
  1585. });
  1586. break
  1587. }
  1588. }
  1589. for (var n = 0; n < this.aPanels.length; n++) {
  1590. if (this.insuranceIsOn && this.aPanels[n].id == 8) {
  1591. TweenLite.to(this.aPanels[n], .5, {
  1592. posX: -380
  1593. })
  1594. }
  1595. }
  1596. break;
  1597. case "push":
  1598. this.aPanels.push({
  1599. id: 6,
  1600. posX: this.canvasWidth / 2 - this.oPanelsImgData.oData.spriteWidth / 2,
  1601. posY: -160
  1602. });
  1603. TweenLite.to(this.aPanels[this.aPanels.length - 1], 1, {
  1604. posY: 213,
  1605. delay: 1,
  1606. ease: "Back.easeOut"
  1607. });
  1608. this.aPanels.push({
  1609. id: 9,
  1610. posX: this.canvasWidth,
  1611. posY: 385
  1612. });
  1613. TweenLite.to(this.aPanels[this.aPanels.length - 1], .3, {
  1614. posX: 383,
  1615. delay: 2.3
  1616. });
  1617. for (var n = 0; n < this.aPanels.length; n++) {
  1618. if (this.aPanels[n].id == 4) {
  1619. TweenLite.to(this.aPanels[n], .3, {
  1620. posX: this.canvasWidth,
  1621. delay: 2
  1622. });
  1623. break
  1624. }
  1625. }
  1626. for (var n = 0; n < this.aPanels.length; n++) {
  1627. if (this.insuranceIsOn && this.aPanels[n].id == 8) {
  1628. TweenLite.to(this.aPanels[n], .5, {
  1629. posX: -380
  1630. })
  1631. }
  1632. }
  1633. break;
  1634. case "compPlay":
  1635. this.aPanels.push({
  1636. id: 5,
  1637. posX: this.canvasWidth,
  1638. posY: 80
  1639. });
  1640. this.compValuePanel = this.aPanels[this.aPanels.length - 1];
  1641. TweenLite.to(this.aPanels[this.aPanels.length - 1], .5, {
  1642. posX: 445,
  1643. delay: 1
  1644. });
  1645. this.compHandTotal = t.value;
  1646. break;
  1647. case "insuranceTaken":
  1648. for (var n = 0; n < this.aPanels.length; n++) {
  1649. if (this.insuranceIsOn && this.aPanels[n].id == 8) {
  1650. TweenLite.to(this.aPanels[n], .5, {
  1651. posX: -380
  1652. })
  1653. }
  1654. }
  1655. break;
  1656. case "insuranceLose":
  1657. for (var n = 0; n < this.aPanels.length; n++) {
  1658. if (this.insuranceIsOn && this.aPanels[n].id == 8) {
  1659. TweenLite.to(this.aPanels[n], .5, {
  1660. posX: -380
  1661. })
  1662. }
  1663. }
  1664. this.aPanels.push({
  1665. id: 13,
  1666. posX: this.canvasWidth / 2 - this.oPanelsImgData.oData.spriteWidth / 2,
  1667. posY: -160
  1668. });
  1669. TweenLite.to(this.aPanels[this.aPanels.length - 1], .5, {
  1670. posY: -20
  1671. });
  1672. break;
  1673. case "hidePlayOn":
  1674. for (var n = 0; n < this.aPanels.length; n++) {
  1675. if (this.aPanels[n].id == 13) {
  1676. TweenLite.to(this.aPanels[n], .5, {
  1677. posY: -160
  1678. })
  1679. }
  1680. }
  1681. break;
  1682. case "insuranceWin":
  1683. this.aPanels.push({
  1684. id: 10,
  1685. posX: this.canvasWidth / 2 - this.oPanelsImgData.oData.spriteWidth / 2,
  1686. posY: -160
  1687. });
  1688. TweenLite.to(this.aPanels[this.aPanels.length - 1], 1, {
  1689. posY: 213,
  1690. ease: "Back.easeOut"
  1691. });
  1692. this.aPanels.push({
  1693. id: 9,
  1694. posX: this.canvasWidth,
  1695. posY: 385
  1696. });
  1697. TweenLite.to(this.aPanels[this.aPanels.length - 1], .3, {
  1698. posX: 383,
  1699. delay: 1.3
  1700. });
  1701. for (var n = 0; n < this.aPanels.length; n++) {
  1702. if (this.aPanels[n].id == 4) {
  1703. TweenLite.to(this.aPanels[n], .3, {
  1704. posX: this.canvasWidth,
  1705. delay: 1
  1706. });
  1707. break
  1708. }
  1709. }
  1710. break;
  1711. case "playerWin":
  1712. this.aPanels.push({
  1713. id: 12,
  1714. posX: this.canvasWidth / 2 - this.oPanelsImgData.oData.spriteWidth / 2,
  1715. posY: -160
  1716. });
  1717. TweenLite.to(this.aPanels[this.aPanels.length - 1], 1, {
  1718. posY: 213,
  1719. ease: "Back.easeOut"
  1720. });
  1721. this.aPanels.push({
  1722. id: 9,
  1723. posX: this.canvasWidth,
  1724. posY: 385
  1725. });
  1726. TweenLite.to(this.aPanels[this.aPanels.length - 1], .3, {
  1727. posX: 383,
  1728. delay: 1.3
  1729. });
  1730. for (var n = 0; n < this.aPanels.length; n++) {
  1731. if (this.aPanels[n].id == 4) {
  1732. TweenLite.to(this.aPanels[n], .3, {
  1733. posX: this.canvasWidth,
  1734. delay: 1
  1735. });
  1736. break
  1737. }
  1738. }
  1739. break;
  1740. case "compWin":
  1741. this.aPanels.push({
  1742. id: 11,
  1743. posX: this.canvasWidth / 2 - this.oPanelsImgData.oData.spriteWidth / 2,
  1744. posY: -160
  1745. });
  1746. TweenLite.to(this.aPanels[this.aPanels.length - 1], 1, {
  1747. posY: 213,
  1748. ease: "Back.easeOut"
  1749. });
  1750. this.aPanels.push({
  1751. id: 9,
  1752. posX: this.canvasWidth,
  1753. posY: 385
  1754. });
  1755. TweenLite.to(this.aPanels[this.aPanels.length - 1], .3, {
  1756. posX: 383,
  1757. delay: 1.3
  1758. });
  1759. for (var n = 0; n < this.aPanels.length; n++) {
  1760. if (this.aPanels[n].id == 4) {
  1761. TweenLite.to(this.aPanels[n], .3, {
  1762. posX: this.canvasWidth,
  1763. delay: 1
  1764. });
  1765. break
  1766. }
  1767. }
  1768. if (t.bank < 5) {
  1769. this.aPanels.push({
  1770. id: 14,
  1771. posX: this.canvasWidth / 2 - this.oPanelsImgData.oData.spriteWidth / 2,
  1772. posY: this.canvasHeight
  1773. });
  1774. TweenLite.to(this.aPanels[this.aPanels.length - 1], .3, {
  1775. posY: 600,
  1776. delay: 2,
  1777. ease: "Back.easeOut"
  1778. })
  1779. }
  1780. break;
  1781. case "compBust":
  1782. this.aPanels.push({
  1783. id: 2,
  1784. posX: this.canvasWidth / 2 - this.oPanelsImgData.oData.spriteWidth / 2,
  1785. posY: -160
  1786. });
  1787. TweenLite.to(this.aPanels[this.aPanels.length - 1], 1, {
  1788. posY: 213,
  1789. ease: "Back.easeOut"
  1790. });
  1791. this.aPanels.push({
  1792. id: 9,
  1793. posX: this.canvasWidth,
  1794. posY: 385
  1795. });
  1796. TweenLite.to(this.aPanels[this.aPanels.length - 1], .3, {
  1797. posX: 383,
  1798. delay: 1.3
  1799. });
  1800. for (var n = 0; n < this.aPanels.length; n++) {
  1801. if (this.aPanels[n].id == 4) {
  1802. TweenLite.to(this.aPanels[n], .3, {
  1803. posX: this.canvasWidth,
  1804. delay: 1
  1805. });
  1806. break
  1807. }
  1808. }
  1809. break;
  1810. case "split":
  1811. this.playerHandTotal1 = t.playerHandTotal2;
  1812. this.playerHandTotal2 = t.playerHandTotal1;
  1813. for (var n = 0; n < this.aPanels.length; n++) {
  1814. if (this.insuranceIsOn && this.aPanels[n].id == 8) {
  1815. TweenLite.to(this.aPanels[n], .5, {
  1816. posX: -380
  1817. })
  1818. }
  1819. }
  1820. TweenLite.to(this.playerValuePanel1, .3, {
  1821. posX: this.canvasWidth
  1822. });
  1823. this.aPanels.push({
  1824. id: 4,
  1825. posX: -379,
  1826. posY: 420
  1827. });
  1828. this.playerValuePanel2 = this.aPanels[this.aPanels.length - 1];
  1829. TweenLite.to(this.playerValuePanel2, .3, {
  1830. posX: -291
  1831. });
  1832. this.handSide = "left";
  1833. break;
  1834. case "switchHands":
  1835. this.handSide = "right";
  1836. this.actionCompleteCallback = t.callback;
  1837. TweenLite.to(this.playerValuePanel1, .3, {
  1838. posX: 445,
  1839. delay: .5,
  1840. onComplete: this.panelSwitchRight,
  1841. onCompleteParams: [this]
  1842. });
  1843. if (t.event == "bust") {
  1844. TweenLite.to(this.playerValuePanel2, .3, {
  1845. posX: -379,
  1846. delay: .5
  1847. })
  1848. }
  1849. break
  1850. }
  1851. };
  1852. e.prototype.panelSwitchRight = function(e) {
  1853. e.actionCompleteCallback()
  1854. };
  1855. e.prototype.blackjackDealComplete = function(e) {
  1856. e.actionCompleteCallback()
  1857. };
  1858. e.prototype.hideDealTweenComplete = function(e) {
  1859. for (var t = 0; t < e.aPanels.length; t++) {
  1860. if (e.aPanels[t].id == 0 || e.aPanels[t].id == 7) {
  1861. e.aPanels.splice(t, 1);
  1862. t -= 1
  1863. }
  1864. }
  1865. };
  1866. e.prototype.showDealBut = function() {
  1867. TweenLite.killTweensOf(this.aPanels[1]);
  1868. TweenLite.to(this.aPanels[1], .5, {
  1869. posX: 383
  1870. })
  1871. };
  1872. e.prototype.hideDealBut = function() {
  1873. TweenLite.killTweensOf(this.aPanels[1]);
  1874. TweenLite.to(this.aPanels[1], .5, {
  1875. posX: this.canvasWidth
  1876. })
  1877. };
  1878. e.prototype.render = function(e) {
  1879. this.renderFunc(e)
  1880. };
  1881. e.prototype.renderInGame = function(e) {
  1882. for (var t = 0; t < this.aPanels.length; t++) {
  1883. var n = this.aPanels[t].id * this.oPanelsImgData.oData.spriteWidth % this.oPanelsImgData.img.width;
  1884. var r = Math.floor(this.aPanels[t].id / (this.oPanelsImgData.img.width / this.oPanelsImgData.oData.spriteWidth)) * this.oPanelsImgData.oData.spriteHeight;
  1885. 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)
  1886. }
  1887. if (this.playerHandTotal1 > 0) {
  1888. for (var t = 0; t < this.playerHandTotal1.toString().length; t++) {
  1889. var i = parseFloat(this.playerHandTotal1.toString().charAt(t));
  1890. var n = i * this.oNumbersImgData.oData.spriteWidth % this.oNumbersImgData.img.width;
  1891. var r = Math.floor(i / (this.oNumbersImgData.img.width / this.oNumbersImgData.oData.spriteWidth)) * this.oNumbersImgData.oData.spriteHeight;
  1892. var s;
  1893. s = t * this.letterSpace + 50 - this.letterSpace * this.playerHandTotal1.toString().length / 2;
  1894. 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)
  1895. }
  1896. }
  1897. if (this.playerHandTotal2 > 0) {
  1898. for (var t = 0; t < this.playerHandTotal2.toString().length; t++) {
  1899. var i = parseFloat(this.playerHandTotal2.toString().charAt(t));
  1900. var n = i * this.oNumbersImgData.oData.spriteWidth % this.oNumbersImgData.img.width;
  1901. var r = Math.floor(i / (this.oNumbersImgData.img.width / this.oNumbersImgData.oData.spriteWidth)) * this.oNumbersImgData.oData.spriteHeight;
  1902. var s;
  1903. s = t * this.letterSpace + 329 - this.letterSpace * this.playerHandTotal2.toString().length / 2;
  1904. 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)
  1905. }
  1906. }
  1907. if (this.compHandTotal > 0) {
  1908. for (var t = 0; t < this.compHandTotal.toString().length; t++) {
  1909. var i = parseFloat(this.compHandTotal.toString().charAt(t));
  1910. var n = i * this.oNumbersImgData.oData.spriteWidth % this.oNumbersImgData.img.width;
  1911. var r = Math.floor(i / (this.oNumbersImgData.img.width / this.oNumbersImgData.oData.spriteWidth)) * this.oNumbersImgData.oData.spriteHeight;
  1912. 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)
  1913. }
  1914. }
  1915. };
  1916. return e
  1917. }();
  1918. e.Panel = t
  1919. })(Elements || (Elements = {}));
  1920. var Elements;
  1921. (function(e) {
  1922. var t = function() {
  1923. function e(e, t, n) {
  1924. this.bet = 0;
  1925. this.bank = 0;
  1926. this.letterSpace = 17;
  1927. this.oNumbersImgData = e;
  1928. this.canvasWidth = t;
  1929. this.canvasHeight = n
  1930. }
  1931. e.prototype.setAmounts = function(e, t) {
  1932. this.bet = e;
  1933. this.bank = t;
  1934. // updateShareScore(t);
  1935. // Play68.setRankingScoreDesc(t);
  1936. };
  1937. e.prototype.render = function(e) {
  1938. for (var t = 0; t < this.bet.toString().length; t++) {
  1939. var n = parseFloat(this.bet.toString().charAt(t));
  1940. var r = n * this.oNumbersImgData.oData.spriteWidth % this.oNumbersImgData.img.width;
  1941. var i = Math.floor(n / (this.oNumbersImgData.img.width / this.oNumbersImgData.oData.spriteWidth)) * this.oNumbersImgData.oData.spriteHeight;
  1942. 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)
  1943. }
  1944. for (var t = 0; t < this.bank.toString().length; t++) {
  1945. var n = parseFloat(this.bank.toString().charAt(t));
  1946. var r = n * this.oNumbersImgData.oData.spriteWidth % this.oNumbersImgData.img.width;
  1947. var i = Math.floor(n / (this.oNumbersImgData.img.width / this.oNumbersImgData.oData.spriteWidth)) * this.oNumbersImgData.oData.spriteHeight;
  1948. 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)
  1949. }
  1950. };
  1951. return e
  1952. }();
  1953. e.Numbers = t
  1954. })(Elements || (Elements = {}));
  1955. var Elements;
  1956. (function(e) {
  1957. var t = function() {
  1958. function e(e, t, n, r, i) {
  1959. this.bet = 0;
  1960. this.bank = 0;
  1961. this.oChipImgData = e;
  1962. this.chipLevel = t;
  1963. this.aChipAmounts = n;
  1964. this.canvasWidth = r;
  1965. this.canvasHeight = i;
  1966. this.aChipStacks = new Array({
  1967. targX: 3,
  1968. targY: 630,
  1969. x: 200,
  1970. y: 800
  1971. }, {
  1972. targX: 133,
  1973. targY: 630,
  1974. x: 200,
  1975. y: 800
  1976. }, {
  1977. targX: 266,
  1978. targY: 630,
  1979. x: 200,
  1980. y: 800
  1981. }, {
  1982. targX: 399,
  1983. targY: 630,
  1984. x: 200,
  1985. y: 800
  1986. })
  1987. }
  1988. e.prototype.setAmounts = function(e, t) {
  1989. this.bet = e;
  1990. this.bank = t
  1991. };
  1992. e.prototype.updateChipStacks = function() {
  1993. if (this.bank < this.aChipAmounts[0 + this.chipLevel]) {
  1994. this.aChipStacks[0].y = 800;
  1995. this.aChipStacks[1].y = 800;
  1996. this.aChipStacks[2].y = 800;
  1997. this.aChipStacks[3].y = 800
  1998. } else {
  1999. this.aChipStacks[0].y = this.aChipStacks[0].targY;
  2000. if (this.bank < this.aChipAmounts[1 + this.chipLevel]) {
  2001. this.aChipStacks[1].y = 800;
  2002. this.aChipStacks[2].y = 800;
  2003. this.aChipStacks[3].y = 800
  2004. } else {
  2005. this.aChipStacks[1].y = this.aChipStacks[1].targY;
  2006. if (this.bank < this.aChipAmounts[2 + this.chipLevel]) {
  2007. this.aChipStacks[2].y = 800;
  2008. this.aChipStacks[3].y = 800
  2009. } else {
  2010. this.aChipStacks[2].y = this.aChipStacks[2].targY;
  2011. if (this.bank < this.aChipAmounts[3 + this.chipLevel]) {
  2012. this.aChipStacks[3].y = 800
  2013. } else {
  2014. this.aChipStacks[3].y = this.aChipStacks[3].targY
  2015. }
  2016. }
  2017. }
  2018. }
  2019. };
  2020. e.prototype.setUp = function(e) {
  2021. switch (e) {
  2022. case "betting":
  2023. this.aBetChips = new Array;
  2024. this.renderFunc = this.renderStart;
  2025. var t;
  2026. if (this.bank >= this.aChipAmounts[3 + this.chipLevel]) {
  2027. t = 4
  2028. } else if (this.bank >= this.aChipAmounts[2 + this.chipLevel]) {
  2029. t = 3
  2030. } else if (this.bank >= this.aChipAmounts[1 + this.chipLevel]) {
  2031. t = 2
  2032. } else if (this.bank >= this.aChipAmounts[0 + this.chipLevel]) {
  2033. t = 1
  2034. }
  2035. for (var n = 0; n < t; n++) {
  2036. TweenLite.to(this.aChipStacks[n], .5, {
  2037. y: this.aChipStacks[n].targY,
  2038. x: this.aChipStacks[n].targX,
  2039. ease: "Back.easeOut",
  2040. delay: n * .1
  2041. })
  2042. }
  2043. break;
  2044. case "firstDeal":
  2045. this.renderFunc = this.renderSmall;
  2046. this.aSmallBetChips = new Array;
  2047. for (var n = 0; n < Math.min(this.aBetChips.length, 5); n++) {
  2048. var r = {
  2049. id: this.aBetChips[this.aBetChips.length - n - 1],
  2050. posX: 170 + n * n * 3 + 1 * n,
  2051. posY: 400,
  2052. scale: 1
  2053. };
  2054. this.aSmallBetChips.push(r);
  2055. TweenLite.killTweensOf(this);
  2056. TweenLite.to(this.aSmallBetChips[n], .3, {
  2057. scale: .5,
  2058. posX: Math.random() * 90 + 190,
  2059. posY: Math.random() * 10 + 550,
  2060. delay: n * .1
  2061. })
  2062. }
  2063. for (var n = 0; n < this.aChipStacks.length; n++) {
  2064. TweenLite.to(this.aChipStacks[n], .3, {
  2065. y: 800,
  2066. x: 200,
  2067. delay: n * .1
  2068. })
  2069. }
  2070. break;
  2071. case "double":
  2072. this.renderFunc = this.renderDouble;
  2073. this.aDoubleBetChips = new Array;
  2074. for (var n = 0; n < this.aSmallBetChips.length; n++) {
  2075. var r = {
  2076. id: this.aSmallBetChips[n].id,
  2077. posX: 200,
  2078. posY: 800,
  2079. scale: 1
  2080. };
  2081. this.aDoubleBetChips.push(r);
  2082. TweenLite.to(this.aDoubleBetChips[n], .5, {
  2083. posX: Math.random() * 90 + 190,
  2084. posY: Math.random() * 10 + 550,
  2085. ease: "Back.easeOut",
  2086. delay: .3 + n * .1
  2087. })
  2088. }
  2089. break
  2090. }
  2091. };
  2092. e.prototype.addChip = function(e, t, n) {
  2093. this.setAmounts(t, n);
  2094. this.updateChipStacks();
  2095. this.curChipX = this.aChipStacks[e].targX;
  2096. this.curChipY = this.aChipStacks[e].targY;
  2097. this.curChipId = e;
  2098. var r = Math.min(this.aBetChips.length, 4);
  2099. TweenLite.killTweensOf(this);
  2100. TweenLite.to(this, .3, {
  2101. curChipX: 170 + r * r * 3 + 1 * r,
  2102. curChipY: 400,
  2103. ease: "Back.easeOut",
  2104. onComplete: this.betTweenComplete,
  2105. onCompleteParams: [this]
  2106. });
  2107. this.aBetChips.push(e);
  2108. this.renderFunc = this.renderAdding
  2109. };
  2110. e.prototype.betTweenComplete = function(e) {
  2111. e.renderFunc = e.renderWaiting
  2112. };
  2113. e.prototype.removeChip = function(e, t) {
  2114. this.setAmounts(e, t);
  2115. this.updateChipStacks();
  2116. var n = Math.min(this.aBetChips.length, 4);
  2117. this.curChipX = 170 + n * n * 3 + 1 * n;
  2118. this.curChipY = 400;
  2119. this.curChipId = this.aBetChips[this.aBetChips.length - 1];
  2120. this.aBetChips.pop();
  2121. TweenLite.killTweensOf(this);
  2122. TweenLite.to(this, .3, {
  2123. curChipX: this.aChipStacks[this.curChipId].targX,
  2124. curChipY: this.aChipStacks[this.curChipId].targY,
  2125. ease: "Back.easeIn",
  2126. onComplete: this.betTweenComplete,
  2127. onCompleteParams: [this]
  2128. });
  2129. this.renderFunc = this.renderRemoving
  2130. };
  2131. e.prototype.render = function(e) {
  2132. this.renderFunc(e)
  2133. };
  2134. e.prototype.renderStart = function(e) {
  2135. for (var t = 0; t < this.aChipStacks.length; t++) {
  2136. var n = (t + this.chipLevel) * this.oChipImgData.oData.spriteWidth % this.oChipImgData.img.width;
  2137. var r = Math.floor((t + this.chipLevel) / (this.oChipImgData.img.width / this.oChipImgData.oData.spriteWidth)) * this.oChipImgData.oData.spriteHeight;
  2138. 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)
  2139. }
  2140. };
  2141. e.prototype.renderAdding = function(e) {
  2142. for (var t = 0; t < this.aChipStacks.length; t++) {
  2143. var n = (t + this.chipLevel) * this.oChipImgData.oData.spriteWidth % this.oChipImgData.img.width;
  2144. var r = Math.floor((t + this.chipLevel) / (this.oChipImgData.img.width / this.oChipImgData.oData.spriteWidth)) * this.oChipImgData.oData.spriteHeight;
  2145. 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)
  2146. }
  2147. for (var t = 0; t < Math.min(this.aBetChips.length - 1, 4); t++) {
  2148. var i = this.aBetChips[this.aBetChips.length - 1 - Math.min(this.aBetChips.length - 1, 4) + t] + this.chipLevel;
  2149. var n = i * this.oChipImgData.oData.spriteWidth % this.oChipImgData.img.width;
  2150. var r = Math.floor(i / (this.oChipImgData.img.width / this.oChipImgData.oData.spriteWidth)) * this.oChipImgData.oData.spriteHeight;
  2151. 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)
  2152. }
  2153. var n = (this.curChipId + this.chipLevel) * this.oChipImgData.oData.spriteWidth % this.oChipImgData.img.width;
  2154. var r = Math.floor((this.curChipId + this.chipLevel) / (this.oChipImgData.img.width / this.oChipImgData.oData.spriteWidth)) * this.oChipImgData.oData.spriteHeight;
  2155. 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)
  2156. };
  2157. e.prototype.renderRemoving = function(e) {
  2158. for (var t = 0; t < this.aChipStacks.length; t++) {
  2159. var n = (t + this.chipLevel) * this.oChipImgData.oData.spriteWidth % this.oChipImgData.img.width;
  2160. var r = Math.floor((t + this.chipLevel) / (this.oChipImgData.img.width / this.oChipImgData.oData.spriteWidth)) * this.oChipImgData.oData.spriteHeight;
  2161. 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)
  2162. }
  2163. for (var t = 0; t < Math.min(this.aBetChips.length, 4); t++) {
  2164. var i = this.aBetChips[this.aBetChips.length - Math.min(this.aBetChips.length, 4) + t] + this.chipLevel;
  2165. var n = i * this.oChipImgData.oData.spriteWidth % this.oChipImgData.img.width;
  2166. var r = Math.floor(i / (this.oChipImgData.img.width / this.oChipImgData.oData.spriteWidth)) * this.oChipImgData.oData.spriteHeight;
  2167. 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)
  2168. }
  2169. var n = (this.curChipId + this.chipLevel) * this.oChipImgData.oData.spriteWidth % this.oChipImgData.img.width;
  2170. var r = Math.floor((this.curChipId + this.chipLevel) / (this.oChipImgData.img.width / this.oChipImgData.oData.spriteWidth)) * this.oChipImgData.oData.spriteHeight;
  2171. 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)
  2172. };
  2173. e.prototype.renderWaiting = function(e) {
  2174. for (var t = 0; t < this.aChipStacks.length; t++) {
  2175. var n = (t + this.chipLevel) * this.oChipImgData.oData.spriteWidth % this.oChipImgData.img.width;
  2176. var r = Math.floor((t + this.chipLevel) / (this.oChipImgData.img.width / this.oChipImgData.oData.spriteWidth)) * this.oChipImgData.oData.spriteHeight;
  2177. 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)
  2178. }
  2179. for (var t = 0; t < Math.min(this.aBetChips.length, 5); t++) {
  2180. var i = this.aBetChips[this.aBetChips.length - Math.min(this.aBetChips.length, 5) + t] + this.chipLevel;
  2181. var n = i * this.oChipImgData.oData.spriteWidth % this.oChipImgData.img.width;
  2182. var r = Math.floor(i / (this.oChipImgData.img.width / this.oChipImgData.oData.spriteWidth)) * this.oChipImgData.oData.spriteHeight;
  2183. 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)
  2184. }
  2185. };
  2186. e.prototype.renderSmall = function(e) {
  2187. for (var t = 0; t < this.aChipStacks.length; t++) {
  2188. var n = (t + this.chipLevel) * this.oChipImgData.oData.spriteWidth % this.oChipImgData.img.width;
  2189. var r = Math.floor((t + this.chipLevel) / (this.oChipImgData.img.width / this.oChipImgData.oData.spriteWidth)) * this.oChipImgData.oData.spriteHeight;
  2190. 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)
  2191. }
  2192. for (var t = 0; t < this.aSmallBetChips.length; t++) {
  2193. var i = this.aSmallBetChips[t].id + this.chipLevel;
  2194. var n = i * this.oChipImgData.oData.spriteWidth % this.oChipImgData.img.width;
  2195. var r = Math.floor(i / (this.oChipImgData.img.width / this.oChipImgData.oData.spriteWidth)) * this.oChipImgData.oData.spriteHeight;
  2196. 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)
  2197. }
  2198. };
  2199. e.prototype.renderDouble = function(e) {
  2200. for (var t = 0; t < this.aSmallBetChips.length; t++) {
  2201. var n = this.aSmallBetChips[t].id + this.chipLevel;
  2202. var r = n * this.oChipImgData.oData.spriteWidth % this.oChipImgData.img.width;
  2203. var i = Math.floor(n / (this.oChipImgData.img.width / this.oChipImgData.oData.spriteWidth)) * this.oChipImgData.oData.spriteHeight;
  2204. 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)
  2205. }
  2206. for (var t = 0; t < this.aDoubleBetChips.length; t++) {
  2207. var n = this.aDoubleBetChips[t].id + this.chipLevel;
  2208. var r = n * this.oChipImgData.oData.spriteWidth % this.oChipImgData.img.width;
  2209. var i = Math.floor(n / (this.oChipImgData.img.width / this.oChipImgData.oData.spriteWidth)) * this.oChipImgData.oData.spriteHeight;
  2210. 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)
  2211. }
  2212. };
  2213. return e
  2214. }();
  2215. e.Chips = t
  2216. })(Elements || (Elements = {}));
  2217. var Elements;
  2218. (function(e) {
  2219. var t = function() {
  2220. function e(e, t, n) {
  2221. this.centreId = 0;
  2222. this.oCardsImgData = e;
  2223. this.canvasWidth = t;
  2224. this.canvasHeight = n
  2225. }
  2226. e.prototype.setUp = function(e, t) {
  2227. if (typeof t === "undefined") {
  2228. t = null
  2229. }
  2230. switch (e) {
  2231. case "firstDeal":
  2232. this.aPlayerCards1 = new Array;
  2233. this.aPlayerCards2 = new Array;
  2234. this.aCurPlayerCards = this.aPlayerCards1;
  2235. this.aCompCards = new Array;
  2236. this.aCurPlayerCards.push({
  2237. id: t.aPlayerDealtCards[0].id,
  2238. posX: 200,
  2239. posY: -200,
  2240. rotation: 0
  2241. });
  2242. this.aCurPlayerCards.push({
  2243. id: t.aPlayerDealtCards[1].id,
  2244. posX: 200,
  2245. posY: -200,
  2246. rotation: 0
  2247. });
  2248. this.aCompCards.push({
  2249. id: t.aCompDealtCards[0].id,
  2250. posX: 200,
  2251. posY: -200,
  2252. rotation: 0,
  2253. scaleX: 1
  2254. });
  2255. this.aCompCards.push({
  2256. id: 52,
  2257. posX: 200,
  2258. posY: -200,
  2259. rotation: 0,
  2260. scaleX: 1
  2261. });
  2262. for (var n = 0; n < this.aCurPlayerCards.length; n++) {
  2263. var r = this.getCentreX(n, this.aCurPlayerCards.length, this.centreId);
  2264. TweenLite.to(this.aCurPlayerCards[n], 1, {
  2265. rotation: this.getRotation(r),
  2266. posX: this.getCentreX(n, this.aCurPlayerCards.length, this.centreId),
  2267. posY: 460,
  2268. delay: n * .1
  2269. });
  2270. var r = this.getCentreX(n, this.aCompCards.length, this.centreId);
  2271. TweenLite.to(this.aCompCards[n], 1, {
  2272. rotation: this.getRotation(r),
  2273. posX: this.getCentreX(n, this.aCompCards.length, this.centreId),
  2274. posY: 130,
  2275. delay: n * .1 + .2
  2276. })
  2277. }
  2278. break;
  2279. case "newPlayerCard":
  2280. this.aCurPlayerCards.push({
  2281. id: t.newCard.id,
  2282. posX: 200,
  2283. posY: -200,
  2284. rotation: 0
  2285. });
  2286. for (var n = 0; n < this.aCurPlayerCards.length; n++) {
  2287. var r = this.getCentreX(n, this.aCurPlayerCards.length, this.centreId);
  2288. if (t.callback && n == this.aCurPlayerCards.length - 1) {
  2289. this.actionCompleteCallback = t.callback;
  2290. TweenLite.to(this.aCurPlayerCards[n], 1, {
  2291. rotation: this.getRotation(r),
  2292. posX: r,
  2293. posY: 460,
  2294. onComplete: this.handComplete,
  2295. onCompleteParams: [this]
  2296. });
  2297. break
  2298. }
  2299. TweenLite.to(this.aCurPlayerCards[n], 1, {
  2300. rotation: this.getRotation(r),
  2301. posX: r,
  2302. posY: 460
  2303. })
  2304. }
  2305. break;
  2306. case "newCompCard":
  2307. this.centreId = 0;
  2308. this.aCompCards.push({
  2309. id: t.oNewCard.id,
  2310. posX: 200,
  2311. posY: -200,
  2312. rotation: 0,
  2313. scaleX: 1
  2314. });
  2315. for (var n = 0; n < this.aCompCards.length; n++) {
  2316. var r = this.getCentreX(n, this.aCompCards.length, this.centreId);
  2317. if (t.callback && n == this.aCompCards.length - 1) {
  2318. this.actionCompleteCallback = t.callback;
  2319. TweenLite.to(this.aCompCards[n], 1, {
  2320. rotation: this.getRotation(r),
  2321. posX: r,
  2322. posY: 130,
  2323. onComplete: this.handComplete,
  2324. onCompleteParams: [this]
  2325. });
  2326. break
  2327. }
  2328. TweenLite.to(this.aCompCards[n], 1, {
  2329. rotation: this.getRotation(r),
  2330. posX: r,
  2331. posY: 130
  2332. })
  2333. }
  2334. break;
  2335. case "compPlay":
  2336. this.centreId = 0;
  2337. TweenLite.to(this.aCompCards[1], .5, {
  2338. scaleX: 0,
  2339. ease: "Power1.easeIn"
  2340. });
  2341. this.aCompCards.push({
  2342. id: t.oHoleCard.id,
  2343. posX: this.aCompCards[1].posX,
  2344. posY: this.aCompCards[1].posY,
  2345. rotation: this.aCompCards[1].rotation,
  2346. scaleX: 0
  2347. });
  2348. TweenLite.to(this.aCompCards[2], .5, {
  2349. scaleX: 1,
  2350. delay: .5,
  2351. onComplete: this.holeCardRevealComplete,
  2352. onCompleteParams: [this]
  2353. });
  2354. this.actionCompleteCallback = t.callback;
  2355. break;
  2356. case "compShow":
  2357. this.centreId = 0;
  2358. TweenLite.to(this.aCompCards[1], .5, {
  2359. scaleX: 0,
  2360. ease: "Power1.easeIn"
  2361. });
  2362. this.aCompCards.push({
  2363. id: t.oHoleCard.id,
  2364. posX: this.aCompCards[1].posX,
  2365. posY: this.aCompCards[1].posY,
  2366. rotation: this.aCompCards[1].rotation,
  2367. scaleX: 0
  2368. });
  2369. TweenLite.to(this.aCompCards[2], .5, {
  2370. scaleX: 1,
  2371. delay: .5
  2372. });
  2373. break;
  2374. case "compInsuranceShow":
  2375. this.centreId = 0;
  2376. TweenLite.to(this.aCompCards[1], .5, {
  2377. scaleX: 0,
  2378. ease: "Power1.easeIn"
  2379. });
  2380. this.aCompCards.push({
  2381. id: t.oHoleCard.id,
  2382. posX: this.aCompCards[1].posX,
  2383. posY: this.aCompCards[1].posY,
  2384. rotation: this.aCompCards[1].rotation,
  2385. scaleX: 0
  2386. });
  2387. TweenLite.to(this.aCompCards[2], .5, {
  2388. scaleX: 1,
  2389. delay: .5,
  2390. onComplete: this.holeCardRevealComplete,
  2391. onCompleteParams: [this]
  2392. });
  2393. this.actionCompleteCallback = t.callback;
  2394. break;
  2395. case "split":
  2396. this.aPlayerCards2 = new Array(this.aPlayerCards1.pop());
  2397. this.centreId = 1;
  2398. var r = this.getCentreX(0, this.aCurPlayerCards.length, 1);
  2399. TweenLite.to(this.aCurPlayerCards[0], .5, {
  2400. rotation: this.getRotation(r),
  2401. posX: r
  2402. });
  2403. var r = this.getCentreX(0, this.aPlayerCards2.length, 2);
  2404. TweenLite.to(this.aPlayerCards2[0], .5, {
  2405. rotation: this.getRotation(r),
  2406. posX: r
  2407. });
  2408. break;
  2409. case "switchHands":
  2410. this.centreId = 2;
  2411. this.aCurPlayerCards = this.aPlayerCards2;
  2412. break
  2413. }
  2414. };
  2415. e.prototype.handComplete = function(e) {
  2416. e.actionCompleteCallback()
  2417. };
  2418. e.prototype.holeCardRevealComplete = function(e) {
  2419. for (var t = 0; t < e.aCompCards.length; t++) {
  2420. if (e.aCompCards[t].id == 52) {
  2421. e.aCompCards.splice(t, 1)
  2422. }
  2423. }
  2424. e.actionCompleteCallback()
  2425. };
  2426. e.prototype.getCentreX = function(e, t, n) {
  2427. if (typeof n === "undefined") {
  2428. n = 0
  2429. }
  2430. var r = this.canvasWidth / 2;
  2431. var i = 50;
  2432. if (n == 1) {
  2433. r = this.canvasWidth / 4;
  2434. i = 25
  2435. } else if (n == 2) {
  2436. r = this.canvasWidth / 4 * 3;
  2437. i = 25
  2438. }
  2439. return r + e * i - (t - 1) * i / 2
  2440. };
  2441. e.prototype.getRotation = function(e) {
  2442. return Math.PI / 8 / this.canvasWidth * e - Math.PI / 16
  2443. };
  2444. e.prototype.render = function(e) {
  2445. for (var t = 0; t < this.aCompCards.length; t++) {
  2446. e.save();
  2447. e.translate(this.aCompCards[t].posX, this.aCompCards[t].posY);
  2448. e.rotate(this.aCompCards[t].rotation);
  2449. var n = this.aCompCards[t].id;
  2450. var r = n * this.oCardsImgData.oData.spriteWidth % this.oCardsImgData.img.width;
  2451. var i = Math.floor(n / (this.oCardsImgData.img.width / this.oCardsImgData.oData.spriteWidth)) * this.oCardsImgData.oData.spriteHeight;
  2452. 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);
  2453. e.restore()
  2454. }
  2455. for (var t = 0; t < this.aPlayerCards1.length; t++) {
  2456. e.save();
  2457. ctx.translate(this.aPlayerCards1[t].posX, this.aPlayerCards1[t].posY);
  2458. ctx.rotate(this.aPlayerCards1[t].rotation);
  2459. var n = this.aPlayerCards1[t].id;
  2460. var r = n * this.oCardsImgData.oData.spriteWidth % this.oCardsImgData.img.width;
  2461. var i = Math.floor(n / (this.oCardsImgData.img.width / this.oCardsImgData.oData.spriteWidth)) * this.oCardsImgData.oData.spriteHeight;
  2462. 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);
  2463. e.restore()
  2464. }
  2465. for (var t = 0; t < this.aPlayerCards2.length; t++) {
  2466. e.save();
  2467. ctx.translate(this.aPlayerCards2[t].posX, this.aPlayerCards2[t].posY);
  2468. ctx.rotate(this.aPlayerCards2[t].rotation);
  2469. var n = this.aPlayerCards2[t].id;
  2470. var r = n * this.oCardsImgData.oData.spriteWidth % this.oCardsImgData.img.width;
  2471. var i = Math.floor(n / (this.oCardsImgData.img.width / this.oCardsImgData.oData.spriteWidth)) * this.oCardsImgData.oData.spriteHeight;
  2472. 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);
  2473. e.restore()
  2474. }
  2475. };
  2476. return e
  2477. }();
  2478. e.Cards = t
  2479. })(Elements || (Elements = {}));
  2480. var Elements;
  2481. (function(e) {
  2482. var t = function() {
  2483. function e(e, t, n) {
  2484. this.canHit = false;
  2485. this.oButtonsImgData = e;
  2486. this.canvasWidth = t;
  2487. this.canvasHeight = n;
  2488. this.aButs = new Array({
  2489. targX: 3,
  2490. targY: 630,
  2491. x: 200,
  2492. y: 800,
  2493. isOn: true
  2494. }, {
  2495. targX: 133,
  2496. targY: 630,
  2497. x: 200,
  2498. y: 800,
  2499. isOn: true
  2500. }, {
  2501. targX: 266,
  2502. targY: 630,
  2503. x: 200,
  2504. y: 800,
  2505. isOn: true
  2506. }, {
  2507. targX: 399,
  2508. targY: 630,
  2509. x: 200,
  2510. y: 800,
  2511. isOn: true
  2512. })
  2513. }
  2514. e.prototype.setUp = function(e, t) {
  2515. if (typeof t === "undefined") {
  2516. t = null
  2517. }
  2518. switch (e) {
  2519. case "firstDeal":
  2520. if (t.dealType == "blackjack") {
  2521. return
  2522. }
  2523. if (t.dealType == "normal") {
  2524. this.aButs[0].isOn = false
  2525. }
  2526. if (!t.doubleIsOn) {
  2527. this.aButs[1].isOn = false
  2528. }
  2529. for (var n = 0; n < this.aButs.length; n++) {
  2530. if (this.aButs[n].isOn) {
  2531. TweenLite.to(this.aButs[n], .5, {
  2532. y: this.aButs[n].targY,
  2533. x: this.aButs[n].targX,
  2534. ease: "Back.easeOut",
  2535. delay: 1 + n * .1,
  2536. onComplete: this.allowButs,
  2537. onCompleteParams: [this]
  2538. })
  2539. }
  2540. }
  2541. break;
  2542. case "double":
  2543. case "stand":
  2544. for (var n = 0; n < this.aButs.length; n++) {
  2545. if (this.aButs[n].isOn) {
  2546. TweenLite.to(this.aButs[n], .3, {
  2547. y: 800,
  2548. x: 200,
  2549. delay: n * .1
  2550. })
  2551. }
  2552. }
  2553. break;
  2554. case "split":
  2555. case "hit":
  2556. for (var n = 0; n < 2; n++) {
  2557. if (this.aButs[n].isOn) {
  2558. TweenLite.to(this.aButs[n], .3, {
  2559. y: 800,
  2560. x: 200,
  2561. delay: n * .1
  2562. })
  2563. }
  2564. }
  2565. break;
  2566. case "bust":
  2567. case "insuranceWin":
  2568. for (var n = 0; n < this.aButs.length; n++) {
  2569. if (this.aButs[n].isOn) {
  2570. TweenLite.to(this.aButs[n], .3, {
  2571. y: 800,
  2572. x: 200,
  2573. delay: 1 + n * .1
  2574. })
  2575. }
  2576. }
  2577. break
  2578. }
  2579. };
  2580. e.prototype.allowButs = function(e) {
  2581. e.canHit = true
  2582. };
  2583. e.prototype.render = function(e) {
  2584. for (var t = 0; t < this.aButs.length; t++) {
  2585. if (this.aButs[t].isOn) {
  2586. var n = t * this.oButtonsImgData.oData.spriteWidth % this.oButtonsImgData.img.width;
  2587. var r = Math.floor(t / (this.oButtonsImgData.img.width / this.oButtonsImgData.oData.spriteWidth)) * this.oButtonsImgData.oData.spriteHeight;
  2588. 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)
  2589. }
  2590. }
  2591. };
  2592. return e
  2593. }();
  2594. e.Buttons = t
  2595. })(Elements || (Elements = {}));
  2596. var requestAnimFrame = function() {
  2597. return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(e) {
  2598. window.setTimeout(e, 1e3 / 60, (new Date).getTime())
  2599. }
  2600. }();
  2601. var previousTime;
  2602. var canvas = document.getElementById("canvas");
  2603. var ctx = canvas.getContext("2d");
  2604. canvas.width = 533;
  2605. canvas.height = 800;
  2606. var canvasX;
  2607. var canvasY;
  2608. var canvasScaleX;
  2609. var canvasScaleY;
  2610. var div = document.getElementById("viewporter");
  2611. var sound;
  2612. var music;
  2613. var allowSound = false;
  2614. var muted = false;
  2615. var splash;
  2616. var splashTimer = 0;
  2617. var screens;
  2618. var assetLib;
  2619. var preAssetLib;
  2620. var rotatePause = false;
  2621. var manualPause = false;
  2622. var isMobile = false;
  2623. var gameState = "loading";
  2624. var aLangs = new Array("EN", "ES", "TR");
  2625. var curLang = "";
  2626. SG.trigger({
  2627. type: "start"
  2628. });
  2629. if (SG.lang != null) curLang = (SG.lang + "").toUpperCase();
  2630. var isBugBrowser = false;
  2631. var deviceAgent = navigator.userAgent.toLowerCase();
  2632. 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)) {
  2633. isMobile = true;
  2634. if (deviceAgent.match(/(android)/) && !/Chrome/.test(navigator.userAgent)) {
  2635. isBugBrowser = true
  2636. }
  2637. }
  2638. var userInput = new Utils.UserInput(canvas, isBugBrowser);
  2639. resizeCanvas();
  2640. window.onresize = function() {
  2641. setTimeout(function() {
  2642. resizeCanvas()
  2643. }, 1)
  2644. };
  2645. window.addEventListener("load", function() {
  2646. setTimeout(function() {
  2647. resizeCanvas()
  2648. }, 0);
  2649. var e = function() {
  2650. resizeCanvas()
  2651. };
  2652. window.addEventListener("orientationchange", e, false);
  2653. SG.setOrientationHandler(e);
  2654. SG.setResizeHandler(e)
  2655. });
  2656. if (typeof window.AudioContext !== "undefined" || typeof window.webkitAudioContext !== "undefined" || navigator.userAgent.indexOf("Android") == -1) {}
  2657. var panel;
  2658. var background;
  2659. var bet = 0;
  2660. var bank = 0;
  2661. var numbers;
  2662. var chips;
  2663. var aChipAmounts = new Array(5, 10, 25, 100, 500, 1e3);
  2664. var cards;
  2665. var aDeck;
  2666. var dealType;
  2667. var buttons;
  2668. var aPCards1;
  2669. var aPCards2;
  2670. var aCurPlayerCards;
  2671. var aCompCards;
  2672. var insuranceTaken = false;
  2673. var splitTaken = false;
  2674. var insuranceCard;
  2675. var chipLevel = 0;
  2676. if (aLangs.length > 1) {
  2677. loadPreAssets()
  2678. } else {
  2679. curLang = aLangs[0];
  2680. loadAssets()
  2681. }