1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-01 19:07:57 -09:00

- Added Dread Wight and Cloak of Confusion.

This commit is contained in:
Jeff 2018-12-13 17:43:11 -06:00
parent 09827e1e11
commit c2739c004b
3 changed files with 429 additions and 0 deletions
Mage.Sets/src/mage/cards
Mage/src/main/java/mage/counters

View file

@ -0,0 +1,191 @@
package mage.cards.c;
import java.util.UUID;
import mage.constants.SubType;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.AttachEffect;
import mage.constants.Outcome;
import mage.target.TargetPermanent;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.combat.CombatGroup;
import mage.game.events.DamageEvent;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.targetpointer.FixedTarget;
/**
*
* @author jeffwadsworth
*/
public final class CloakOfConfusion extends CardImpl {
public CloakOfConfusion(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{B}");
this.subtype.add(SubType.AURA);
// Enchant creature you control
TargetPermanent auraTarget = new TargetControlledCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
// Whenever enchanted creature attacks and isn't blocked, you may have it assign no combat damage this turn.
// If you do, defending player discards a card at random.
this.addAbility(new CloakOfConfusionTriggeredAbility());
}
public CloakOfConfusion(final CloakOfConfusion card) {
super(card);
}
@Override
public CloakOfConfusion copy() {
return new CloakOfConfusion(this);
}
}
class CloakOfConfusionTriggeredAbility extends TriggeredAbilityImpl {
public CloakOfConfusionTriggeredAbility() {
super(Zone.BATTLEFIELD, new CloakOfConfusionEffect(), true);
}
public CloakOfConfusionTriggeredAbility(final CloakOfConfusionTriggeredAbility ability) {
super(ability);
}
@Override
public CloakOfConfusionTriggeredAbility copy() {
return new CloakOfConfusionTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.DECLARE_BLOCKERS_STEP;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent aura = game.getPermanentOrLKIBattlefield(getSourceId());
if (aura != null) {
Permanent enchantedCreature = game.getPermanent(aura.getAttachedTo());
if (enchantedCreature != null
&& enchantedCreature.isAttacking()) {
for (CombatGroup combatGroup : game.getCombat().getGroups()) {
if (combatGroup.getBlockers().isEmpty()
&& combatGroup.getAttackers().contains(enchantedCreature.getId())) {
this.getEffects().setTargetPointer(
new FixedTarget(game.getCombat().getDefendingPlayerId(
enchantedCreature.getId(), game)));
return true;
}
}
}
}
return false;
}
@Override
public String getRule() {
return "Whenever enchanted creature attacks and isn't blocked, " + super.getRule();
}
}
class CloakOfConfusionEffect extends OneShotEffect {
public CloakOfConfusionEffect() {
super(Outcome.Neutral);
this.staticText = "you may have it assign no combat damage this turn. "
+ "If you do, defending player discards a card at random";
}
public CloakOfConfusionEffect(final CloakOfConfusionEffect effect) {
super(effect);
}
@Override
public CloakOfConfusionEffect copy() {
return new CloakOfConfusionEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent enchantedCreature = game.getPermanent(game.getPermanent(source.getSourceId()).getAttachedTo());
if (controller != null) {
if (controller.chooseUse(outcome, "Do you wish to not assign combat damage from "
+ enchantedCreature.getName() + " and have the defending player discard a card at random?", source, game)) {
ContinuousEffect effect = new AssignNoCombatDamageTargetEffect();
effect.setTargetPointer(new FixedTarget(enchantedCreature.getId()));
game.addEffect(effect, source);
Player defendingPlayer = game.getPlayer(targetPointer.getFirst(game, source));
if (defendingPlayer != null) {
defendingPlayer.discard(1, true, source, game);
}
}
return true;
}
return false;
}
}
class AssignNoCombatDamageTargetEffect extends ReplacementEffectImpl {
public AssignNoCombatDamageTargetEffect() {
super(Duration.EndOfTurn, Outcome.Neutral);
}
public AssignNoCombatDamageTargetEffect(final AssignNoCombatDamageTargetEffect effect) {
super(effect);
}
@Override
public AssignNoCombatDamageTargetEffect copy() {
return new AssignNoCombatDamageTargetEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
switch (event.getType()) {
case DAMAGE_CREATURE:
case DAMAGE_PLAYER:
case DAMAGE_PLANESWALKER:
return true;
default:
return false;
}
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
DamageEvent damageEvent = (DamageEvent) event;
return event.getSourceId().equals(targetPointer.getFirst(game, source))
&& damageEvent.isCombatDamage();
}
}

View file

@ -0,0 +1,237 @@
package mage.cards.d;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.decorator.ConditionalContinuousRuleModifyingEffect;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ContinuousRuleModifyingEffect;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.abilities.effects.common.counter.RemoveCounterSourceEffect;
import mage.constants.SubType;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
/**
*
* @author jeffwadsworth
*/
public final class DreadWight extends CardImpl {
public DreadWight(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}{B}");
this.subtype.add(SubType.ZOMBIE);
this.power = new MageInt(3);
this.toughness = new MageInt(4);
// At end of combat, put a paralyzation counter on each creature blocking or blocked by Dread Wight and tap those creatures. Each of those creatures doesn't untap during its controller's untap step for as long as it has a paralyzation counter on it. Each of those creatures gains "{4}: Remove a paralyzation counter from this creature."
this.addAbility(new DreadWightTriggeredAbility(
new CreateDelayedTriggeredAbilityEffect(
new AtTheEndOfCombatDelayedTriggeredAbility(
new DreadWightEffect()))));
}
public DreadWight(final DreadWight card) {
super(card);
}
@Override
public DreadWight copy() {
return new DreadWight(this);
}
}
class DreadWightTriggeredAbility extends TriggeredAbilityImpl {
DreadWightTriggeredAbility(Effect effect) {
super(Zone.BATTLEFIELD, effect);
this.usesStack = false;
}
DreadWightTriggeredAbility(final DreadWightTriggeredAbility ability) {
super(ability);
}
@Override
public DreadWightTriggeredAbility copy() {
return new DreadWightTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return (event.getType() == EventType.BLOCKER_DECLARED);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getSourceId().equals(getSourceId())) { // Dread Wight is the blocker
getAllEffects().setTargetPointer(new FixedTarget(event.getTargetId()));
return true;
}
if (event.getTargetId().equals(getSourceId())) { // Dread Wight is the attacker
getAllEffects().setTargetPointer(new FixedTarget(event.getSourceId()));
return true;
}
return false;
}
@Override
public String getRule() {
return super.getRule();
}
}
class DreadWightEffect extends OneShotEffect {
String rule = "doesn't untap during its controller's untap step for as long as it has a paralyzation counter on it.";
public DreadWightEffect() {
super(Outcome.Detriment);
this.staticText = "put a paralyzation counter on each creature blocking or blocked by {this} and tap those creatures. "
+ "Each of those creatures doesn't untap during its controller's untap step for as long as it has a paralyzation counter on it. "
+ "Each of those creatures gains \"{4}: Remove a paralyzation counter from this creature.\"";
}
public DreadWightEffect(final DreadWightEffect effect) {
super(effect);
}
@Override
public DreadWightEffect copy() {
return new DreadWightEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
if (permanent != null) {
// add paralyzation counter
Effect effect = new AddCountersTargetEffect(CounterType.PARALYZATION.createInstance());
effect.setTargetPointer(new FixedTarget(permanent.getId()));
effect.apply(game, source);
// tap permanent
permanent.tap(game);
// does not untap while paralyzation counter is on it
ContinuousRuleModifyingEffect effect2 = new DreadWightDoNotUntapEffect(
Duration.WhileOnBattlefield,
permanent.getId());
effect2.setText("This creature doesn't untap during its controller's untap step for as long as it has a paralyzation counter on it");
Condition condition = new DreadWightCounterCondition(permanent.getId());
ConditionalContinuousRuleModifyingEffect conditionalEffect = new ConditionalContinuousRuleModifyingEffect(
effect2,
condition);
Ability ability = new SimpleStaticAbility(
Zone.BATTLEFIELD,
conditionalEffect);
ContinuousEffect effect3 = new GainAbilityTargetEffect(
ability,
Duration.WhileOnBattlefield);
ability.setRuleVisible(true);
effect3.setTargetPointer(new FixedTarget(permanent.getId()));
game.addEffect(effect3, source);
// each gains 4: remove paralyzation counter
Ability activatedAbility = new SimpleActivatedAbility(
Zone.BATTLEFIELD,
new RemoveCounterSourceEffect(CounterType.PARALYZATION.createInstance()),
new ManaCostsImpl("{4}"));
ContinuousEffect effect4 = new GainAbilityTargetEffect(
activatedAbility,
Duration.WhileOnBattlefield);
effect4.setTargetPointer(new FixedTarget(permanent.getId()));
game.addEffect(effect4, source);
return true;
}
return false;
}
}
class DreadWightDoNotUntapEffect extends ContinuousRuleModifyingEffectImpl {
UUID permanentId;
public DreadWightDoNotUntapEffect(Duration duration, UUID permanentId) {
super(duration, Outcome.Detriment);
this.permanentId = permanentId;
}
public DreadWightDoNotUntapEffect(final DreadWightDoNotUntapEffect effect) {
super(effect);
this.permanentId = effect.permanentId;
}
@Override
public DreadWightDoNotUntapEffect copy() {
return new DreadWightDoNotUntapEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
Permanent permanentToUntap = game.getPermanent((event.getTargetId()));
if (permanentToUntap != null) {
return permanentToUntap.getLogName() + " doesn't untap.";
}
return null;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.UNTAP;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return event.getTargetId() == permanentId
&& game.isActivePlayer(game.getPermanent(permanentId).getControllerId());
}
}
class DreadWightCounterCondition implements Condition {
UUID permanentId;
public DreadWightCounterCondition(UUID permanentId) {
this.permanentId = permanentId;
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(permanentId);
if (permanent != null) {
return permanent.getCounters(game).getCount(CounterType.PARALYZATION) > 0;
}
return false;
}
@Override
public String toString() {
return "has counter on it";
}
}

View file

@ -91,6 +91,7 @@ public enum CounterType {
P2P2(new BoostCounter(2, 2).name),
PAGE("page"),
PAIN("pain"),
PARALYZATION("paralyzation"),
PETAL("petal"),
PETRIFICATION("petrification"),
PHYLACTERY("phylactery"),