From b8076aa1d3c05ee4fccf3be7dd1937da41a0a485 Mon Sep 17 00:00:00 2001 From: magenoxx Date: Sat, 20 Aug 2011 22:59:49 +0400 Subject: [PATCH] [M12][10E] Sengir Vampire --- .../mage/sets/magic2012/SengirVampire.java | 54 +++++++++++++ .../src/mage/sets/tenth/SengirVampire.java | 80 +++++++++++++++++++ ...ndDealtDamageThisTurnTriggeredAbility.java | 44 ++++++++++ Mage/src/mage/game/permanent/Permanent.java | 6 ++ .../mage/game/permanent/PermanentImpl.java | 22 +++++ 5 files changed, 206 insertions(+) create mode 100644 Mage.Sets/src/mage/sets/magic2012/SengirVampire.java create mode 100644 Mage.Sets/src/mage/sets/tenth/SengirVampire.java create mode 100644 Mage/src/mage/abilities/common/DiesAndDealtDamageThisTurnTriggeredAbility.java diff --git a/Mage.Sets/src/mage/sets/magic2012/SengirVampire.java b/Mage.Sets/src/mage/sets/magic2012/SengirVampire.java new file mode 100644 index 00000000000..c228350237b --- /dev/null +++ b/Mage.Sets/src/mage/sets/magic2012/SengirVampire.java @@ -0,0 +1,54 @@ +/* + * 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.magic2012; + +import java.util.UUID; +import mage.Constants.Rarity; + +/** + * + * @author nantuko + */ +public class SengirVampire extends mage.sets.tenth.SengirVampire { + + public SengirVampire(UUID ownerId) { + super(ownerId); + this.cardNumber = 107; + this.expansionSetCode = "M12"; + this.rarity = Rarity.UNCOMMON; + } + + public SengirVampire(final SengirVampire card) { + super(card); + } + + @Override + public SengirVampire copy() { + return new SengirVampire(this); + } +} diff --git a/Mage.Sets/src/mage/sets/tenth/SengirVampire.java b/Mage.Sets/src/mage/sets/tenth/SengirVampire.java new file mode 100644 index 00000000000..ececa24146c --- /dev/null +++ b/Mage.Sets/src/mage/sets/tenth/SengirVampire.java @@ -0,0 +1,80 @@ +/* + * 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.tenth; + +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.MageInt; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.DiesAndDealtDamageThisTurnTriggeredAbility; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.CardImpl; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeEvent; +import mage.game.permanent.Permanent; + +import java.util.UUID; + +/** + * @author nantuko + */ +public class SengirVampire extends CardImpl { + + public SengirVampire(UUID ownerId) { + super(ownerId, 176, "Sengir Vampire", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{3}{B}{B}"); + this.expansionSetCode = "10E"; + this.subtype.add("Vampire"); + + this.color.setBlack(true); + this.power = new MageInt(4); + this.toughness = new MageInt(4); + + this.addAbility(FlyingAbility.getInstance()); + + // Whenever a creature dealt damage by Sengir Vampire this turn dies, put a +1/+1 counter on Sengir Vampire. + this.addAbility(new DiesAndDealtDamageThisTurnTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance()))); + } + + public SengirVampire(final SengirVampire card) { + super(card); + } + + @Override + public SengirVampire copy() { + return new SengirVampire(this); + } +} + + + + diff --git a/Mage/src/mage/abilities/common/DiesAndDealtDamageThisTurnTriggeredAbility.java b/Mage/src/mage/abilities/common/DiesAndDealtDamageThisTurnTriggeredAbility.java new file mode 100644 index 00000000000..8d519196e27 --- /dev/null +++ b/Mage/src/mage/abilities/common/DiesAndDealtDamageThisTurnTriggeredAbility.java @@ -0,0 +1,44 @@ +package mage.abilities.common; + +import mage.Constants; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.Effect; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeEvent; +import mage.game.permanent.Permanent; + +public class DiesAndDealtDamageThisTurnTriggeredAbility extends TriggeredAbilityImpl { + + public DiesAndDealtDamageThisTurnTriggeredAbility(Effect effect) { + super(Constants.Zone.BATTLEFIELD, effect); + } + + public DiesAndDealtDamageThisTurnTriggeredAbility(final DiesAndDealtDamageThisTurnTriggeredAbility ability) { + super(ability); + } + + @Override + public DiesAndDealtDamageThisTurnTriggeredAbility copy() { + return new DiesAndDealtDamageThisTurnTriggeredAbility(this); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.ZONE_CHANGE) { + ZoneChangeEvent zEvent = (ZoneChangeEvent) event; + if (zEvent.getFromZone() == Constants.Zone.BATTLEFIELD && zEvent.getToZone() == Constants.Zone.GRAVEYARD) { + Permanent p = (Permanent) game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD); + if (p.getDealtDamageByThisTurn().contains(this.sourceId)) { + return true; + } + } + } + return false; + } + + @Override + public String getRule() { + return "Whenever a creature dealt damage by {this} this turn dies, " + super.getRule(); + } +} \ No newline at end of file diff --git a/Mage/src/mage/game/permanent/Permanent.java b/Mage/src/mage/game/permanent/Permanent.java index d984297a853..e106e42c949 100644 --- a/Mage/src/mage/game/permanent/Permanent.java +++ b/Mage/src/mage/game/permanent/Permanent.java @@ -112,6 +112,12 @@ public interface Permanent extends Card { public boolean removeFromCombat(Game game); public boolean isDeathtouched(); + /** + * Returns the list of sources that dealt damage this turn to this permanent + * @return + */ + public List getDealtDamageByThisTurn(); + /** * Imprint some other card to this one. * diff --git a/Mage/src/mage/game/permanent/PermanentImpl.java b/Mage/src/mage/game/permanent/PermanentImpl.java index 0a16d0a2df0..9a16fddb265 100644 --- a/Mage/src/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/mage/game/permanent/PermanentImpl.java @@ -45,6 +45,7 @@ import mage.game.events.GameEvent.EventType; import mage.players.Player; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.UUID; @@ -73,8 +74,11 @@ public abstract class PermanentImpl> extends CardImpl protected List attachments = new ArrayList(); protected List imprinted = new ArrayList(); protected List connectedCards = new ArrayList(); + protected List dealtDamageByThisTurn; protected UUID attachedTo; + private static final List emptyList = Collections.unmodifiableList(new ArrayList()); + public PermanentImpl(UUID ownerId, UUID controllerId, String name) { super(ownerId, name); this.originalControllerId = controllerId; @@ -115,6 +119,12 @@ public abstract class PermanentImpl> extends CardImpl for (UUID connectedCardId : permanent.connectedCards) { this.connectedCards.add(connectedCardId); } + if (permanent.dealtDamageByThisTurn != null) { + dealtDamageByThisTurn = new ArrayList(); + for (UUID sourceId : permanent.dealtDamageByThisTurn) { + this.dealtDamageByThisTurn.add(sourceId); + } + } this.attachedTo = permanent.attachedTo; } @@ -197,6 +207,7 @@ public abstract class PermanentImpl> extends CardImpl this.loyaltyUsed = false; this.turnsOnBattlefield++; this.deathtouched = false; + dealtDamageByThisTurn = null; for (Ability ability : this.abilities) { ability.reset(game); } @@ -501,6 +512,10 @@ public abstract class PermanentImpl> extends CardImpl if (source != null && source.getAbilities().containsKey(DeathtouchAbility.getInstance().getId())) { deathtouched = true; } + if (dealtDamageByThisTurn == null) { + dealtDamageByThisTurn = new ArrayList(); + } + dealtDamageByThisTurn.add(sourceId); } } return damageDone; @@ -709,4 +724,11 @@ public abstract class PermanentImpl> extends CardImpl return this.imprinted; } + @Override + public List getDealtDamageByThisTurn() { + if (dealtDamageByThisTurn == null) { + return emptyList; + } + return dealtDamageByThisTurn; + } }