Fixed issue #136 of Wight of Precint Six. Added test for Wight of Precint Six.

This commit is contained in:
LevelX2 2013-02-14 12:59:15 +01:00
parent 1121c7c562
commit 8d3796ef7a
3 changed files with 74 additions and 28 deletions

View file

@ -31,7 +31,6 @@ import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.Constants.TargetController;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
@ -41,10 +40,8 @@ import mage.abilities.effects.common.continious.BoostSourceEffect;
import mage.cards.CardImpl;
import mage.filter.FilterCard;
import mage.filter.common.FilterCreatureCard;
import mage.filter.predicate.other.OwnerPredicate;
import mage.game.Game;
import mage.players.Player;
import mage.players.PlayerList;
/**
*
@ -53,9 +50,6 @@ import mage.players.PlayerList;
public class WightOfPrecinctSix extends CardImpl<WightOfPrecinctSix> {
private static final FilterCard filter = new FilterCreatureCard("creature card in your opponents' graveyards");
static {
filter.add(new OwnerPredicate(TargetController.OPPONENT));
}
public WightOfPrecinctSix(UUID ownerId) {
super(ownerId, 84, "Wight of Precinct Six", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{1}{B}");
@ -67,7 +61,7 @@ public class WightOfPrecinctSix extends CardImpl<WightOfPrecinctSix> {
this.toughness = new MageInt(1);
// Wight of Precinct Six gets +1/+1 for each creature card in your opponents' graveyards.
DynamicValue boost = new CardsInAllGraveyardsCount(filter);
DynamicValue boost = new CardsInOpponentGraveyardsCount(filter);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostSourceEffect(boost, boost, Constants.Duration.WhileOnBattlefield)));
}
@ -81,30 +75,29 @@ public class WightOfPrecinctSix extends CardImpl<WightOfPrecinctSix> {
}
}
class CardsInAllGraveyardsCount implements DynamicValue {
class CardsInOpponentGraveyardsCount implements DynamicValue {
private FilterCard filter;
public CardsInAllGraveyardsCount() {
public CardsInOpponentGraveyardsCount() {
this(new FilterCard());
}
public CardsInAllGraveyardsCount(FilterCard filter) {
public CardsInOpponentGraveyardsCount(FilterCard filter) {
this.filter = filter;
}
private CardsInAllGraveyardsCount(CardsInAllGraveyardsCount dynamicValue) {
private CardsInOpponentGraveyardsCount(CardsInOpponentGraveyardsCount dynamicValue) {
this.filter = dynamicValue.filter;
}
@Override
public int calculate(Game game, Ability sourceAbility) {
int amount = 0;
PlayerList playerList = game.getPlayerList();
for (UUID playerUUID : playerList) {
for (UUID playerUUID : game.getOpponents(sourceAbility.getControllerId())) {
Player player = game.getPlayer(playerUUID);
if (player != null) {
amount += player.getGraveyard().count(filter, game);
amount += player.getGraveyard().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game);
}
}
return amount;
@ -112,7 +105,7 @@ class CardsInAllGraveyardsCount implements DynamicValue {
@Override
public DynamicValue copy() {
return new CardsInAllGraveyardsCount(this);
return new CardsInOpponentGraveyardsCount(this);
}
@Override

View file

@ -0,0 +1,53 @@
package org.mage.test.cards.continuous;
import mage.Constants;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* Wight of Precinct
* Wight of Precinct Six gets +1/+1 for each creature card in your opponents' graveyards.
*
* @author LevelX2
*/
public class WightOfPrecintSixTest extends CardTestPlayerBase {
/**
* Tests no creature cards in opponents graveyard -> no boost
*/
@Test
public void testNoCreatureCardsInOpponentsGraveyard() {
addCard(Constants.Zone.GRAVEYARD, playerA, "Angelic Edict");
addCard(Constants.Zone.GRAVEYARD, playerA, "Runeclaw Bear");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Wight of Precinct Six");
addCard(Constants.Zone.GRAVEYARD, playerB, "Angelic Edict");
setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT);
execute();
assertPowerToughness(playerA, "Wight of Precinct Six", 1, 1);
}
/**
* Tests two creature cards in opponents graveyard -> boost +2/+2
*/
@Test
public void testCreatureCardsInOpponentsGraveyard() {
addCard(Constants.Zone.GRAVEYARD, playerA, "Angelic Edict");
addCard(Constants.Zone.GRAVEYARD, playerA, "Runeclaw Bear");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Wight of Precinct Six");
addCard(Constants.Zone.GRAVEYARD, playerB, "Angelic Edict");
addCard(Constants.Zone.GRAVEYARD, playerB, "Runeclaw Bear");
addCard(Constants.Zone.GRAVEYARD, playerB, "Wight of Precinct Six");
setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT);
execute();
assertPowerToughness(playerA, "Wight of Precinct Six", 3, 3);
}
}

View file

@ -39,7 +39,7 @@ public class CardsInAllGraveyardsCount implements DynamicValue {
for (UUID playerUUID : playerList) {
Player player = game.getPlayer(playerUUID);
if (player != null) {
amount += player.getGraveyard().count(filter, game);
amount += player.getGraveyard().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game);
}
}
return amount;