-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtable2.html
975 lines (873 loc) · 25.8 KB
/
table2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#port {
width:988px;
height:849px;
background-image:url(table.png);
position:absolute;
}
.card {
background-image:url(cardback.png);
background-repeat:no-repeat;
position:absolute;
}
.kd {
background-image:url(kd.png);
}
.qs {
background-image:url(qs.png);
}
.side-chip {
width:20px;
height:17px;
background-image:url(chip_side_cyan.png);
position:absolute;
}
.top-chip {
width:21px;
height:23px;
background-image:url(chip_top_cyan.png);
position:absolute;
}
.betindicator {
width:50px;
height:30px;
position:absolute;
top:80px;
left:290px;
}
.button {
position:absolute;
width:76px;
height:101px;
}
.shield {
background-image:url(shield.png);
}
.x2 {
width:107px;
height:92px;
background-image:url(x2.png);
}
.osd65 {
width:160px;
height:160px;
position:absolute;
background-image:url(pause.png);
}
</style>
</head>
<body>
<div id='port'></div>
<script type='text/javascript'>
var csstm;
var ifrStop = function(fn) {
var ifr = document.getElementById(fn);
if (ifr)
{
if (fn=='css')
window.clearTimeout(csstm);
document.body.removeChild(ifr);
}
}
var ifrPlay = function(fn) {
var ifr = document.getElementById(fn);
if (ifr) {
//document.body.removeChild(ifr);
ifr.setAttribute('src', '/casinotest/'+fn+audiosuffix);
return;
}
var created=false;
if (!ifr)
{
ifr=document.createElement("iframe");
ifr.setAttribute('width', '1px');
ifr.setAttribute('height', '1px');
ifr.setAttribute('scrolling', 'no');
ifr.style.border="0px";
ifr.setAttribute('id',fn);
ifr.addEventListener('load',function() {
if (fn=='css')
{
csstm = window.setTimeout(function() { ifrPlay(fn); },13000);
}
//CANNOT GET THIS TO WORK, ABOVE IS A HACK WHICH MIGHT NOT WORK DEPENDS ON NETWORK SPEED.
/*//alert(document.getElementsByTagName('iframe')[0].contentWindow.document.getElementsByTagName('embed')[0].tagName);
document.getElementsByTagName('iframe')[0].contentWindow.document.getElementsByTagName('embed')[0].addEventListener('ended',function() {
console.log('end play detected at %o',fn);
document.body.removeChild(ifr); //console.log("%o loaded",ifr);
if (fn=='css') frPlay(fn);
},false);*/
});
created=true;
}
ifr.setAttribute('src', '/casinotest/'+fn+audiosuffix);
if (created) document.body.appendChild(ifr);
}
//old iOS 3.x method, does not work on iOs 4.x, and the document.getElementById('audioel').load() & .play does not work, either.
function fakeClick(fn) {
var a = document.createElement('a');
a.id = 'fakeClick';
a.href='#';
a.addEventListener('click',function(e) {
e.preventDefault();
fn();
},false);
document.body.appendChild(a);
var evt,
el = document.getElementById('fakeClick');
if (document.createEvent) {
evt = document.createEvent("MouseEvents");
if (evt.initMouseEvent) {
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
el.dispatchEvent(evt);
}
}
document.body.removeChild(el);
}
//whether to force html5 audio
var FORCEAUDIO = (/forceaudio=1/.exec(location.href)?true:false);
var APPLE = /(iPad|iPhone)/.exec(navigator.userAgent)?true:false;
var WEBKIT = /WebKit/.exec(navigator.userAgent)?true:false;
var NORUN = (/norun=1/.exec(location.href))?true:false;
var IE = /MSIE/.exec(navigator.userAgent)?true:false;
//implement Array.indexOf for MSIE :D
if (IE) {
if(!Array.indexOf){
Array.prototype.indexOf = function(obj){
for(var i=0; i<this.length; i++){
if(this[i]==obj){
return i;
}
}
return -1;
}
}
}
if (/nowebkit=1/.exec(location.href)) WEBKIT=false;
if (/(&|\?)webkit=1/.exec(location.href)) WEBKIT=true;
var audiosuffix = (APPLE?'.mp3':'.ogg'); //apple likes mp3, ff & chrome audio tag plays .ogg
var c = document.getElementById('port');
if (typeof(console)=='undefined') console = {log: function() { }};
var chrome = (/Chrome/.exec(navigator.userAgent))?true:false;
var sounds = ['chip','card','coins','css'];
var controls={};
if (!APPLE || FORCEAUDIO) { //instantiate normal html audio controls only for non apple
for (var i=0;i<sounds.length;i++)
{
//console.log("creating control for sound %o",sounds[i]);
var el = document.createElement('audio');
el.setAttribute('id',sounds[i]);
el.src=sounds[i]+audiosuffix;
el.preload='auto';
el.controls=true; el.autobuffer=true;
if (!FORCEAUDIO) el.style.display='none';
if (sounds[i]=='css')
{
var bgmp = function()
{
bgmusicplay();
};
if (!IE) el.addEventListener('ended',bgmp,false);
else el.attachEvent('onended',bgmp);
}
document.body.appendChild(el);
//console.log("appended %o",el);
controls[sounds[i]]=el;
}
}
var chipsndplay = function() {
if (NOSOUND) return;
if (!FORCEAUDIO && APPLE) return;
if (IE) return;
controls['chip'].play();
}
var cardsndplay = function() {
if (NOSOUND) return;
if (!FORCEAUDIO && APPLE) return;
if (IE) return;
controls['card'].play();
}
var coinssndplay = function() {
if (NOSOUND) return;
if (!FORCEAUDIO && APPLE) return;
if (IE) return;
controls['coins'].play();
}
var bgmusicpause = function() {
if (NOSOUND) return;
if (IE) return;
if (APPLE && !FORCEAUDIO) { ifrStop('css'); }
else
controls['css'].pause();
}
var bgmusicplay = function() {
if (NOSOUND) return;
if (IE) return;
if (APPLE && !FORCEAUDIO) ifrPlay('css'); //we can only reliably play 1 background track with the iframe hack.
else
{
fakeClick(function() {
controls['css'].play();
});
}
}
//don't use SM2 at the time being
/*
soundManager.url = 'soundmanager/swf/'; // directory where SM2 .SWFs live
soundManager.useFlashBlock = false;
var bgmusic,chipsnd,cardsnd,coinssnd;
var chipsndplay = function() {
var chipsnd = soundManager.createSound({id:'chip'+parseInt(Math.random()*10),url:'chip.mp3',multiShotEvents:true});
chipsnd.play();
}
var cardsndplay = function() {
//var cardsnd = soundManager.createSound({id:'card'+parseInt(Math.random()*10),url:'card.mp3',multiShotEvents:true});
cardsnd.play();
}
var coinssnd = function() {
//var coinssnd = soundManager.createSound({id:'coins',url:'coins.mp3',multiShotEvents:true});
coinssnd.play();
}
soundManager.onready(function() {
chipsnd = soundManager.createSound({id:'chip',url:'chip.mp3'});
cardsnd = soundManager.createSound({id:'card',url:'card.mp3'});
coinssnd = soundManager.createSound({id:'coins',url:'coins.mp3'});
bgmusic = soundManager.createSound({id: 'css',url: 'css.mp3',volume:20});
bgmusic.play();
});
soundManager.ontimeout(function() {
alert('timeout starting sm2');
// (Optional) Hrmm, SM2 could not start. Show an error, etc.?
});*/
var imglist = ["table","cardback","kd","qs","chip_side_cyan","chip_top_cyan",'shield'];
var images = {};
for (var i=0;i<imglist.length;i++)
{
images[imglist[i]] = new Image();
images[imglist[i]].src = imglist[i]+'.png'; //);
}
function OSD65(x,y,opa) {
this.x =x;
this.y =y;
if (!opa) opa=0;
this.opacity=opa;
this.direction='none';
this.speed=0.1;
this.show = function() {
this.direction='show';
}
this.fade = function() {
this.direction='fade';
}
this.update = function() {
if (this.direction=='show' && this.opacity<1) this.opacity+=this.speed;
else if (this.direction=='fade' && this.opacity>0) this.opacity-=this.speed;
}
this.display = function() {
if (!this.el)
{
this.el = document.createElement('div');
this.el.className = 'osd65';
this.el.style.zIndex=5;
c.appendChild(this.el);
}
this.el.style.top=this.y+'px';
this.el.style.left=this.x+'px';
this.el.style.opacity=this.opacity;
if (IE) this.el.style.filter = 'alpha(opacity='+parseInt(this.opacity*100)+')';
//console.log('opacity is ',this.el.style.opacity);
var scl = 1/this.opacity;
if (scl>3) scl=3;
var wkt='scale('+scl+')';
this.el.style.transform=
this.el.style.msTransform =
this.el.style.OTransform=
this.el.style.MozTransform=
this.el.style.webkitTransform=
wkt;
}
}
function BetIndicator(min,max) {
this.curmin = 0 ; this.min = min;
this.curmax = 0 ; this.max = max;
this.update = function() {
if (this.curmin!=this.min)
this.curmin+=(this.min-this.curmin)*0.05;
if (!this.curmax!=this.max)
this.curmax+=(this.max-this.curmax)*0.05;
if (Math.abs(this.min-this.curmin)<1) this.curmin = this.min;
if (Math.abs(this.max-this.curmax)<1) this.curmax = this.max;
}
this.display = function() {
if (!this.el)
{
this.el = document.createElement('div');
this.el.className = 'betindicator';
c.appendChild(this.el);
}
//console.log(this.el)
/*p.text("Min:$"+parseInt(this.curmin),280,83)
P.text("Max:$"+parseInt(this.curmax),282,100);*/
this.el.innerHTML='Min:$'+parseInt(this.curmin)+'<br />'+"Max:$"+parseInt(this.curmax);
}
}
function Slot(x,y,chst,nm,deg) {
if (!deg) deg = 0;
this.angle = deg;
this.name = nm;
this.chipstate = chst;
this.x = x;
this.y = y;
this.chips = [];
this.unplace = function(ch) {
delete ch.slot;
var idx = this.chips.indexOf(ch);
if (idx!=-1)
this.chips.splice(idx,1);
return ch;
}
this.place = function(ch,cb) {
ch.slot = this;
var ypos = this.y+(DIMS[this.chipstate][1]/(this.chipstate=='side-chip'?5:-20)*this.chips.length);
//console.log("starting move with cb %o, deg %o",cb,deg);
ch.move(this.x,ypos,this.chipstate,deg,cb);
this.chips.push(ch);
}
this.update = function() {
for (var i=0;i<this.chips.length;i++)
this.chips[i].update();
}
this.display = function() {
//console.log("displaying %o chips on %o,%o",this.chips.length,this.x,this.y);
if (this.chipstate=='side-chip' || this.chipstate=='side-card')
{
for (var i=0;i<this.chips.length;i++)
{
this.chips[i].display();
this.chips[i].el.style.zIndex=i;
}
}
else if (this.chipstate=='top-chip')
{
//we use the pushmatrix trick here to get the chips to stack from the bottom up.
/*P.pushMatrix();
P.translate(0,(this.chips.length*DIMS[this.chipstate][1]/10+ DIMS[this.chipstate][1])*-1);*/
for (var i=this.chips.length-1;i>=0;i--)
{
var ch = this.chips[i];
ch.display();
ch.el.style.zIndex=i;
}
/*P.popMatrix();*/
}
}
return this;
}
function dist() {
var dx, dy, dz;
if (arguments.length === 4) {
dx = arguments[0] - arguments[2];
dy = arguments[1] - arguments[3];
return Math.sqrt(dx * dx + dy * dy);
} else if (arguments.length === 6) {
dx = arguments[0] - arguments[3];
dy = arguments[1] - arguments[4];
dz = arguments[2] - arguments[5];
return Math.sqrt(dx * dx + dy * dy + dz * dz);
}
}
function Chip(x,y,col,state) {
this.movspeed = 0.1;
if (!state) state='side-chip';
this.state = state;
this.x = x; this.y = y; this.col = col; this.state = state;
this.move = function(x,y,state,deg,cb) {
//console.log("cb = %o",cb);
this.tx = x;
this.ty = y;
this.tstate = state;
this.cb = cb;
//console.log("cb was just set to %o",cb);
}
this.update = function() {
//console.log("cb: %o",this.cb);
if (this.tx!=this.x || this.ty!=this.y)
{
var dst = dist(this.x,this.y,this.tx,this.ty);
if (dst<1)
{
this.x = this.tx;
this.y = this.ty;
}
else
{
//console.log("dst is %o",dst);
var nx = (this.tx-this.x)*this.movspeed;
var ny = (this.ty-this.y)*this.movspeed;
this.x+=nx; this.y+=ny;
}
}
else if (this.cb) //typeof(this.cb)!='undefined')
{
//console.log('about to invoke cb')
var cbf = this.cb;
chipsndplay();
this.cb=null;
cbf(this);
}
else if (this.tstate)
{
this.state = this.tstate;
delete this.tstate;
}
//else console.log('this.cb = %o',this.cb);
}
this.display = function() {
if (!this.el)
{
this.el = document.createElement('div');
c.appendChild(this.el);
}
this.el.className=this.state;
var mantrans=false;
if (!WEBKIT)
{
this.el.style.top = this.y+'px';
this.el.style.left = this.x+'px';
mantrans=true;
}
else
{
var wkt ='translate3d('+parseInt(this.x)+'px,'+parseInt(this.y)+'px,0px)';
this.el.style.transform=this.el.style.msTransform = this.el.style.OTransform=this.el.style.MozTransform=this.el.style.webkitTransform=wkt;
}
//alert(wkt); throw "bah "+WEBKIT;
//var img = P.loadImage('chip_'+this.state.replace('-chip','')+'_'+this.col+'.png');
//console.log('about to display chip on %o,%o',this.x,this.y);
//P.image(img,this.x,this.y,DIMS[this.state][0],DIMS[this.state][1]);
}
return this;
}
function Card(kind,x,y,state) {
this.kind = kind;
this.movx = this.curx = x;
this.movy = this.cury = y;
if (!state) state='back';
this.state=state;
this.movdeg = this.angle=0;
this.flipstate=0;
this.movspeed=0.1;
this.update = function() {
var cancb="yes";
//console.log('%o,%o ? %o,%o',this.curx,this.cury,this.movx,this.movy);
if (this.movx!=this.curx || this.movy!=this.cury)
{
var dst = dist(this.curx,this.cury,this.movx,this.movy);
if (dst<1)
{
this.curx = this.movx;
this.cury = this.movy;
}
else
{
//console.log("dst is %o",dst);
var nx = (this.movx-this.curx)*this.movspeed;
var ny = (this.movy-this.cury)*this.movspeed;
this.curx+=nx; this.cury+=ny;
}
cancb="moving";
}
if (Math.abs(this.angle-this.movdeg)<1)
{
//console.log('set angle here (%o, %o)',this.angle,this.movdeg);
this.angle=this.movdeg;
//this.movdeg=null;
}
else if (this.movdeg!=null && this.angle!=this.movdeg)
{
if (this.angle<this.movdeg)
this.angle+=Math.abs(this.angle-this.movdeg)*this.movspeed;
else
this.angle-=Math.abs(this.angle-this.movdeg)*this.movspeed;
cancb="rotating ("+this.angle+","+this.movdeg+")";
}
if (this.state=='flip')
{
this.flipstate+=this.movspeed*35;
if (this.flipstate>=100)
{
this.flipstate=0;
if (this.prevstate=='open') this.state='back';
else if (this.prevstate=='back') this.state='open';
}
cancb="flipping";
}
if (cancb=='yes' && this.cb)
{
//alert('got cb, can cb!');
var cbf = this.cb;
this.cb=null;
cbf(this);
}
else if (this.cb)
{
//console.log("got cb, nocan cb (%o)",cancb);
}
if (!this.angle && this.angle!=0) throw "nan!";
}
this.move = function(nx,ny,state,deg,cb) {
cardsndplay();
if (!deg) deg=0;
//console.log("deg is %o",deg);
this.movx = nx; this.movy = ny; this.movdeg=deg; this.cb = cb;
}
this.flip = function(horiz) {
this.prevstate = this.state;
this.state='flip';
this.horizflip = (horiz?true:false);
this.flipstate=0;
}
this.display = function() {
var imgu = ''; var scl=1; var elv=1; //elevation
if (this.state=='back')
imgu = '';
else if (this.state=='open')
{
imgu = this.kind;
}
else if (this.state=='flip')
{
if ((this.prevstate=='back' && this.flipstate<50) || (this.prevstate=='open' && this.flipstate>=50))
imgu = '';
else if ((this.prevstate=='open' && this.flipstate<50) || (this.prevstate=='back' && this.flipstate>=50))
imgu = this.kind;
if (this.flipstate<50)
{
scl=1-(this.flipstate*2/100);
//elv=1+(this.flipstate*2/100);
}
else if (this.flipstate>=50)
{
scl=((this.flipstate-50) * 2/100);
//elv=2-((this.flipstate-50) * 2/100);
}
//console.log("flipstate %o, imgu: %o, scl: %o, elv: %o",this.flipstate,imgu,scl,elv);
}
/*P.pushMatrix();
P.translate(this.curx,this.cury);
P.scale(1*elv,scl*elv);
P.rotate(P.radians(this.angle));
//P.image(img,this.curx,this.cury,P.width/21.5,P.height/13);
if (false && APPLE)
{
//P.rect(0,0,CARD_WIDTH,CARD_HEIGHT);
P.line(0,0,CARD_WIDTH,0);
P.line(0,0,0,CARD_HEIGHT);
P.line(CARD_WIDTH,CARD_HEIGHT,CARD_WIDTH,0);
P.line(CARD_WIDTH,CARD_HEIGHT,0,CARD_HEIGHT);
}
else
{
var img = P.loadImage(imgu);
P.image(img,0,0,CARD_WIDTH,CARD_HEIGHT);
}
P.popMatrix();*/
if (!this.el)
{
this.el = document.createElement('div');
this.el.style.width = parseInt(CARD_WIDTH)+'px';
this.el.style.height = parseInt(CARD_HEIGHT)+'px';
c.appendChild(this.el);
//console.log('starting off with %o,%o',this.curx,this.cury);
}
this.el.className='card'+(imgu?' '+imgu:'');
//lets try use translate() instead of .left/.top
if (!WEBKIT) //looks like ff / opera do not support translate\translate3d() transforms
{
this.el.style.top=parseInt(this.cury)+'px';
this.el.style.left=parseInt(this.curx)+'px';
var mantrans=true;
}
else
var mantrans=false;
if (this.horizflip)
var sclstr = scl+',1';
else
var sclstr = '1,'+scl;
var wkt =(!mantrans?'translate3d('+parseInt(this.curx)+'px,'+parseInt(this.cury)+'px,0px)':'')+' rotate('+parseInt(this.angle)+'deg) scale('+sclstr+')';
this.el.style.transform=this.el.style.msTransform=this.el.style.OTransform=this.el.style.MozTransform=this.el.style.webkitTransform=wkt;
}
return this;
}
function Button(nm,x,y) {
this.name = nm;
this.x = x;
this.y = y;
this.spin=0;
this.update = function() {
var spinfactor=6;
if (this.mouseover || this.spin>=spinfactor) this.spin+=spinfactor;
if (this.spin>=100) { this.spin=0; this.mouseover=false; }
}
this.mouseMoved = function() {
//console.log('%o,%o',P.mouseX,P.mouseY);
if (!this.img) return;
var myx = this.x; //+this.img.width/2;
var myy = this.y;//+this.img.height/2;
var dist = P.dist(P.mouseX,P.mouseY,myx,myy);
//console.log(dist);
if (dist<=60)
{
//console.log('%o.mouseover=true',this.name);
this.mouseover=true;
}
else
{
this.mouseover=false;
}
}
this.display = function() {
if (!this.el)
{
this.el = document.createElement('div');
this.el.className='button '+this.name;
var ths = this;
var mouseovev = function() {
ths.mouseover=true; ths.spin++; };
if (IE) this.el.attachEvent('onmouseover',mouseovev);
else
this.el.addEventListener('mouseover',mouseovev,false);
c.appendChild(this.el);
}
this.el.style.left = this.x+'px';
this.el.style.top = this.y+'px';
var scl=1;
if (this.spin && this.spin<50)
scl-=this.spin/100*2;
else if (this.spin && this.spin>=50)
scl=Math.abs(1-this.spin/100*2);
var wkt = 'scale('+scl+',1)';
this.el.style.transform=this.el.style.msTransform=this.el.style.OTransform=this.el.style.MozTransform=this.el.style.webkitTransform=wkt;
/*if (!this.img) this.img = P.loadImage(this.name+'.png');
P.pushMatrix();*/
//P.translate(this.img.width*scl,0);
/*P.imageMode(P.CENTER);
P.image(this.img,this.x,this.y,this.img.width*scl,this.img.height);
P.imageMode(P.CORNER);
P.popMatrix();*/
}
return this;
}
function ButtonX2(nm,x,y) {
Button.call(this,nm,x,y)
this.display = function() {
if (!this.el)
{
this.el = document.createElement('div');
this.el.className='button '+this.name;
var ths = this;
var mouseovev = function() {
ths.mouseover=true; ths.spin++; };
if (IE) this.el.attachEvent('onmouseover',mouseovev);
else this.el.addEventListener('mouseover',mouseovev,false);
c.appendChild(this.el);
}
this.el.style.left = this.x+'px';
this.el.style.top = this.y+'px';
//console.log(this.el.style.left,',',this.el.style.top,' and ',this.x,',',this.y);
var scl=1;
if (this.spin && this.spin<50)
{
scl-=this.spin/100*2*30;
}
else if (this.spin && this.spin>=50)
{
scl=(30-Math.abs(1-(50-this.spin)/100*2*30))*-1;
}
var wkt = 'rotate('+scl+'deg)';
this.el.style.MsTransform = this.el.style.transform=this.el.style.OTransform=this.el.style.MozTransform=this.el.style.webkitTransform=wkt;
/* if (!this.img) this.img = P.loadImage(this.name+'.png');
P.pushMatrix();
//P.translate(this.img.width*scl,0);
//console.log('spin = %o, scl = %o',this.spin,scl);
P.imageMode(P.CENTER);
P.translate(this.x,this.y);
P.rotate(P.radians(scl));
//console.log("drawing image %o,%o %o,%o",this.x,this.y,this.img.width,this.img.height);
P.image(this.img
,0 //this.x
,0 //this.y
,this.img.width
,this.img.height);
P.imageMode(P.CORNER);
P.popMatrix();*/
}
}
var CARDS_AMT=10;
var CHIPS_AMT=45;
var SHOW_INDICATOR=true;
var NOBG=false;
var NOSOUND=false;
var cres = /nosound=([0-9]+)/.exec(location.href);
if (cres) NOSOUND=true;
var cres = /cards=([0-9]+)/.exec(location.href);
if (cres) CARDS_AMT=parseInt(cres[1]);
var cres = /chips=([0-9]+)/.exec(location.href);
if (cres) CHIPS_AMT=parseInt(cres[1]);
var cres = /nobg=1/.exec(location.href);
if (cres) NOBG=true;
var cres = /noind=1/.exec(location.href);
if (cres) SHOW_INDICATOR=false;
var cres = /apple=1/.exec(location.href);
if (cres) APPLE=1;
var WIDTH=988;
var HEIGHT=849;
var RATIO = 1;
var CARD_WIDTH = WIDTH/21.5/RATIO;
var CARD_HEIGHT = HEIGHT/13/RATIO;
var CX1 = 410; var CY1 = 250;
var CX2 = CX1+CARD_WIDTH*1.5 ; var CY2 = CY1;
var CX3 = CX1+CARD_WIDTH*3 ; var CY3 = CY1;
var DIMS = {'side-chip':[20,17],'top-chip':[21,23],'side-card':[CARD_WIDTH,CARD_HEIGHT]};
var POS1_X = 275;
var POS1_Y = 280;
var POS1_DEG = 60;
var POS2_X = 360;
var POS2_Y = 382;
var POS2_DEG = 30;
var POS3_X = 483;
var POS3_Y = 425;
var POS3_DEG = 0;
var slots={};
var freecards = [];
var freechips = [];
var buttons = [];
var bind,osd;
var paused=false;
var draw = function() {
//osd works even in pause
osd.update();
osd.display();
if (paused)
{
window.setTimeout(draw,15);
return;
}
for (var sln in slots)
{
//console.log('updating slot %o',sln);
slots[sln].update();
slots[sln].display();
}
bind.update();
bind.display();
for (var i=0;i<buttons.length;i++)
{
buttons[i].update();
buttons[i].display();
}
window.setTimeout(draw,15);
}
var pauseev = function(ev) {
paused=(paused?false:true);
if (paused) bgmusicpause();
if (paused)
{
osd.show();
}
else
{
osd.fade();
bgmusicplay(); //play();
}
};
if (IE) c.attachEvent('onclick',pauseev);
else c.addEventListener('click',pauseev,false);
var loadfunc = function(ev) {
var m = RATIO;
//chip slots
slots['p1'] = new Slot(160/m,265/m,'top-chip','p1');
slots['p2'] = new Slot(225/m,400/m,'top-chip','p2');
slots['p3'] = new Slot(255/m,435/m,'top-chip','p3');
slots['p4'] = new Slot(375/m,515/m,'top-chip','p4');
slots['p5'] = new Slot(430/m,525/m,'top-chip','p5');
slots['p6'] = new Slot(WIDTH-slots['p5'].x+20,slots['p5'].y,'top-chip','p6');
slots['p7'] = new Slot(WIDTH-slots['p4'].x+20,slots['p4'].y,'top-chip','p7');
slots['p8'] = new Slot(WIDTH-slots['p3'].x+20,slots['p3'].y,'top-chip','p8');
slots['p9'] = new Slot(WIDTH-slots['p2'].x+20,slots['p2'].y,'top-chip','p9');
slots['p10'] = new Slot(WIDTH-slots['p1'].x+20,slots['p1'].y,'top-chip','p10');
slots['p11'] = new Slot(381/m,84/m,'side-chip','dealer1'); //dealer
//card "slots"
slots['c1'] = new Slot(POS1_X/m-30,POS1_Y/m+10,'side-card','c1',POS1_DEG);
slots['c2'] = new Slot(POS2_X/m-10,POS2_Y/m+20,'side-card','c2',POS2_DEG);
slots['c3'] = new Slot(POS3_X/m+5,POS3_Y/m+5,'side-card','c3',POS3_DEG);
slots['c4'] = new Slot(WIDTH-POS2_X+10,POS2_Y+10,'side-card','c4',360-POS2_DEG);
slots['c5'] = new Slot(WIDTH-POS1_X+25,POS1_Y+13,'side-card','c5',360-POS1_DEG);
slots['c6'] = new Slot(CX1/m,CY1/m,'side-card','c6',0);
slots['c7'] = new Slot(CX2/m,CY2/m,'side-card','c7',0);
slots['c8'] = new Slot(CX3/m,CY3/m,'side-card','c8',0);
var types = ['qs','kd'];
if (!NORUN) {
for (var i=0;i<CARDS_AMT;i++)
{
var crd = new Card(types[parseInt(Math.random()*2)],190,97,'back');
freecards.push(crd);
var card_placement = function(mycrd) {
window.setTimeout(function() {
if (Math.random()>=0.3) mycrd.flip(Math.random()>0.5?true:false);
//console.log('in card_placement');
var newpos = 'c'+(parseInt(Math.random()*8)+1);
if (mycrd.slot) mycrd.slot.unplace(mycrd);
slots[newpos].place(mycrd,card_placement);
},Math.random()*10000);
}
card_placement(crd);
}
//this is the chips flying
for (var i=0;i<CHIPS_AMT;i++)
{
window.setTimeout(function() {
var ch = new Chip(Math.random()*WIDTH,0,'cyan','side-chip');
freechips.push(ch);
var chip_placement = function(mych) {
window.setTimeout(function() {
var newpos = 'p'+(parseInt(Math.random()*11)+1);
//console.log('chip_placement cb. now at %o, going to %o',(mych.slot?mych.slot.name:'noname'),newpos);
if (mych.slot) mych.slot.unplace(mych);
slots[newpos].place(mych,chip_placement);
},Math.random()*10000);
//console.log(newpos);
}
chip_placement(ch)
},Math.random()*1000);
}
}
bind = new BetIndicator(0,100);
osd = new OSD65(450,250,0);
var bindrand = function() {
window.setTimeout(bindrand,4500);
if (paused) return;
bind.min=Math.random()*100;
bind.max=Math.random()*200;
coinssndplay();
}
var btn = new Button('shield',WIDTH-WIDTH*0.45,HEIGHT-HEIGHT*0.16);
buttons.push(btn);
var btn = new ButtonX2('x2',WIDTH-WIDTH*0.62,HEIGHT-HEIGHT*0.16);
buttons.push(btn);
if (!NORUN)
{
//2nd stage action demo
window.setTimeout(bindrand,2500);
}
window.setTimeout(draw,0);
bgmusicplay();
}
if (IE) window.attachEvent('onload',loadfunc);
else window.addEventListener('load',loadfunc,false);
</script>
</body>
</html>