Skip to content

Commit

Permalink
fixed change and set inside pick n atRandom. fixes #326
Browse files Browse the repository at this point in the history
  • Loading branch information
Zomis committed Jul 23, 2015
1 parent 7aadef5 commit 11c832e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
Expand Up @@ -77,7 +77,7 @@ class EffectDelegate {

EffectDelegate[] deleg = new EffectDelegate[effects.length]
for (int i = 0; i < deleg.length; i++) {
deleg[i] = create(effects[i], true)
deleg[i] = create(effects[i], false)
assert deleg[i].closures.size() > 0 : 'probability condition needs to have some actions'
}
String effectString = Arrays.stream(deleg).map({ef -> ef.description.toString()})
Expand All @@ -96,7 +96,7 @@ class EffectDelegate {
}

def withProbability(double probability, @DelegatesTo(EffectDelegate) Closure action) {
EffectDelegate deleg = create(action, true)
EffectDelegate deleg = create(action, false)
assert deleg.closures.size() > 0 : 'probability condition needs to have some actions'
description.append("$probability % chance to $deleg.description")
closures.add({Entity source, Object data ->
Expand Down
12 changes: 12 additions & 0 deletions test-resources/mods/TestMod/cards.groovy
Expand Up @@ -26,3 +26,15 @@ card('Destroy Spell') {
set HEALTH to 0 on targets
}
}

card('Pick One Change') {
creature 'Bio'
health 2
onEndOfTurn {
pick 1 atRandom (
{ change HEALTH by 1 on { thisCard() } },
{ change ATTACK by 1 on { thisCard() } },
{ set SICKNESS to 2 on { thisCard() } }
)
}
}
11 changes: 11 additions & 0 deletions test-resources/mods/TestMod/test.groovy
Expand Up @@ -22,3 +22,14 @@ from clearState test 'spellcards' using {
assert spell.removed
}

from clearState test 'Pick One Change' using {
def card = to you zone 'Battlefield' create 'Pick One Change'

assert card.attack == 0
assert card.health == 2
uses 'End Turn' ok
assert card.attack == 1 || card.health == 3 || card.sickness == 2

uses 'End Turn' ok
}

0 comments on commit 11c832e

Please sign in to comment.