mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
Fixed issue #136 of Wight of Precint Six. Added test for Wight of Precint Six.
This commit is contained in:
parent
1121c7c562
commit
8d3796ef7a
3 changed files with 74 additions and 28 deletions
|
@ -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,8 +61,8 @@ 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);
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostSourceEffect(boost,boost, Constants.Duration.WhileOnBattlefield)));
|
||||
DynamicValue boost = new CardsInOpponentGraveyardsCount(filter);
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostSourceEffect(boost, boost, Constants.Duration.WhileOnBattlefield)));
|
||||
}
|
||||
|
||||
public WightOfPrecinctSix(final WightOfPrecinctSix card) {
|
||||
|
@ -81,47 +75,46 @@ public class WightOfPrecinctSix extends CardImpl<WightOfPrecinctSix> {
|
|||
}
|
||||
}
|
||||
|
||||
class CardsInAllGraveyardsCount implements DynamicValue {
|
||||
class CardsInOpponentGraveyardsCount implements DynamicValue {
|
||||
|
||||
private FilterCard filter;
|
||||
|
||||
public CardsInAllGraveyardsCount() {
|
||||
this(new FilterCard());
|
||||
public CardsInOpponentGraveyardsCount() {
|
||||
this(new FilterCard());
|
||||
}
|
||||
|
||||
public CardsInAllGraveyardsCount(FilterCard filter) {
|
||||
this.filter = filter;
|
||||
public CardsInOpponentGraveyardsCount(FilterCard filter) {
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
private CardsInAllGraveyardsCount(CardsInAllGraveyardsCount dynamicValue) {
|
||||
this.filter = dynamicValue.filter;
|
||||
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) {
|
||||
Player player = game.getPlayer(playerUUID);
|
||||
if (player != null) {
|
||||
amount += player.getGraveyard().count(filter, game);
|
||||
}
|
||||
}
|
||||
return amount;
|
||||
int amount = 0;
|
||||
for (UUID playerUUID : game.getOpponents(sourceAbility.getControllerId())) {
|
||||
Player player = game.getPlayer(playerUUID);
|
||||
if (player != null) {
|
||||
amount += player.getGraveyard().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game);
|
||||
}
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamicValue copy() {
|
||||
return new CardsInAllGraveyardsCount(this);
|
||||
return new CardsInOpponentGraveyardsCount(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "1";
|
||||
return "1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return filter.getMessage();
|
||||
return filter.getMessage();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue