Skip to content

Instantly share code, notes, and snippets.

@thisiszoaib
Created November 14, 2020 14:20
Show Gist options
  • Select an option

  • Save thisiszoaib/8d71a814abf2dbd37a42b77c0c98eccc to your computer and use it in GitHub Desktop.

Select an option

Save thisiszoaib/8d71a814abf2dbd37a42b77c0c98eccc to your computer and use it in GitHub Desktop.
Card Game 7
checkForCardMatch(): void {
setTimeout(() => {
const cardOne = this.flippedCards[0];
const cardTwo = this.flippedCards[1];
const nextState = cardOne.imageId === cardTwo.imageId ? 'matched' : 'default';
cardOne.state = cardTwo.state = nextState;
this.flippedCards = [];
if (nextState === 'matched') {
this.matchedCount++;
if (this.matchedCount === this.cardImages.length) {
const dialogRef = this.dialog.open(RestartDialogComponent, {
disableClose: true
});
dialogRef.afterClosed().subscribe(() => {
this.restart();
});
}
}
}, 1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment