mirror of
https://github.com/correl/mage.git
synced 2025-04-01 19:07:57 -09:00
Implement [JUD] Infectious Rage (#10187)
* Implement [JUD] Infectious Rage * Fix ClassCastException by using last known info * Add game log message for random choice. Still need to investigate filter. * Clarify filter and add comments * Address review comments (3/4) * Check zone change counter
This commit is contained in:
parent
d3ec7e44a3
commit
1ac9ec65cc
4 changed files with 149 additions and 23 deletions
Mage.Sets/src/mage
Mage/src/main/java/mage/filter/predicate/permanent
|
@ -12,17 +12,16 @@ import mage.constants.CardType;
|
|||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.predicate.ObjectSourcePlayer;
|
||||
import mage.filter.predicate.ObjectSourcePlayerPredicate;
|
||||
import mage.filter.predicate.mageobject.AnotherPredicate;
|
||||
import mage.filter.predicate.permanent.PermanentCanBeAttachedToPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.util.TargetAddress;
|
||||
|
||||
/**
|
||||
* @author duncant
|
||||
|
@ -66,27 +65,6 @@ class AttachedToPermanentPredicate implements ObjectSourcePlayerPredicate<Perman
|
|||
}
|
||||
}
|
||||
|
||||
class PermanentCanBeAttachedToPredicate implements ObjectSourcePlayerPredicate<Permanent> {
|
||||
|
||||
protected Permanent aura;
|
||||
|
||||
public PermanentCanBeAttachedToPredicate(Permanent aura) {
|
||||
super();
|
||||
this.aura = aura;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(ObjectSourcePlayer<Permanent> input, Game game) {
|
||||
Permanent potentialAttachment = input.getObject();
|
||||
for (TargetAddress addr : TargetAddress.walk(aura)) {
|
||||
Target target = addr.getTarget(aura);
|
||||
Filter filter = target.getFilter();
|
||||
return filter.match(potentialAttachment, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class MoveTargetAuraEffect extends OneShotEffect {
|
||||
|
||||
public MoveTargetAuraEffect() {
|
||||
|
|
112
Mage.Sets/src/mage/cards/i/InfectiousRage.java
Normal file
112
Mage.Sets/src/mage/cards/i/InfectiousRage.java
Normal file
|
@ -0,0 +1,112 @@
|
|||
package mage.cards.i;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DiesAttachedTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.effects.common.continuous.BoostEnchantedEffect;
|
||||
import mage.abilities.keyword.EnchantAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.predicate.permanent.PermanentCanBeAttachedToPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.util.RandomUtil;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author xenohedron
|
||||
*/
|
||||
|
||||
public final class InfectiousRage extends CardImpl {
|
||||
|
||||
public InfectiousRage(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{R}");
|
||||
this.subtype.add(SubType.AURA);
|
||||
|
||||
// Enchant creature
|
||||
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
||||
this.getSpellAbility().addTarget(auraTarget);
|
||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
|
||||
Ability ability = new EnchantAbility(auraTarget);
|
||||
this.addAbility(ability);
|
||||
|
||||
// Enchanted creature gets +2/-1.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(2, -1)));
|
||||
|
||||
// When enchanted creature dies, choose a creature at random Infectious Rage can enchant.
|
||||
// Return Infectious Rage to the battlefield attached to that creature.
|
||||
this.addAbility(new DiesAttachedTriggeredAbility(new InfectiousRageReattachEffect(), "enchanted creature"));
|
||||
|
||||
}
|
||||
|
||||
private InfectiousRage(final InfectiousRage card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InfectiousRage copy() {
|
||||
return new InfectiousRage(this);
|
||||
}
|
||||
}
|
||||
|
||||
class InfectiousRageReattachEffect extends OneShotEffect {
|
||||
|
||||
public InfectiousRageReattachEffect() {
|
||||
super(Outcome.PutCardInPlay);
|
||||
this.staticText = "choose a creature at random {this} can enchant. Return {this} to the battlefield attached to that creature.";
|
||||
}
|
||||
|
||||
public InfectiousRageReattachEffect(final InfectiousRageReattachEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InfectiousRageReattachEffect copy() {
|
||||
return new InfectiousRageReattachEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Card auraCard = game.getCard(source.getSourceId());
|
||||
Permanent auraPermanent = source.getSourcePermanentOrLKI(game);
|
||||
if (controller == null || auraCard == null || auraPermanent == null) {
|
||||
return false;
|
||||
}
|
||||
if (source.getSourceObjectZoneChangeCounter() != auraCard.getZoneChangeCounter(game)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FilterPermanent filter = new FilterPermanent();
|
||||
filter.add(CardType.CREATURE.getPredicate());
|
||||
filter.add(new PermanentCanBeAttachedToPredicate(auraPermanent)); // Doesn't yet exclude creatures with protection abilities
|
||||
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game);
|
||||
|
||||
if (!permanents.isEmpty()) {
|
||||
Permanent creature = RandomUtil.randomFromCollection(permanents);
|
||||
if (creature != null) {
|
||||
game.getState().setValue("attachTo:" + auraCard.getId(), creature);
|
||||
controller.moveCards(auraCard, Zone.BATTLEFIELD, source, game);
|
||||
return creature.addAttachment(auraCard.getId(), source, game);
|
||||
}
|
||||
}
|
||||
else {
|
||||
game.informPlayers("No valid creatures for " + auraPermanent.getLogName() + "to enchant.");
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -93,6 +93,7 @@ public final class Judgment extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Hapless Researcher", 42, Rarity.COMMON, mage.cards.h.HaplessResearcher.class));
|
||||
cards.add(new SetCardInfo("Harvester Druid", 120, Rarity.COMMON, mage.cards.h.HarvesterDruid.class));
|
||||
cards.add(new SetCardInfo("Hunting Grounds", 138, Rarity.RARE, mage.cards.h.HuntingGrounds.class));
|
||||
cards.add(new SetCardInfo("Infectious Rage", 92, Rarity.UNCOMMON, mage.cards.i.InfectiousRage.class));
|
||||
cards.add(new SetCardInfo("Ironshell Beetle", 121, Rarity.COMMON, mage.cards.i.IronshellBeetle.class));
|
||||
cards.add(new SetCardInfo("Jeska, Warrior Adept", 93, Rarity.RARE, mage.cards.j.JeskaWarriorAdept.class));
|
||||
cards.add(new SetCardInfo("Keep Watch", 43, Rarity.COMMON, mage.cards.k.KeepWatch.class));
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package mage.filter.predicate.permanent;
|
||||
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.predicate.ObjectSourcePlayer;
|
||||
import mage.filter.predicate.ObjectSourcePlayerPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.Target;
|
||||
import mage.util.TargetAddress;
|
||||
|
||||
/**
|
||||
* @author duncant
|
||||
*/
|
||||
|
||||
public class PermanentCanBeAttachedToPredicate implements ObjectSourcePlayerPredicate<Permanent> {
|
||||
|
||||
protected Permanent aura;
|
||||
|
||||
public PermanentCanBeAttachedToPredicate(Permanent aura) {
|
||||
super();
|
||||
this.aura = aura;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(ObjectSourcePlayer<Permanent> input, Game game) {
|
||||
// TODO: Is it possible to add functionality to exclude objects the aura can't enchant (e.g. protection from)?
|
||||
Permanent potentialAttachment = input.getObject();
|
||||
for (TargetAddress addr : TargetAddress.walk(aura)) {
|
||||
Target target = addr.getTarget(aura);
|
||||
Filter filter = target.getFilter();
|
||||
return filter.match(potentialAttachment, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue