tests for reported bug Rabid Elephant. typo fixes

This commit is contained in:
drmDev 2016-03-17 08:21:36 -04:00
parent ae66db20ad
commit eb9747d0d1
4 changed files with 54 additions and 8 deletions

View file

@ -55,7 +55,7 @@ public class RabidElephant extends CardImpl {
this.toughness = new MageInt(4); this.toughness = new MageInt(4);
// Whenever Rabid Elephant becomes blocked, it gets +2/+2 until end of turn for each creature blocking it. // Whenever Rabid Elephant becomes blocked, it gets +2/+2 until end of turn for each creature blocking it.
DynamicValue value = new MultipliedValue(new BlockedCreatureCount(),2); DynamicValue value = new MultipliedValue(new BlockedCreatureCount(), 2);
Effect effect = new BoostSourceEffect(value, value, Duration.EndOfTurn); Effect effect = new BoostSourceEffect(value, value, Duration.EndOfTurn);
effect.setText("it gets +2/+2 until end of turn for each creature blocking it"); effect.setText("it gets +2/+2 until end of turn for each creature blocking it");
this.addAbility(new BecomesBlockedTriggeredAbility(effect, false)); this.addAbility(new BecomesBlockedTriggeredAbility(effect, false));

View file

@ -0,0 +1,45 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.mage.test.cards.triggers;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author escplan9 (Derek Monturo - dmontur1 at gmail dot com)
*/
public class BecomesBlockedTest extends CardTestPlayerBase {
/**
* Reported bug:
* There's something wrong with how Rabid Elephant is getting his +2/+2 bonus,
* it doesn't last until end of turn, but seems to be removed right after the blockers step.
*/
@Test
public void testRabidElephant() {
// {4}{G}
// Whenever Rabid Elephant becomes blocked, it gets +2/+2 until end of turn for each creature blocking it.
addCard(Zone.BATTLEFIELD, playerA, "Rabid Elephant", 1); // 3/4
addCard(Zone.BATTLEFIELD, playerB, "Savannah Lions", 1); // 2/1
addCard(Zone.BATTLEFIELD, playerB, "Hill Giant", 1); // 3/3
attack(1, playerA, "Rabid Elephant");
block(1, playerB, "Savannah Lions", "Rabid Elephant");
//block(1, playerB, "Hill Giant", "Rabid Elephant");
// test passes if PhaseStep ends at DECLARE_BLOCKERS
//setStopAt(1, PhaseStep.DECLARE_BLOCKERS);
setStopAt(1, PhaseStep.COMBAT_DAMAGE);
execute();
// blocked by 2 creatures, so gets +2/+2 twice, making it 7/8
assertPowerToughness(playerA, "Rabid Elephant", 3, 4);
}
}

View file

@ -38,21 +38,21 @@ import mage.game.Game;
public class MultipliedValue implements DynamicValue { public class MultipliedValue implements DynamicValue {
private final DynamicValue value; private final DynamicValue value;
private final int multplier; private final int multiplier;
public MultipliedValue(DynamicValue value, int multiplier) { public MultipliedValue(DynamicValue value, int multiplier) {
this.value = value.copy(); this.value = value.copy();
this.multplier = multiplier; this.multiplier = multiplier;
} }
MultipliedValue(final MultipliedValue dynamicValue) { MultipliedValue(final MultipliedValue dynamicValue) {
this.value = dynamicValue.value.copy(); this.value = dynamicValue.value.copy();
this.multplier = dynamicValue.multplier; this.multiplier = dynamicValue.multiplier;
} }
@Override @Override
public int calculate(Game game, Ability sourceAbility, Effect effect) { public int calculate(Game game, Ability sourceAbility, Effect effect) {
return multplier * value.calculate(game, sourceAbility, effect); return multiplier * value.calculate(game, sourceAbility, effect);
} }
@Override @Override
@ -63,10 +63,10 @@ public class MultipliedValue implements DynamicValue {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (multplier == 2) { if (multiplier == 2) {
sb.append("twice "); sb.append("twice ");
} else { } else {
sb.append(multplier).append(" * "); sb.append(multiplier).append(" * ");
} }
return sb.append(value.toString()).toString(); return sb.append(value.toString()).toString();
} }

View file

@ -50,8 +50,9 @@ public class BlockedCreatureCount implements DynamicValue {
this(message, false); this(message, false);
} }
public BlockedCreatureCount(String message, boolean beyondTheFist) { public BlockedCreatureCount(String message, boolean beyondTheFirst) {
this.message = message; this.message = message;
this.beyondTheFirst = beyondTheFirst;
} }
public BlockedCreatureCount(final BlockedCreatureCount dynamicValue) { public BlockedCreatureCount(final BlockedCreatureCount dynamicValue) {