Fixed Righteous Authority (it wrongly gained ability to enchanted instead of being ability of the enchantment).

This commit is contained in:
LevelX2 2012-12-20 21:09:33 +01:00
parent dcb904308c
commit ee51cd59e0
2 changed files with 66 additions and 13 deletions

View file

@ -39,13 +39,19 @@ import mage.Constants.Zone;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.BeginningOfDrawTriggeredAbility; import mage.abilities.common.BeginningOfDrawTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.CardsInControllerHandCount; import mage.abilities.dynamicvalue.common.CardsInControllerHandCount;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.DrawCardControllerEffect; import mage.abilities.effects.common.DrawCardControllerEffect;
import mage.abilities.effects.common.DrawCardTargetEffect;
import mage.abilities.effects.common.continious.BoostEnchantedEffect;
import mage.abilities.effects.common.continious.BoostSourceEffect; import mage.abilities.effects.common.continious.BoostSourceEffect;
import mage.abilities.effects.common.continious.GainAbilityAttachedEffect; import mage.abilities.effects.common.continious.GainAbilityAttachedEffect;
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.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
@ -55,9 +61,6 @@ import mage.target.common.TargetCreaturePermanent;
*/ */
public class RighteousAuthority extends CardImpl<RighteousAuthority> { public class RighteousAuthority extends CardImpl<RighteousAuthority> {
static final String rule = "Enchanted creature gets +1/+1 for each card in its controller's hand";
static final String rule2 = "At the beginning of the draw step of enchanted creature's controller, that player draws an additional card";
public RighteousAuthority (UUID ownerId) { public RighteousAuthority (UUID ownerId) {
super(ownerId, 189, "Righteous Authority", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{W}{U}"); super(ownerId, 189, "Righteous Authority", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{W}{U}");
this.expansionSetCode = "RTR"; this.expansionSetCode = "RTR";
@ -73,13 +76,11 @@ public class RighteousAuthority extends CardImpl<RighteousAuthority> {
this.addAbility(ability); this.addAbility(ability);
// Enchanted creature gets +1/+1 for each card in its controller's hand. // Enchanted creature gets +1/+1 for each card in its controller's hand.
CardsInControllerHandCount boost = new CardsInControllerHandCount(); CardsInEnchantedControllerHandCount boost = new CardsInEnchantedControllerHandCount();
Ability gainedAbility = new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostSourceEffect(boost, boost, Duration.WhileOnBattlefield)); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(boost, boost, Duration.WhileOnBattlefield)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(gainedAbility, AttachmentType.AURA, Duration.WhileOnBattlefield, rule)));
// At the beginning of the draw step of enchanted creature's controller, that player draws an additional card. // At the beginning of the draw step of enchanted creature's controller, that player draws an additional card.
Ability gainedAbility2 = new BeginningOfDrawTriggeredAbility(new DrawCardControllerEffect(1), TargetController.YOU, false); this.addAbility(new BeginningOfDrawTriggeredAbility(new DrawCardTargetEffect(1), TargetController.CONTROLLER_ATTACHED_TO, false));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(gainedAbility2, AttachmentType.AURA, Duration.WhileOnBattlefield, rule2)));
} }
public RighteousAuthority (final RighteousAuthority card) { public RighteousAuthority (final RighteousAuthority card) {
@ -91,3 +92,38 @@ public class RighteousAuthority extends CardImpl<RighteousAuthority> {
return new RighteousAuthority(this); return new RighteousAuthority(this);
} }
} }
class CardsInEnchantedControllerHandCount implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility) {
if (sourceAbility != null) {
Permanent attachment = game.getPermanent(sourceAbility.getSourceId());
if (attachment != null && attachment.getAttachedTo() != null) {
Permanent attachedTo = game.getPermanent(attachment.getAttachedTo());
if (attachedTo != null) {
Player controller = game.getPlayer(attachedTo.getControllerId());
if (controller != null) {
return controller.getHand().size();
}
}
}
}
return 0;
}
@Override
public DynamicValue clone() {
return new mage.abilities.dynamicvalue.common.CardsInControllerHandCount();
}
@Override
public String getMessage() {
return "card in its controller's hand";
}
@Override
public String toString() {
return "1";
}
}

View file

@ -1,20 +1,22 @@
package mage.abilities.common; package mage.abilities.common;
import mage.Constants; import mage.Constants.TargetController;
import mage.Constants.Zone;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
public class BeginningOfDrawTriggeredAbility extends TriggeredAbilityImpl<BeginningOfDrawTriggeredAbility> { public class BeginningOfDrawTriggeredAbility extends TriggeredAbilityImpl<BeginningOfDrawTriggeredAbility> {
private Constants.TargetController targetController; private TargetController targetController;
public BeginningOfDrawTriggeredAbility(Effect effect, Constants.TargetController targetController, boolean isOptional) { public BeginningOfDrawTriggeredAbility(Effect effect, TargetController targetController, boolean isOptional) {
this(Constants.Zone.BATTLEFIELD, effect, targetController, isOptional); this(Zone.BATTLEFIELD, effect, targetController, isOptional);
} }
public BeginningOfDrawTriggeredAbility(Constants.Zone zone, Effect effect, Constants.TargetController targetController, boolean isOptional) { public BeginningOfDrawTriggeredAbility(Zone zone, Effect effect, TargetController targetController, boolean isOptional) {
super(zone, effect, isOptional); super(zone, effect, isOptional);
this.targetController = targetController; this.targetController = targetController;
} }
@ -52,6 +54,19 @@ public class BeginningOfDrawTriggeredAbility extends TriggeredAbilityImpl<Beginn
} }
return true; return true;
} }
case CONTROLLER_ATTACHED_TO:
Permanent attachment = game.getPermanent(sourceId);
if (attachment != null && attachment.getAttachedTo() != null) {
Permanent attachedTo = game.getPermanent(attachment.getAttachedTo());
if (attachedTo != null && attachedTo.getControllerId().equals(event.getPlayerId())) {
if (getTargets().size() == 0) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
}
}
return true;
}
}
break; break;
case ANY: case ANY:
if (getTargets().size() == 0) { if (getTargets().size() == 0) {
@ -74,6 +89,8 @@ public class BeginningOfDrawTriggeredAbility extends TriggeredAbilityImpl<Beginn
return "At the beginning of each opponent's draw step, " + generateZoneString() + getEffects().getText(modes.getMode()); return "At the beginning of each opponent's draw step, " + generateZoneString() + getEffects().getText(modes.getMode());
case ANY: case ANY:
return "At the beginning of each player's draw step, " + generateZoneString() + getEffects().getText(modes.getMode()); return "At the beginning of each player's draw step, " + generateZoneString() + getEffects().getText(modes.getMode());
case CONTROLLER_ATTACHED_TO:
return "At the beginning of the draw step of enchanted creature's controller, " + generateZoneString() + getEffects().getText(modes.getMode());
} }
return ""; return "";
} }