Skip to content

Commit

Permalink
Remove default export from conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
oskarrough committed Dec 18, 2020
1 parent 0205827 commit ce08ca2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
4 changes: 2 additions & 2 deletions public/game/actions.js
Expand Up @@ -320,12 +320,12 @@ function dealDamageEqualToBlock(state, {target}) {
}

export default {
dealDamageEqualToBlock,
addCardToHand,
addHealth,
addStarterDeck,
applyCardPowers,
createNewGame,
dealDamageEqualToBlock,
discardCard,
discardHand,
drawCards,
Expand All @@ -334,7 +334,7 @@ export default {
playCard,
removeHealth,
reshuffleAndDraw,
rewardPlayer,
setDungeon,
takeMonsterTurn,
rewardPlayer,
}
2 changes: 1 addition & 1 deletion public/game/cards.js
@@ -1,6 +1,6 @@
import {uuid} from './utils.js'
import actionMethods from './actions.js'
import conditionMethods from './conditions.js'
import * as conditionMethods from './conditions.js'
import cards from '../content/cards.js'

/*
Expand Down
23 changes: 9 additions & 14 deletions public/game/conditions.js
@@ -1,26 +1,21 @@
// Returns true if all cards in your hand are of the same type.
function onlyType(state, condition) {
export function onlyType(state, condition) {
return state.hand.some((card) => {
return card.type !== condition.cardType
})
}

function healthPercentage(state) {
return (state.player.currentHealth / state.player.maxHealth) * 100
}

// Returns true if hp is below condition.percentage
function healthPercentageBelow(state, condition) {
const player = state.player
const percentage = (player.currentHealth / player.maxHealth) * 100
return percentage < condition.percentage
export function healthPercentageBelow(state, condition) {
return healthPercentage(state) < condition.percentage
}

// Returns true if hp is above condition.percentage
function healthPercentageAbove(state, condition) {
const player = state.player
const percentage = (player.currentHealth / player.maxHealth) * 100
return percentage > condition.percentage
export function healthPercentageAbove(state, condition) {
return healthPercentage(state) > condition.percentage
}

export default {
onlyType,
healthPercentageBelow,
healthPercentageAbove,
}

0 comments on commit ce08ca2

Please sign in to comment.