Skip to content

Commit

Permalink
add win condition
Browse files Browse the repository at this point in the history
  • Loading branch information
ditam committed Apr 26, 2021
1 parent 4ab5325 commit 2fe3a4d
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,30 @@ const decks = {
},
cards: [
// bottom-first so it can be dumped into DOM naively
{ type: 'gold' },
{ type: 'diamond' },
{ type: 'rock' },
{ type: 'rock' },
{ type: 'rock' },
{ type: 'platinum' },
{ type: 'silver' },
{ type: 'gold' },
{ type: 'soil' },
{ type: 'soil' },
{ type: 'gold' },
{ type: 'soil' },
{ type: 'gold' },
{ type: 'rock' },
{ type: 'rock' },
{ type: 'soil' },
{ type: 'soil' },
{ type: 'soil' },
{ type: 'platinum' },
{ type: 'soil' },
{ type: 'platinum' },
{ type: 'gold' },
{ type: 'rock' },
{ type: 'soil' },
{ type: 'soil' },
{ type: 'silver' },
{ type: 'gold' },
{ type: 'silver' },
Expand Down Expand Up @@ -399,7 +409,10 @@ function endPlayerTurn() {
layoutCurrentPlayerHand();
layoutWaitingPlayerHand();

if (currentPlayer === 2 && gameMode === 'ai') {
if (!deckHasCard(decks.shaft.cards, 'diamond')) {
const winner = decks.player1.money > decks.player2.money? 'Player 1' : decks.player2.name;
$('#lantern-viewer').addClass('visible').text('The winner is ' + winner + '!');
} else if (currentPlayer === 2 && gameMode === 'ai') {
takeAITurn();
}
}
Expand Down

0 comments on commit 2fe3a4d

Please sign in to comment.