-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGame.js
40 lines (31 loc) · 867 Bytes
/
Game.js
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
startGame = function(){
var deck = makeDeck();
/*for(var i = 0; i < 52; i++){
console.log(deck[i].getInfo());
}*/
deck = shuffle(deck);
var myCards = $('.myCard');
for(var i = 0; i < myCards.length; i++){
myCards[i].setAttribute('src', deck[i].getImgSrc());
myCards[i].setAttribute('onclick', 'selectCard(this)');
}
}
function selectCard(card){
card.setAttribute("style", "opacity: 0.4");
card.setAttribute("onclick", "deselectCard(this)");
}
function deselectCard(card){
card.setAttribute("style", "");
card.setAttribute("onclick", "selectCard(this)");
}
function rand(min, max) {
return Math.floor(Math.random()*(max-min)+min);
}
function exchangeCards(){
var myCards = $('.myCard');
for(var i = 0; i < myCards.length; i++){
if(myCards[i].style.cssText != ""){
alert(myCards[i].style.cssText);
}
}
}