-
Notifications
You must be signed in to change notification settings - Fork 11
/
triple-number-memory.html
853 lines (744 loc) · 40.8 KB
/
triple-number-memory.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
<!DOCTYPE html>
<html>
<!--
Simple html memory game to teach the concept of numbers.
Remember the place of cards that show the same number in different representations.
Copyright (C) 2017 Jacob Kanev
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
For a copy of the GNU General Public License see <http://www.gnu.org/licenses/>.
-->
<head>
<title>Triple Number Memory</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
html, body {
background-color: #eef;
width: 100vw;
height: 100vh;
margin: 0;
padding: 0;
border: 0;
font-family: Sans-Serif;
overflow: hidden;
}
button {
display: inline;
margin: 1vw;
padding: 1vw;
border: 1px solid #CCCCCC;
-webkit-box-shadow: #FEFFFF 0px 2px 2px ;
-moz-box-shadow: #FEFFFF 0px 2px 2px ;
box-shadow: #FEFFFF 0px 2px 2px ;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
padding: 10px 10px 10px 10px;
text-shadow: 0px 2px 2px rgba(255,255,255,1);
color: #4A4A4A;
background-color: #F7F5F6;
background-image: -webkit-gradient(linear, left top, left bottom, from(#F7F5F6), to(#DDDDDD));
background-image: -webkit-linear-gradient(top, #F7F5F6, #DDDDDD);
background-image: -moz-linear-gradient(top, #F7F5F6, #DDDDDD);
background-image: -ms-linear-gradient(top, #F7F5F6, #DDDDDD);
background-image: -o-linear-gradient(top, #F7F5F6, #DDDDDD);
background-image: linear-gradient(to bottom, #F7F5F6, #DDDDDD);
filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#F7F5F6, endColorstr=#DDDDDD);
white-space: normal;
font-size: 3vmin;
}
button:hover{
border:1px solid #ADADAD;
background-color: #E0E0E0;
background-image: -webkit-gradient(linear, left top, left bottom, from(#E0E0E0), to(#BDBBBC));
background-image: -webkit-linear-gradient(top, #E0E0E0, #BDBBBC);
background-image: -moz-linear-gradient(top, #E0E0E0, #BDBBBC);
background-image: -ms-linear-gradient(top, #E0E0E0, #BDBBBC);
background-image: -o-linear-gradient(top, #E0E0E0, #BDBBBC);
background-image: linear-gradient(to bottom, #E0E0E0, #BDBBBC);
filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#E0E0E0, endColorstr=#BDBBBC);
}
button:active{
border:1px solid #ADADAD;
background-color: #E0E0E0;
background-image: -webkit-gradient(linear, left top, left bottom, from(#BDBBBC), to(#E0E0E0));
background-image: -webkit-linear-gradient(top, #BDBBBC, #E0E0E0);
background-image: -moz-linear-gradient(top, #BDBBBC, #E0E0E0);
background-image: -ms-linear-gradient(top, #BDBBBC, #E0E0E0);
background-image: -o-linear-gradient(top, #BDBBBC, #E0E0E0);
background-image: linear-gradient(to bottom, #BDBBBC, #E0E0E0);
filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#BDBBBC, endColorstr=#E0E0E0);
}
div.dots {
font-weight: bold;
background-color: #eaeaea;
width: 100%;
height: 100%;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
text-align: center;
vertical-align: middle;
color: #a00;
display: none;
}
div.english {
background-color: #eaeaea;
width: 100%;
height: 100%;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
text-align: center;
vertical-align: middle;
color: #060;
display: none;
}
div.german {
background-color: #eaeaea;
width: 100%;
height: 100%;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
text-align: center;
vertical-align: middle;
color: #060;
display: none;
}
div.digits {
background-color: #eaeaea;
width: 100%;
height: 100%;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
text-align: center;
vertical-align: middle;
color: #00a;
display: none;
}
div.card {
position: relative;
float: left;
border: 0.1vw solid #CCCCCC;
margin: 0.3vw;
-webkit-box-shadow: #FEFFFF 0px 2px 2px ;
-moz-box-shadow: #FEFFFF 0px 2px 2px ;
box-shadow: #FEFFFF 0px 2px 2px ;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
padding: 0.3vw;
text-shadow: 0px 2px 2px rgba(255,255,255,1);
color: #4A4A4A;
background-color: #F7F5F6;
background-image: -webkit-gradient(linear, left top, left bottom, from(#F7F5F6), to(#DDDDDD));
background-image: -webkit-linear-gradient(top, #F7F5F6, #DDDDDD);
background-image: -moz-linear-gradient(top, #F7F5F6, #DDDDDD);
background-image: -ms-linear-gradient(top, #F7F5F6, #DDDDDD);
background-image: -o-linear-gradient(top, #F7F5F6, #DDDDDD);
background-image: linear-gradient(to bottom, #F7F5F6, #DDDDDD);
filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#F7F5F6, endColorstr=#DDDDDD);
white-space: normal;
vertical-align: top;
}
div.card:hover{
border: 0.1vw solid #ADADAD;
background-color: #E0E0E0;
background-image: -webkit-gradient(linear, left top, left bottom, from(#E0E0E0), to(#BDBBBC));
background-image: -webkit-linear-gradient(top, #E0E0E0, #BDBBBC);
background-image: -moz-linear-gradient(top, #E0E0E0, #BDBBBC);
background-image: -ms-linear-gradient(top, #E0E0E0, #BDBBBC);
background-image: -o-linear-gradient(top, #E0E0E0, #BDBBBC);
background-image: linear-gradient(to bottom, #E0E0E0, #BDBBBC);
filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#E0E0E0, endColorstr=#BDBBBC);
}
div.card:active{
border: 0.1vw solid #ADADAD;
background-color: #E0E0E0;
background-image: -webkit-gradient(linear, left top, left bottom, from(#BDBBBC), to(#E0E0E0));
background-image: -webkit-linear-gradient(top, #BDBBBC, #E0E0E0);
background-image: -moz-linear-gradient(top, #BDBBBC, #E0E0E0);
background-image: -ms-linear-gradient(top, #BDBBBC, #E0E0E0);
background-image: -o-linear-gradient(top, #BDBBBC, #E0E0E0);
background-image: linear-gradient(to bottom, #BDBBBC, #E0E0E0);
filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#BDBBBC, endColorstr=#E0E0E0);
}
div {
text-shadow: 0px 2px 2px rgba(255,255,255,1);
color: #202020;
}
div.table {
position: absolute; left:0; right:0;padding:0; width:100vw; height:100vh; text-align: justify;
}
div.message {
position: relative;
width:78vw;
height:77vh;
left:1%;
top:1%;
padding: 10vh 10vw 10vh 10vw;
font-size: 3vmin;
display: none;
border: 1px solid #CCCCCC;
-webkit-box-shadow: #FEFFFF 0px 2px 2px ;
-moz-box-shadow: #FEFFFF 0px 2px 2px ;
box-shadow: #FEFFFF 0px 2px 2px ;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
text-shadow: 0px 2px 2px rgba(255,255,255,1);
color: #4A4A4A;
background-color: #F7F5F6;
background-image: -webkit-gradient(linear, left top, left bottom, from(#F7F5F6), to(#DDDDDD));
background-image: -webkit-linear-gradient(top, #F7F5F6, #DDDDDD);
background-image: -moz-linear-gradient(top, #F7F5F6, #DDDDDD);
background-image: -ms-linear-gradient(top, #F7F5F6, #DDDDDD);
background-image: -o-linear-gradient(top, #F7F5F6, #DDDDDD);
background-image: linear-gradient(to bottom, #F7F5F6, #DDDDDD);
filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#F7F5F6, endColorstr=#DDDDDD);
white-space: normal;
vertical-align: top;
}
div.result {
position: relative; float: left; padding: 0.5em; margin: 0.1em;
display: none;
border: 1px solid #CCCCCC;
-webkit-box-shadow: #FEFFFF 0px 2px 2px ;
-moz-box-shadow: #FEFFFF 0px 2px 2px ;
box-shadow: #FEFFFF 0px 2px 2px ;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
input.text {
font-family: verdana, arial, sansserif;
font-size: 3vmin;
position: relative;
float: left;
border: 0.1px solid #CCCCCC;
margin: 1vw;
padding: 1vw;
-webkit-box-shadow: #FEFFFF 0px 2px 2px ;
-moz-box-shadow: #FEFFFF 0px 2px 2px ;
box-shadow: #FEFFFF 0px 2px 2px ;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
text-shadow: 0px 2px 2px rgba(255,255,255,1);
color: #000000;
background-color: #F7F5F6;
}
div.player {
font-size: 3vmin;
padding: 5vw;
position: absolute;
left:33vw;
width:20vw;
top:13vmin;
height: 20vh;
display: none;
-webkit-box-shadow: #FEFFFF 0px 2px 2px ;
-moz-box-shadow: #FEFFFF 0px 2px 2px ;
box-shadow: 0px 0px 50px #505050;
-webkit-border-radius: 30px;
-moz-border-radius: 30px;
border-radius: 30px;
text-shadow: 0px 2px 2px rgba(255,255,255,1);
}
span.stars {
text-shadow: 0px 0px 1px #400;
color: #fb0;
font-size: 5vmin;
}
</style>
<script type="text/javascript">
<!--
// global gameHistory object
var _gameHistory = null;
var _globalLock = false;
var _quitFullScreen = false;
var _language = "en";
//______________________________
// Class representing a single player.
// Used to count points, colours and names.
function Player(name, colour, id)
{
this.name = name;
this.colour = colour;
this.id = id;
this.points = 0;
this.pointString = "";
this.nextPlayer = 0;
document.getElementById(this.id).style.backgroundColor = this.colour;
}
//______________________________
// Proceed to next player, announce, and remove lock
Player.prototype.next = function()
{
// show message
if (_language == "en")
document.getElementById(this.id).innerHTML = "Next turn: " + this.name;
if (_language == "de")
document.getElementById(this.id).innerHTML = "Nächster Zug: " + this.name;
document.getElementById(this.id).style.display = "block";
// start time out for hiding message
setTimeout( function(id) { document.getElementById(id).style.display = "none"; _globalLock = false; }.bind(0, this.id), 700 );
}
//______________________________
// Adds a point to the player's score, displays a message with the new score and releases the lock
Player.prototype.addPoint = function()
{
// show message
this.points += 1;
this.pointString += " <span class='stars'>★</span>";
message = this.name + ": " + this.points.toString();
if (_language == "en")
message += " points.<br/><br/><br/>" + this.pointString;
if (_language == "de")
message += " Punkte.<br/><br/><br/>" + this.pointString;
document.getElementById(this.id).innerHTML = message;
document.getElementById(this.id).style.display = "block";
// start time out for hiding message
setTimeout( function(id) { document.getElementById(id).style.display = "none"; _globalLock = false;}.bind(0, this.id), 700 );
}
//______________________________
// class for a single memory card
// A memory card is represented by two divs with the outside one representing the card
// and the inside one representing the face. The face div has a class according to the
// type: <div class="card"><div class="digits">23</div></div>
// both divs have distinct IDs
function Card(meaning, type, string, rows, cols)
{
this.meaning = meaning; // the actual number that's on the card
this.type = type; // whether the card has digits, dots, english, ..., on it
this.string = string; // the html representation
this.random = Math.random(); // a random value used for shuffling
this.faceId = meaning.toString() + "_" + type + "_face"; // the respective div id, e.g. "3_english_face"
this.cardId = meaning.toString() + "_" + type + "_card"; // the respective div id for the card, e.g. "3_english_card"
// determine sizes for width, left, top and height
width = Math.floor(89.0 / cols);
left = (100.0 - cols*(width + 1.4)) / 2.0;
height = Math.floor(80.0 / rows);
topValue = (100.0 - rows*(height + 2.4)) / 2.0;
fontSize = type=="dots" ? 30 / cols : 15 / cols;
lineHeight = type=="dots" ? 47 / cols : 80 / cols;
// hack for bug in Chrome on Android
if (navigator.userAgent.indexOf("Chrome") > -1 && navigator.userAgent.indexOf("Android") > -1) {
factor = 0.86;
height *= factor;
topValue *= factor;
fontSize *= factor;
lineHeight *= factor;
}
this.html = "<div class=\"card\" id=\"" + this.cardId + "\" style=\"width:" + width.toString() + "vw; height:" + height.toString() + "vh; left:" + left.toString() + "vw; top:" + topValue.toString() + "vh;\" onClick=\"_gameHistory.move(" + this.meaning.toString() + ", '" + this.type + "');\">"
+ "<div class=\"" + this.type + "\" id=\"" + this.faceId + "\" style=\"font-size:" + fontSize.toString() + "vw; line-height:" + lineHeight.toString() + "vh;\">"
+ this.string
+ "</div>"
+ "</div>";
}
//______________________________
// cover the card so its face is hidden
function coverCard(id)
{
faceId = id + "_face";
document.getElementById(faceId).style.display = "none";
};
//______________________________
// uncover the card so its face is shown
function uncoverCard(id)
{
faceId = id + "_face";
document.getElementById(faceId).style.display = "block";
};
//______________________________
// remove the card from the table
function removeCard(id)
{
cardId = id + "_card";
document.getElementById(cardId).style.visibility = "hidden";
};
//______________________________
// highlight a card
function highlightCard(id, colour)
{
faceId = id + "_face";
document.getElementById(faceId).style.backgroundColor = colour;
};
//______________________________
// gameHistory object, tracks open cards, removes cards and assigns points
// players: array with players
function GameHistory(players, moves)
{
this.openCards = [];
this.players = players;
// assigne next players
for (var i=0; i<this.players.length; i++) {
if (i<this.players.length-1)
this.players[i].nextPlayer = this.players[i+1];
else
this.players[i].nextPlayer = this.players[0];
}
this.currentPlayer = this.players[0];
// adjust point string if there's only one player
if (this.players.length == 1) {
if (_language == "en")
this.currentPlayer.pointString = "moves.";
if (_language == "de")
this.currentPlayer.pointString = "Züge.";
}
this.playerMove = 0;
this.movesLeft = moves;
}
//______________________________
// a card has been clicked -- make a move
GameHistory.prototype.move = function(meaning, type)
{
if (!_globalLock) {
// assemble id
id = meaning.toString() + "_" + type;
// see whether card is already open (clicked accidentally)
var alreadyOpen = false;
for (var i=0; i<this.openCards.length; i++)
if (id === this.openCards[i][0])
alreadyOpen = true;
// if not -
if (!alreadyOpen) {
// lock GUI
_globalLock = true;
nextTimeOut = 0;
// uncover card
uncoverCard(id);
// push card to memory
this.openCards.push([id, meaning]);
// cover latest card that's still open
if (this.openCards.length > 3)
coverCard( this.openCards.shift()[0] );
// if three identical cards are open, remove them
if (this.openCards.length === 3) {
if (this.openCards[0][1] === this.openCards[1][1] && this.openCards[1][1] === this.openCards[2][1]) {
// remove cards and increase value for timeout
nextTimeOut += 700;
for (var i=0; i<3; i++) {
var id = this.openCards.shift()[0];
highlightCard(id, this.currentPlayer.colour);
setTimeout( removeCard.bind(null, id), nextTimeOut );
}
this.movesLeft -= 1;
// add point to current player's score
if (this.players.length > 1) {
nextTimeOut += 700;
setTimeout( function(){ _gameHistory.currentPlayer.addPoint(); }, nextTimeOut );
}
}
}
else
setTimeout( function(){_globalLock=false;}, nextTimeOut );
if (this.players.length == 1)
this.currentPlayer.points += 1;
// if game is over, show results
if (this.movesLeft == 0) {
nextTimeOut += 700;
setTimeout( function(){ finishGame(); proceed('start_' + _language, 'finish_' + _language); quitFullScreen(); }, nextTimeOut );
}
// otherwise, advance move to next player
else {
if (this.players.length > 1) {
this.playerMove += 1;
if (this.playerMove==3) {
this.playerMove = 0;
nextTimeOut += 700;
setTimeout( function(){_gameHistory.currentPlayer = _gameHistory.currentPlayer.nextPlayer; _gameHistory.currentPlayer.next(); }, nextTimeOut);
}
else
setTimeout( function(){_globalLock=false;}, nextTimeOut );
}
else
setTimeout( function(){_globalLock=false;}, nextTimeOut );
}
}
}
};
//______________________________
// helper function for creating cards
function addToArray(array, meaning, digits, dots, english, german, rows, cols)
{
array.push( new Card(meaning, "digits", digits, rows, cols) );
array.push( new Card(meaning, "dots", dots, rows, cols) );
if (_language == "en")
array.push( new Card(meaning, "english", english, rows, cols) );
if (_language == "de")
array.push( new Card(meaning, "german", german, rows, cols) );
}
//______________________________
// start a new game --
// create a new gameHistory, create new cards, shuffle them
// and put them face down on the table
function newGame(rows, cols)
{
// get players and create history
players = [];
for (var i=1; i<5; i++) {
name = document.getElementById("name" + i.toString() + "_" + _language).value.trim();
if( name != "") {
id = "player"+i.toString();
colour = document.getElementById("name" + i.toString() + "_" + _language).style.backgroundColor;
players.push(new Player(name, colour, id) );
}
}
if (players.length==0) {
if (_language == "de")
players = [ new Player("Gelöst in", document.getElementById("name1_de").style.backgroundColor, "player1") ];
if (_language == "en")
players = [ new Player("Solved in", document.getElementById("name1_en").style.backgroundColor, "player1") ];
}
_gameHistory = null;
_gameHistory = new GameHistory(players, rows*cols/3);
// create array with 5 false and 16 true values at random order
function Select(value) {
this.random = Math.random();
this.value = value;
}
selections = [];
for (var i=0; i<21-rows*cols/3; i++)
selections.push( new Select(false) );
for (var i=0; i<rows*cols/3; i++)
selections.push( new Select(true) );
selections.sort(function(a, b) { return a.random - b.random; });
// add rows*cols/3 of 21 available cards
var cards = [];
if (selections[0].value)
addToArray(cards, 0, "0", " ", "Zero", "Null", rows, cols);
if (selections[1].value)
addToArray(cards, 1, "1", "‧", "One", "Eins", rows, cols);
if (selections[2].value)
addToArray(cards, 2, "2", "‧‧", "Two", "Zwei", rows, cols);
if (selections[3].value)
addToArray(cards, 3, "3", "∴", "Three", "Drei", rows, cols);
if (selections[4].value)
addToArray(cards, 4, "4", "⁘", "Four", "Vier", rows, cols);
if (selections[5].value)
addToArray(cards, 5, "5", "⁙", "Five", "Fünf", rows, cols);
if (selections[6].value)
addToArray(cards, 6, "6", "<span style='color:#000;'>⁙</span> ‧", "Six", "Sechs", rows, cols);
if (selections[7].value)
addToArray(cards, 7, "7", "<span style='color:#000;'>⁙</span> ‧‧", "Seven", "Sieben", rows, cols);
if (selections[8].value)
addToArray(cards, 8, "8", "<span style='color:#000;'>⁙</span> ∴", "Eight", "Acht", rows, cols);
if (selections[9].value)
addToArray(cards, 9, "9", "<span style='color:#000;'>⁙</span> ⁘", "Nine", "Neun", rows, cols);
if (selections[10].value)
addToArray(cards, 10, "10", "<span style='color:#000;'>⁙</span> ⁙", "Ten", "Zehn", rows, cols);
if (selections[11].value)
addToArray(cards, 11, "11", "<span style='color:#888;'>⁙ ⁙</span><br/>‧", "Eleven", "Elf", rows, cols);
if (selections[12].value)
addToArray(cards, 12, "12", "<span style='color:#888;'>⁙ ⁙</span><br/>‧‧", "Twelve", "Zwölf", rows, cols);
if (selections[13].value)
addToArray(cards, 13, "13", "<span style='color:#888;'>⁙ ⁙</span><br/>∴", "Thirteen", "Dreizehn", rows, cols);
if (selections[14].value)
addToArray(cards, 14, "14", "<span style='color:#888;'>⁙ ⁙</span><br/>⁘", "Fourteen", "Vierzehn", rows, cols);
if (selections[15].value)
addToArray(cards, 15, "15", "<span style='color:#888;'>⁙ ⁙</span><br/>⁙", "Fifteen", "Fünfzehn", rows, cols);
if (selections[16].value)
addToArray(cards, 16, "16", "<span style='color:#888;'>⁙ ⁙</span><br/><span style='color:#000;'>⁙</span> ‧", "Sixteen", "Sechzehn", rows, cols);
if (selections[17].value)
addToArray(cards, 17, "17", "<span style='color:#888;'>⁙ ⁙</span><br/><span style='color:#000;'>⁙</span> ‧‧", "Seventeen", "Siebzehn", rows, cols);
if (selections[18].value)
addToArray(cards, 18, "18", "<span style='color:#888;'>⁙ ⁙</span><br/><span style='color:#000;'>⁙</span> ∴", "Eighteen", "Achzehn", rows, cols);
if (selections[19].value)
addToArray(cards, 19, "19", "<span style='color:#888;'>⁙ ⁙</span><br/><span style='color:#000;'>⁙</span> ⁘", "Nineteen", "Neunzehn", rows, cols);
if (selections[20].value)
addToArray(cards, 20, "20", "<span style='color:#888;'>⁙ ⁙</span><br/><span style='color:#000;'>⁙</span> ⁙", "Twenty", "Zwanzig", rows, cols);
// shuffle cards and assign tags
cards.sort( function(a, b) { return a.random - b.random; } );
for (var n=0; n<cards.length; n++)
cards[n].tag = "card_" + n.toString();
// put the cards on the table
var cardString = "";
for (var n=0; n<cards.length; n++)
cardString += cards[n].html;
document.getElementById("table").innerHTML = cardString;
// announce first player
_globalLock = false;
if (_gameHistory.players.length>1) {
_globalLock = true;
setTimeout( function(){_gameHistory.currentPlayer.next(); }, 1000 );
}
}
//______________________________
// start a new game --
// create a new gameHistory, create new cards, shuffle them
// and put them face down on the table
function finishGame(rows, cols)
{
resultsTable = "<table>"
for (var i=0; i<_gameHistory.players.length; i++) {
player = _gameHistory.players[i];
resultsTable += "<tr><td> " + player.name
+ " </td><td> " + player.points
+ " </td><td> " + player.pointString
+ " </td></tr>";
}
resultsTable += "</table>";
document.getElementById('results_' + _language).innerHTML = resultsTable;
nextTimeOut += 700;
}
//______________________________
// go to full screen
function goFullScreen()
{
if (_quitFullScreen) {
clearTimeout(_quitFullScreen);
_quitFullScreen = false;
} else {
if (document.documentElement.requestFullScreen) {
document.documentElement.requestFullScreen();
} else if (document.documentElement.mozRequestFullScreen) {
document.documentElement.mozRequestFullScreen();
} else if (document.documentElement.webkitRequestFullScreen) {
document.documentElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
} else if (document.documentElement.msRequestFullScreen) {
document.documentElement.msRequestFullScreen();
}
}
}
//______________________________
// stop full screen
function quitFullScreen()
{
if (document.cancelFullScreen) {
document.cancelFullScreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
} else if (document.msCancelFullScreen) {
document.msCancelFullScreen();
}
_quitFullScreen = false;
}
//______________________________
// start the session
function startSession(rows, cols, language) {
_language = language;
goFullScreen();
newGame(rows, cols);
}
//______________________________
// hides the first id and shows the second
function proceed(hide, show)
{
document.getElementById(hide).style.display = "none";
document.getElementById(show).style.display = "block";
}
//-->
</script>
</head>
<body>
<!-- Card table -->
<div id="table" class="table">
</div>
<!-- Language chose -->
<div id="language" class="message" style="display:block;">
<button onClick="proceed('language', 'intro_en');" style="clear:left;">English</button>
<button onClick="proceed('language', 'intro_de');" style="clear:left;">Deutsch</button>
</div>
<!-- English workflow -->
<div id="intro_en" class="message">
<b>Triple Number Memory</b> <br>
Remember and find matching triplets of cards showing the same number, like <span style="color: #f00000;"><b><i>3</i></b></span> and <span style="color: #f00000;"><b><i>∴</i></b></span> and <span style="color: #f00000;"><b><i>Three</i></b></span>. Players play in turns, each player uncovers three new cards by clicking on them. After three clicks it's the next player's turn.
<br/><br/>
<div>
<button onClick="proceed('intro_en', 'names_en');">Next</button> or <button onClick="proceed('intro_en', 'language');">Go Back</button>
</div>
</div>
<div id="names_en" class="message">
Enter up to four players
<br/>
<input id="name1_en" type="text" class="text" style="clear:left; background-color: #fff090"></input>
<input id="name2_en" type="text" class="text" style="clear:left; background-color: #b0fff0"></input>
<input id="name3_en" type="text" class="text" style="clear:left; background-color: #f0c0ff"></input>
<input id="name4_en" type="text" class="text" style="clear:left; background-color: #e0ffa0"></input>
<br/><br/>
<div>
<button onClick="proceed('names_en', 'start_en');">Next</button> or <button onClick="proceed('names_en', 'intro_en');">Go Back</button>
</div>
</div>
<div id="start_en" class="message">
Choose your game size and start
<br/>
<button onClick="startSession(7,9,'en'); proceed('start_en', 'table');" style="clear:left;">Huge</button>
<button onClick="startSession(6,8,'en'); proceed('start_en', 'table');" style="clear:left;">Big</button>
<button onClick="startSession(5,6,'en'); proceed('start_en', 'table');" style="clear:left;">Medium</button>
<button onClick="startSession(4,6,'en'); proceed('start_en', 'table');" style="clear:left;">Small</button>
<button onClick="startSession(3,5,'en'); proceed('start_en', 'table');" style="clear:left;">Tiny</button>
<br/><br/>
<div>
Or <button onClick="proceed('start_en', 'names_en');">Go Back</button>
</div>
</div>
<div id="finish_en" class="message">
Final Results
<br/><br/>
<span id="results_en"></span>
<br/><br/>
<button onClick="proceed('finish_en', 'names_en');" style="clear:left;">New Game</button>
<br/>
</div>
<!-- German workflow -->
<div id="intro_de" class="message">
<b>Dreifach-Zahlen-Memory</b> <br>
Finde alle Karten, die die gleiche Zahl zeigen. Immer drei Karten gehören zusammen, wie zum Beispield <span style="color: #f00000;"><b><i>3</i></b></span> und <span style="color: #f00000;"><b><i>∴</i></b></span> und <span style="color: #f00000;"><b><i>Drei</i></b></span>. Spieler spielen der Reihe nach, jeder Spieler deckt drei neue Karten auf, danach ist der nächste Spieler an der Reihe.
<br/><br/>
<div>
<button onClick="proceed('intro_de', 'names_de');">Weiter</button> oder <button onClick="proceed('intro_de', 'language');">Zurück</button>
</div>
</div>
<div id="names_de" class="message">
Tragt bis zu vier Spieler ein
<br/>
<input id="name1_de" type="text" class="text" style="clear:left; background-color: #fff090"></input>
<input id="name2_de" type="text" class="text" style="clear:left; background-color: #b0fff0"></input>
<input id="name3_de" type="text" class="text" style="clear:left; background-color: #f0c0ff"></input>
<input id="name4_de" type="text" class="text" style="clear:left; background-color: #e0ffa0"></input>
<br/><br/>
<div>
<button onClick="proceed('names_de', 'start_de');">Weiter</button> oder <button onClick="proceed('names_de', 'intro_de');">Zurück</button>
</div>
</div>
<div id="start_de" class="message">
Wählt eine Spielgröße
<br/>
<button onClick="startSession(7,9,'de'); proceed('start_de', 'table');" style="clear:left;">Riesig</button>
<button onClick="startSession(6,8,'de'); proceed('start_de', 'table');" style="clear:left;">Groß</button>
<button onClick="startSession(5,6,'de'); proceed('start_de', 'table');" style="clear:left;">Mittel</button>
<button onClick="startSession(4,6,'de'); proceed('start_de', 'table');" style="clear:left;">Klein</button>
<button onClick="startSession(3,5,'de'); proceed('start_de', 'table');" style="clear:left;">Winzig</button>
<br/><br/>
<div>
Oder <button onClick="proceed('start_de', 'names_de');">Zurück</button>
</div>
</div>
<div id="finish_de" class="message">
Ergebnis
<br/><br/>
<span id="results_de"></span>
<br/><br/>
<button onClick="proceed('finish_de', 'names_de');" style="clear:left;">Neues Spiel</button>
<br/>
</div>
<!-- Player message boxes -->
<div id="player1" class="player"></div>
<div id="player2" class="player"></div>
<div id="player3" class="player"></div>
<div id="player4" class="player"></div>
</body>
</html>