[AVR] Harvester Of Souls + test.

This commit is contained in:
magenoxx 2012-05-09 10:04:11 +04:00
parent 419acfeabb
commit 55bf5714a0
5 changed files with 290 additions and 0 deletions

View file

@ -0,0 +1,68 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.avacynrestored;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.MageInt;
import mage.abilities.common.DiesAnotherCreatureTriggeredAbility;
import mage.abilities.effects.common.DrawCardControllerEffect;
import mage.abilities.keyword.DeathtouchAbility;
import mage.cards.CardImpl;
import java.util.UUID;
/**
* @author noxx
*/
public class HarvesterOfSouls extends CardImpl<HarvesterOfSouls> {
public HarvesterOfSouls(UUID ownerId) {
super(ownerId, 107, "Harvester of Souls", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{4}{B}{B}");
this.expansionSetCode = "AVR";
this.subtype.add("Demon");
this.color.setBlack(true);
this.power = new MageInt(5);
this.toughness = new MageInt(5);
this.addAbility(DeathtouchAbility.getInstance());
// Whenever another nontoken creature dies, you may draw a card.
this.addAbility(new DiesAnotherCreatureTriggeredAbility(new DrawCardControllerEffect(1), true, true));
}
public HarvesterOfSouls(final HarvesterOfSouls card) {
super(card);
}
@Override
public HarvesterOfSouls copy() {
return new HarvesterOfSouls(this);
}
}

View file

@ -0,0 +1,43 @@
package org.mage.test.cards.triggers.dies;
import mage.Constants;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author noxx
*
* Whenever another nontoken creature dies, you may draw a card.
*/
public class HarvesterOfSoulsTest extends CardTestPlayerBase {
/**
* Tests creature on any side would trigger effect
* Also tests that tokens don't cause trigger to happen
*/
@Test
public void testDisabledEffectOnChangeZone() {
addCard(Constants.Zone.BATTLEFIELD, playerA, "Plains", 4);
addCard(Constants.Zone.BATTLEFIELD, playerA, "Mountain", 3);
addCard(Constants.Zone.HAND, playerA, "Day of Judgment", 1);
addCard(Constants.Zone.HAND, playerA, "Thatcher Revolt", 1);
addCard(Constants.Zone.BATTLEFIELD, playerA, "Harvester of Souls", 1);
addCard(Constants.Zone.BATTLEFIELD, playerA, "Craw Wurm", 1);
addCard(Constants.Zone.BATTLEFIELD, playerB, "Arrogant Bloodlord", 1);
castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Thatcher Revolt");
castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Day of Judgment");
setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 20);
assertLife(playerB, 20);
assertHandCount(playerA, 2);
assertHandCount(playerB, 0);
}
}

View file

@ -0,0 +1,89 @@
package mage.abilities.common;
import mage.Constants;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentToken;
import java.util.UUID;
/**
* noxx
*/
public class DiesAnotherCreatureTriggeredAbility extends TriggeredAbilityImpl<DiesAnotherCreatureTriggeredAbility> {
protected FilterCreaturePermanent filter;
protected boolean nontoken;
public DiesAnotherCreatureTriggeredAbility(Effect effect, boolean optional) {
this(effect, optional, new FilterCreaturePermanent());
}
public DiesAnotherCreatureTriggeredAbility(Effect effect, boolean optional, boolean nontoken) {
this(effect, optional, new FilterCreaturePermanent(), nontoken);
}
public DiesAnotherCreatureTriggeredAbility(Effect effect, boolean optional, FilterCreaturePermanent filter) {
this(effect, optional, filter, false);
}
public DiesAnotherCreatureTriggeredAbility(Effect effect, boolean optional, FilterCreaturePermanent filter, boolean nontoken) {
super(Constants.Zone.BATTLEFIELD, effect, optional);
this.filter = filter;
this.nontoken = nontoken;
}
public DiesAnotherCreatureTriggeredAbility(DiesAnotherCreatureTriggeredAbility ability) {
super(ability);
this.filter = ability.filter;
this.nontoken = ability.nontoken;
}
@Override
public DiesAnotherCreatureTriggeredAbility copy() {
return new DiesAnotherCreatureTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
UUID sourceId = getSourceId();
if (game.getPermanent(sourceId) == null) {
if (game.getLastKnownInformation(sourceId, Constants.Zone.BATTLEFIELD) == null) {
return false;
}
}
if (zEvent.getFromZone() == Constants.Zone.BATTLEFIELD && zEvent.getToZone() == Constants.Zone.GRAVEYARD) {
Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD);
if (permanent != null) {
if (permanent.getId().equals(this.getSourceId())) {
return false;
}
if (nontoken && permanent instanceof PermanentToken) {
return false;
}
if (filter.match(permanent)) {
return true;
}
}
}
}
return false;
}
@Override
public String getRule() {
if (nontoken) {
return "Whenever another nontoken creature dies, " + super.getRule();
}
return "Whenever another creature dies, " + super.getRule();
}
}

View file

@ -1,3 +1,30 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.common;
import mage.Constants;
@ -8,24 +35,40 @@ import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentToken;
import java.util.UUID;
/**
* @author noxx
*/
public class DiesAnotherCreatureYouControlTriggeredAbility extends TriggeredAbilityImpl<DiesAnotherCreatureYouControlTriggeredAbility> {
protected FilterCreaturePermanent filter;
protected boolean nontoken;
public DiesAnotherCreatureYouControlTriggeredAbility(Effect effect, boolean optional) {
this(effect, optional, new FilterCreaturePermanent());
}
public DiesAnotherCreatureYouControlTriggeredAbility(Effect effect, boolean optional, boolean nontoken) {
this(effect, optional, new FilterCreaturePermanent(), nontoken);
}
public DiesAnotherCreatureYouControlTriggeredAbility(Effect effect, boolean optional, FilterCreaturePermanent filter) {
this(effect, optional, filter, false);
}
public DiesAnotherCreatureYouControlTriggeredAbility(Effect effect, boolean optional, FilterCreaturePermanent filter, boolean nontoken) {
super(Constants.Zone.BATTLEFIELD, effect, optional);
this.filter = filter;
this.nontoken = nontoken;
}
public DiesAnotherCreatureYouControlTriggeredAbility(DiesAnotherCreatureYouControlTriggeredAbility ability) {
super(ability);
this.filter = ability.filter;
this.nontoken = ability.nontoken;
}
@Override
@ -47,6 +90,10 @@ public class DiesAnotherCreatureYouControlTriggeredAbility extends TriggeredAbil
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
Permanent permanent = zEvent.getTarget();
if (nontoken && permanent instanceof PermanentToken) {
return false;
}
if (permanent != null && permanent.getCardType().contains(Constants.CardType.CREATURE) &&
zEvent.isDiesEvent() &&
permanent.getControllerId().equals(this.getControllerId()) && filter != null &&
@ -59,6 +106,9 @@ public class DiesAnotherCreatureYouControlTriggeredAbility extends TriggeredAbil
@Override
public String getRule() {
if (nontoken) {
return "Whenever another nontoken creature you control dies, " + super.getRule();
}
return "Whenever another creature you control dies, " + super.getRule();
}
}

View file

@ -1,3 +1,30 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.common;
import mage.Constants;
@ -9,6 +36,11 @@ import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
import java.util.UUID;
/**
* @author noxx
*/
public class DiesThisOrAnotherCreatureTriggeredAbility extends TriggeredAbilityImpl<DiesThisOrAnotherCreatureTriggeredAbility> {
protected FilterCreaturePermanent filter;
@ -36,6 +68,14 @@ public class DiesThisOrAnotherCreatureTriggeredAbility extends TriggeredAbilityI
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
UUID sourceId = getSourceId();
if (game.getPermanent(sourceId) == null) {
if (game.getLastKnownInformation(sourceId, Constants.Zone.BATTLEFIELD) == null) {
return false;
}
}
if (zEvent.getFromZone() == Constants.Zone.BATTLEFIELD && zEvent.getToZone() == Constants.Zone.GRAVEYARD) {
Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD);
if (permanent != null) {