[M12][10E] Sengir Vampire

This commit is contained in:
magenoxx 2011-08-20 22:59:49 +04:00
parent 5231aa2dd3
commit b8076aa1d3
5 changed files with 206 additions and 0 deletions

View file

@ -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<DiesAndDealtDamageThisTurnTriggeredAbility> {
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();
}
}

View file

@ -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<UUID> getDealtDamageByThisTurn();
/**
* Imprint some other card to this one.
*

View file

@ -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<T extends PermanentImpl<T>> extends CardImpl
protected List<UUID> attachments = new ArrayList<UUID>();
protected List<UUID> imprinted = new ArrayList<UUID>();
protected List<UUID> connectedCards = new ArrayList<UUID>();
protected List<UUID> dealtDamageByThisTurn;
protected UUID attachedTo;
private static final List<UUID> emptyList = Collections.unmodifiableList(new ArrayList<UUID>());
public PermanentImpl(UUID ownerId, UUID controllerId, String name) {
super(ownerId, name);
this.originalControllerId = controllerId;
@ -115,6 +119,12 @@ public abstract class PermanentImpl<T extends PermanentImpl<T>> extends CardImpl
for (UUID connectedCardId : permanent.connectedCards) {
this.connectedCards.add(connectedCardId);
}
if (permanent.dealtDamageByThisTurn != null) {
dealtDamageByThisTurn = new ArrayList<UUID>();
for (UUID sourceId : permanent.dealtDamageByThisTurn) {
this.dealtDamageByThisTurn.add(sourceId);
}
}
this.attachedTo = permanent.attachedTo;
}
@ -197,6 +207,7 @@ public abstract class PermanentImpl<T extends PermanentImpl<T>> 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<T extends PermanentImpl<T>> extends CardImpl
if (source != null && source.getAbilities().containsKey(DeathtouchAbility.getInstance().getId())) {
deathtouched = true;
}
if (dealtDamageByThisTurn == null) {
dealtDamageByThisTurn = new ArrayList<UUID>();
}
dealtDamageByThisTurn.add(sourceId);
}
}
return damageDone;
@ -709,4 +724,11 @@ public abstract class PermanentImpl<T extends PermanentImpl<T>> extends CardImpl
return this.imprinted;
}
@Override
public List<UUID> getDealtDamageByThisTurn() {
if (dealtDamageByThisTurn == null) {
return emptyList;
}
return dealtDamageByThisTurn;
}
}