Fix: do not select edge if opened same cards
This commit is contained in:
@@ -327,46 +327,53 @@ var Game = {
|
||||
|
||||
var index = this.getCardIndex(col, row);
|
||||
|
||||
if(this.isCardSelectEdgeActivated() == false) { // card select edge is not activated
|
||||
if(this.isCardSelectEdgeActivated() == false // card select edge is not activated
|
||||
|| this.isSelectedBefore(col, row) == false) { // not selected card
|
||||
|
||||
if(this.cards[index].isActivated == false)
|
||||
return;
|
||||
|
||||
this.showSelectedCard(col, row);
|
||||
} else { // card select edge is activated
|
||||
if(this.isSelectedBefore(col, row) == true) {
|
||||
this.setSelectedCard(col, row);
|
||||
return;
|
||||
}
|
||||
|
||||
this.hideSelectedCard();
|
||||
|
||||
if(this.isFrontCard(col, row)) {
|
||||
// opened card -> flip to back
|
||||
if(this.isFrontCard(col, row) == true) {
|
||||
this.flipToBack(col, row);
|
||||
|
||||
if(this.isOpenedCard(col, row) == true) {
|
||||
if(this.isOpenedCard(col, row) == true)
|
||||
this.resetOpenCardInfo(col, row);
|
||||
|
||||
this.setSelectedCard(col, row);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
||||
// closed card -> flip to front
|
||||
this.flipToFront(col, row);
|
||||
|
||||
if(this.isOpenedCard(col, row) == false) {
|
||||
this.setOpenCardInfo(col, row);
|
||||
|
||||
if(this.isCardSelectEdgeAll() == true) {
|
||||
if(this.isSameCharacterCard() == true) {
|
||||
if(this.isCardSelectEdgeAll() == true) { // selected 2 cards
|
||||
if(this.isSameCharacterCard() == true) // selected same cards
|
||||
this.clearOpenedTwoCards();
|
||||
} else {
|
||||
else // selected different cards
|
||||
this.resetOpenedTwoCards();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.showSelectedCard(col, row);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// showOpenCardInfo();
|
||||
// this.showOpenCardInfo();
|
||||
this.setSelectedCard(col, row);
|
||||
},
|
||||
|
||||
setSelectedCard: function(col, row) {
|
||||
this.selectedCardCol = col;
|
||||
this.selectedCardRow = row;
|
||||
},
|
||||
|
||||
|
||||
isSelectedBefore: function(col, row) {
|
||||
if(this.selectedCardCol == col && this.selectedCardRow == row)
|
||||
return true;
|
||||
@@ -417,7 +424,7 @@ var Game = {
|
||||
|
||||
showOpenCardInfo: function() {
|
||||
console.log(
|
||||
"card 1 (" + this.openCardInfoIndex[0] + ", : " + this.openCardInfoCharacter[0] + "), card 2 ("
|
||||
"card 1 (" + this.openCardInfoIndex[0] + ", " + this.openCardInfoCharacter[0] + "), card 2 ("
|
||||
+ this.openCardInfoIndex[1] + ", " + this.openCardInfoCharacter[1] + ")");
|
||||
},
|
||||
|
||||
@@ -450,10 +457,12 @@ var Game = {
|
||||
var card1 = this.cards[this.openCardInfoIndex[0]];
|
||||
this.resetOpenCardInfo(card1.getColumnNo(), card1.getRowNo());
|
||||
this.reservedHideCard[0] = card1;
|
||||
card1.setActive(false);
|
||||
|
||||
var card2 = this.cards[this.openCardInfoIndex[1]];
|
||||
this.resetOpenCardInfo(card2.getColumnNo(), card2.getRowNo());
|
||||
this.reservedHideCard[1] = card2;
|
||||
card2.setActive(false);
|
||||
|
||||
// to do : show card 2 (flip to front) and wait 1 sec
|
||||
// to do : hide card 1, card 2
|
||||
|
||||
Reference in New Issue
Block a user