mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
[MID] Implemented Curse of Surveillance
This commit is contained in:
parent
bd93a4841b
commit
8b9c77e129
3 changed files with 121 additions and 1 deletions
108
Mage.Sets/src/mage/cards/c/CurseOfSurveillance.java
Normal file
108
Mage.Sets/src/mage/cards/c/CurseOfSurveillance.java
Normal file
|
@ -0,0 +1,108 @@
|
|||
package mage.cards.c;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.abilities.common.BeginningOfUpkeepAttachedTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.DrawCardTargetEffect;
|
||||
import mage.constants.SubType;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.abilities.keyword.EnchantAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.filter.FilterPlayer;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.other.PlayerIdPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.TargetPlayer;
|
||||
import mage.target.targetadjustment.TargetAdjuster;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author weirddan455
|
||||
*/
|
||||
public final class CurseOfSurveillance extends CardImpl {
|
||||
|
||||
public CurseOfSurveillance(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{4}{U}");
|
||||
|
||||
this.subtype.add(SubType.AURA);
|
||||
this.subtype.add(SubType.CURSE);
|
||||
|
||||
// Enchant player
|
||||
TargetPlayer auraTarget = new TargetPlayer();
|
||||
this.getSpellAbility().addTarget(auraTarget);
|
||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment));
|
||||
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
||||
this.addAbility(ability);
|
||||
|
||||
// At the beginning of enchanted player's upkeep, any number of target players other than that player each draw cards equal to the number of Curses attached to that player.
|
||||
ability = new BeginningOfUpkeepAttachedTriggeredAbility(
|
||||
new DrawCardTargetEffect(CurseOfSurveillanceValue.instance).setText(
|
||||
"any number of target players other than that player each draw cards equal to the number of Curses attached to that player"
|
||||
),
|
||||
false, false
|
||||
);
|
||||
ability.setTargetAdjuster(CurseOfSurveillanceTargetAdjuster.instance);
|
||||
ability.addTarget(new TargetPlayer(0, Integer.MAX_VALUE, false));
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
private CurseOfSurveillance(final CurseOfSurveillance card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CurseOfSurveillance copy() {
|
||||
return new CurseOfSurveillance(this);
|
||||
}
|
||||
}
|
||||
|
||||
enum CurseOfSurveillanceValue implements DynamicValue {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
UUID enchantedPlayerId = (UUID) effect.getValue("enchantedPlayer");
|
||||
int curses = 0;
|
||||
if (enchantedPlayerId != null) {
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents()) {
|
||||
if (permanent != null && permanent.hasSubtype(SubType.CURSE, game) && permanent.isAttachedTo(enchantedPlayerId)) {
|
||||
curses++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return curses;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CurseOfSurveillanceValue copy() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "number of Curses attached to that player";
|
||||
}
|
||||
}
|
||||
|
||||
enum CurseOfSurveillanceTargetAdjuster implements TargetAdjuster {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public void adjustTargets(Ability ability, Game game) {
|
||||
Permanent enchantment = game.getPermanentOrLKIBattlefield(ability.getSourceId());
|
||||
if (enchantment != null) {
|
||||
FilterPlayer filter = new FilterPlayer();
|
||||
filter.add(Predicates.not(new PlayerIdPredicate(enchantment.getAttachedTo())));
|
||||
TargetPlayer target = new TargetPlayer(0, Integer.MAX_VALUE, false, filter);
|
||||
ability.getTargets().clear();
|
||||
ability.addTarget(target);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -50,6 +50,7 @@ public final class InnistradMidnightHunt extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Croaking Counterpart", 215, Rarity.RARE, mage.cards.c.CroakingCounterpart.class));
|
||||
cards.add(new SetCardInfo("Curse of Shaken Faith", 134, Rarity.RARE, mage.cards.c.CurseOfShakenFaith.class));
|
||||
cards.add(new SetCardInfo("Curse of Silence", 326, Rarity.RARE, mage.cards.c.CurseOfSilence.class));
|
||||
cards.add(new SetCardInfo("Curse of Surveillance", 46, Rarity.RARE, mage.cards.c.CurseOfSurveillance.class));
|
||||
cards.add(new SetCardInfo("Dawnhart Rejuvenator", 180, Rarity.COMMON, mage.cards.d.DawnhartRejuvenator.class));
|
||||
cards.add(new SetCardInfo("Dawnhart Wardens", 308, Rarity.UNCOMMON, mage.cards.d.DawnhartWardens.class));
|
||||
cards.add(new SetCardInfo("Defend the Celestus", 182, Rarity.UNCOMMON, mage.cards.d.DefendTheCelestus.class));
|
||||
|
|
|
@ -13,16 +13,24 @@ import mage.target.targetpointer.FixedTarget;
|
|||
*/
|
||||
public class BeginningOfUpkeepAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private final boolean setTargetPointer;
|
||||
|
||||
public BeginningOfUpkeepAttachedTriggeredAbility(Effect effect) {
|
||||
this(effect, false);
|
||||
}
|
||||
|
||||
public BeginningOfUpkeepAttachedTriggeredAbility(Effect effect, boolean optional) {
|
||||
this(effect, optional, true);
|
||||
}
|
||||
|
||||
public BeginningOfUpkeepAttachedTriggeredAbility(Effect effect, boolean optional, boolean setTargetPointer) {
|
||||
super(Zone.BATTLEFIELD, effect, optional);
|
||||
this.setTargetPointer = setTargetPointer;
|
||||
}
|
||||
|
||||
private BeginningOfUpkeepAttachedTriggeredAbility(final BeginningOfUpkeepAttachedTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.setTargetPointer = ability.setTargetPointer;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,7 +49,10 @@ public class BeginningOfUpkeepAttachedTriggeredAbility extends TriggeredAbilityI
|
|||
if (enchantment == null || !game.isActivePlayer(enchantment.getAttachedTo())) {
|
||||
return false;
|
||||
}
|
||||
this.getEffects().setTargetPointer(new FixedTarget(enchantment.getAttachedTo()));
|
||||
if (setTargetPointer) {
|
||||
this.getEffects().setTargetPointer(new FixedTarget(enchantment.getAttachedTo()));
|
||||
}
|
||||
this.getEffects().setValue("enchantedPlayer", enchantment.getAttachedTo());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue