mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
- Fixed Barter in Blood. Improved test for it.
This commit is contained in:
parent
d1f3e62d03
commit
2e5be475b0
2 changed files with 17 additions and 57 deletions
|
@ -28,25 +28,23 @@
|
||||||
package mage.sets.avacynrestored;
|
package mage.sets.avacynrestored;
|
||||||
|
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Outcome;
|
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
import mage.abilities.Ability;
|
|
||||||
import mage.abilities.effects.OneShotEffect;
|
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.permanent.Permanent;
|
|
||||||
import mage.players.Player;
|
|
||||||
import mage.target.Target;
|
|
||||||
import mage.target.common.TargetControlledPermanent;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import mage.abilities.effects.common.SacrificeAllEffect;
|
||||||
|
import mage.filter.common.FilterControlledPermanent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author North
|
* @author North
|
||||||
*/
|
*/
|
||||||
public class BarterInBlood extends CardImpl<BarterInBlood> {
|
public class BarterInBlood extends CardImpl<BarterInBlood> {
|
||||||
|
|
||||||
|
private static final FilterControlledPermanent filter = new FilterControlledPermanent("creature");
|
||||||
|
|
||||||
|
static {
|
||||||
|
filter.getCardType().add(CardType.CREATURE);
|
||||||
|
}
|
||||||
|
|
||||||
public BarterInBlood(UUID ownerId) {
|
public BarterInBlood(UUID ownerId) {
|
||||||
super(ownerId, 85, "Barter in Blood", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{2}{B}{B}");
|
super(ownerId, 85, "Barter in Blood", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{2}{B}{B}");
|
||||||
|
@ -55,7 +53,7 @@ public class BarterInBlood extends CardImpl<BarterInBlood> {
|
||||||
this.color.setBlack(true);
|
this.color.setBlack(true);
|
||||||
|
|
||||||
// Each player sacrifices two creatures.
|
// Each player sacrifices two creatures.
|
||||||
this.getSpellAbility().addEffect(new BarterInBloodEffect());
|
this.getSpellAbility().addEffect(new SacrificeAllEffect(2, filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
public BarterInBlood(final BarterInBlood card) {
|
public BarterInBlood(final BarterInBlood card) {
|
||||||
|
@ -66,48 +64,4 @@ public class BarterInBlood extends CardImpl<BarterInBlood> {
|
||||||
public BarterInBlood copy() {
|
public BarterInBlood copy() {
|
||||||
return new BarterInBlood(this);
|
return new BarterInBlood(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class BarterInBloodEffect extends OneShotEffect<BarterInBloodEffect> {
|
|
||||||
|
|
||||||
public BarterInBloodEffect() {
|
|
||||||
super(Outcome.Sacrifice);
|
|
||||||
this.staticText = "Each player sacrifices two creatures";
|
|
||||||
}
|
|
||||||
|
|
||||||
public BarterInBloodEffect(final BarterInBloodEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BarterInBloodEffect copy() {
|
|
||||||
return new BarterInBloodEffect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source) {
|
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
|
||||||
if (controller != null) {
|
|
||||||
FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
|
||||||
for (UUID playerId : controller.getInRange()) {
|
|
||||||
Player player = game.getPlayer(playerId);
|
|
||||||
if (player != null) {
|
|
||||||
int amount = Math.min(2, game.getBattlefield().countAll(filter, player.getId(), game));
|
|
||||||
Target target = new TargetControlledPermanent(amount, amount, filter, false);
|
|
||||||
target.setRequired(true);
|
|
||||||
if (amount > 0 && target.canChoose(player.getId(), game)
|
|
||||||
&& player.choose(Outcome.Sacrifice, target, source.getSourceId(), game)) {
|
|
||||||
for (UUID targetId : target.getTargets()) {
|
|
||||||
Permanent permanent = game.getPermanent(targetId);
|
|
||||||
if (permanent != null) {
|
|
||||||
permanent.sacrifice(source.getSourceId(), game);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -16,7 +16,12 @@ public class BarterInBloodTest extends CardTestPlayerBase {
|
||||||
public void testSacrifice() {
|
public void testSacrifice() {
|
||||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Swamp", 4);
|
addCard(Constants.Zone.BATTLEFIELD, playerA, "Swamp", 4);
|
||||||
addCard(Constants.Zone.HAND, playerA, "Barter in Blood");
|
addCard(Constants.Zone.HAND, playerA, "Barter in Blood");
|
||||||
|
|
||||||
|
addCard(Constants.Zone.BATTLEFIELD, playerA, "Memnite");
|
||||||
|
addCard(Constants.Zone.BATTLEFIELD, playerA, "Royal Assassin");
|
||||||
|
addCard(Constants.Zone.BATTLEFIELD, playerA, "Sengir Vampire");
|
||||||
|
|
||||||
|
addCard(Constants.Zone.BATTLEFIELD, playerB, "Island");
|
||||||
addCard(Constants.Zone.BATTLEFIELD, playerB, "Flowering Lumberknot");
|
addCard(Constants.Zone.BATTLEFIELD, playerB, "Flowering Lumberknot");
|
||||||
addCard(Constants.Zone.BATTLEFIELD, playerB, "Moorland Inquisitor");
|
addCard(Constants.Zone.BATTLEFIELD, playerB, "Moorland Inquisitor");
|
||||||
|
|
||||||
|
@ -25,6 +30,7 @@ public class BarterInBloodTest extends CardTestPlayerBase {
|
||||||
setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT);
|
setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT);
|
||||||
execute();
|
execute();
|
||||||
|
|
||||||
assertPermanentCount(playerB, 0);
|
assertPermanentCount(playerA, 5);
|
||||||
|
assertPermanentCount(playerB, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue