mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
Fixed Righteous Authority (it wrongly gained ability to enchanted instead of being ability of the enchantment).
This commit is contained in:
parent
dcb904308c
commit
ee51cd59e0
2 changed files with 66 additions and 13 deletions
|
@ -39,13 +39,19 @@ import mage.Constants.Zone;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfDrawTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.CardsInControllerHandCount;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
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.GainAbilityAttachedEffect;
|
||||
import mage.abilities.keyword.EnchantAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
|
@ -55,9 +61,6 @@ import mage.target.common.TargetCreaturePermanent;
|
|||
*/
|
||||
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) {
|
||||
super(ownerId, 189, "Righteous Authority", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{W}{U}");
|
||||
this.expansionSetCode = "RTR";
|
||||
|
@ -73,13 +76,11 @@ public class RighteousAuthority extends CardImpl<RighteousAuthority> {
|
|||
this.addAbility(ability);
|
||||
|
||||
// Enchanted creature gets +1/+1 for each card in its controller's hand.
|
||||
CardsInControllerHandCount boost = new CardsInControllerHandCount();
|
||||
Ability gainedAbility = new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostSourceEffect(boost, boost, Duration.WhileOnBattlefield));
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(gainedAbility, AttachmentType.AURA, Duration.WhileOnBattlefield, rule)));
|
||||
CardsInEnchantedControllerHandCount boost = new CardsInEnchantedControllerHandCount();
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(boost, boost, Duration.WhileOnBattlefield)));
|
||||
|
||||
// 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 SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(gainedAbility2, AttachmentType.AURA, Duration.WhileOnBattlefield, rule2)));
|
||||
this.addAbility(new BeginningOfDrawTriggeredAbility(new DrawCardTargetEffect(1), TargetController.CONTROLLER_ATTACHED_TO, false));
|
||||
}
|
||||
|
||||
public RighteousAuthority (final RighteousAuthority card) {
|
||||
|
@ -91,3 +92,38 @@ public class RighteousAuthority extends CardImpl<RighteousAuthority> {
|
|||
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";
|
||||
}
|
||||
}
|
|
@ -1,20 +1,22 @@
|
|||
package mage.abilities.common;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.Constants.TargetController;
|
||||
import mage.Constants.Zone;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
public class BeginningOfDrawTriggeredAbility extends TriggeredAbilityImpl<BeginningOfDrawTriggeredAbility> {
|
||||
private Constants.TargetController targetController;
|
||||
private TargetController targetController;
|
||||
|
||||
public BeginningOfDrawTriggeredAbility(Effect effect, Constants.TargetController targetController, boolean isOptional) {
|
||||
this(Constants.Zone.BATTLEFIELD, effect, targetController, isOptional);
|
||||
public BeginningOfDrawTriggeredAbility(Effect effect, TargetController targetController, boolean 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);
|
||||
this.targetController = targetController;
|
||||
}
|
||||
|
@ -52,6 +54,19 @@ public class BeginningOfDrawTriggeredAbility extends TriggeredAbilityImpl<Beginn
|
|||
}
|
||||
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;
|
||||
case ANY:
|
||||
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());
|
||||
case ANY:
|
||||
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 "";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue