refactoring

This commit is contained in:
North 2012-04-01 18:26:36 +03:00
parent 6e259cff81
commit 440ffe9f06
2 changed files with 12 additions and 10 deletions

View file

@ -39,12 +39,12 @@ import mage.abilities.effects.common.AttachEffect;
import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.game.Game; import mage.game.Game;
import mage.game.events.DamagedCreatureEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.FixedTarget;
/** /**
* *
@ -97,12 +97,11 @@ class SpitefulShadowsTriggeredAbility extends TriggeredAbilityImpl<SpitefulShado
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.DAMAGED_CREATURE) { if (event.getType() == GameEvent.EventType.DAMAGED_CREATURE) {
Permanent enchantment = game.getPermanent(sourceId); Permanent enchantment = game.getPermanent(sourceId);
if (enchantment != null && enchantment.getAttachedTo() != null) { UUID targetId = event.getTargetId();
if (event.getTargetId().equals(enchantment.getAttachedTo())) { if (enchantment != null && enchantment.getAttachedTo() != null && targetId.equals(enchantment.getAttachedTo())) {
this.getEffects().get(0).setValue("damageAmount", event.getAmount()); this.getEffects().get(0).setValue("damageAmount", event.getAmount());
this.getEffects().get(0).setValue("targetId", event.getTargetId()); this.getEffects().get(0).setTargetPointer(new FixedTarget(targetId));
return true; return true;
}
} }
} }
return false; return false;
@ -133,11 +132,12 @@ class SpitefulShadowsEffect extends OneShotEffect<SpitefulShadowsEffect> {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Integer damageAmount = (Integer) this.getValue("damageAmount"); Integer damageAmount = (Integer) this.getValue("damageAmount");
UUID targetId = (UUID) this.getValue("targetId"); UUID targetId = this.targetPointer.getFirst(source);
if (damageAmount != null && targetId != null) { if (damageAmount != null && targetId != null) {
Permanent permanent = game.getPermanent(targetId); Permanent permanent = game.getPermanent(targetId);
if (permanent == null) if (permanent == null) {
permanent = (Permanent) game.getLastKnownInformation(targetId, Zone.BATTLEFIELD); permanent = (Permanent) game.getLastKnownInformation(targetId, Zone.BATTLEFIELD);
}
if (permanent != null) { if (permanent != null) {
Player player = game.getPlayer(permanent.getControllerId()); Player player = game.getPlayer(permanent.getControllerId());
if (player != null) { if (player != null) {

View file

@ -53,6 +53,8 @@ import mage.target.common.TargetCardInLibrary;
*/ */
public class SadisticSacrament extends CardImpl<SadisticSacrament> { public class SadisticSacrament extends CardImpl<SadisticSacrament> {
private static final String ruleText = "Search target player's library for up to three cards, exile them, then that player shuffles his or her library. If {this} was kicked, instead search that player's library for up to fifteen cards, exile them, then that player shuffles his or her library";
public SadisticSacrament(UUID ownerId) { public SadisticSacrament(UUID ownerId) {
super(ownerId, 110, "Sadistic Sacrament", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{B}{B}{B}"); super(ownerId, 110, "Sadistic Sacrament", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{B}{B}{B}");
this.expansionSetCode = "ZEN"; this.expansionSetCode = "ZEN";
@ -67,7 +69,7 @@ public class SadisticSacrament extends CardImpl<SadisticSacrament> {
new SadisticSacramentEffect(15), new SadisticSacramentEffect(15),
new SadisticSacramentEffect(3), new SadisticSacramentEffect(3),
KickedCondition.getInstance(), KickedCondition.getInstance(),
"Search target player's library for up to three cards, exile them, then that player shuffles his or her library. If Sadistic Sacrament was kicked, instead search that player's library for up to fifteen cards, exile them, then that player shuffles his or her library")); ruleText));
this.getSpellAbility().addTarget(new TargetPlayer()); this.getSpellAbility().addTarget(new TargetPlayer());
} }