Skip to content

Commit

Permalink
Avoid window.alert when playing cards without energy
Browse files Browse the repository at this point in the history
  • Loading branch information
oskarrough committed Mar 31, 2020
1 parent 1dbf7fb commit c37ac09
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 1 addition & 7 deletions public/ui/app.js
Expand Up @@ -88,7 +88,7 @@ export default class App extends Component {
// We want to be able to drag cards in the hand.
new Sortable(this.base.querySelector('.Hand .Cards'), {
group: 'hand',
draggable: '.Card',
draggable: '.Card:not([disabled])',
revertOnSpill: true,
onSpill() {
targets.forEach(t => t.classList.remove(overClass))
Expand All @@ -97,12 +97,6 @@ export default class App extends Component {
// Do as little as possible here. It gets called a lot.
targets.forEach(t => t.classList.remove(overClass))
event.to.classList.add(overClass)
// Check if we have enough energy.
const card = self.state.hand.find(c => c.id === event.dragged.dataset.id)
if (card.energy > self.state.player.currentEnergy) {
alert('Not enough energy to play this card.')
return false
}
}
})
// And we want to be able to drop on all the targets (player + monsters)
Expand Down
8 changes: 8 additions & 0 deletions public/ui/index.css
Expand Up @@ -358,6 +358,14 @@ summary {
cursor: url(images/grab-open.png) 10 0, auto;
}

.Hand .Card:not([disabled]) {
/* opacity: 0.5; */
}

.Hand .Card[disabled] {
cursor: not-allowed;
}

/* input, */
/* textarea, */
/* select { */
Expand Down

0 comments on commit c37ac09

Please sign in to comment.