mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
* Cipher - Fixed that the selection of the creature was handled targeted (e.g. checking for protection) fixes #1240).
This commit is contained in:
parent
1213fd22c8
commit
df4dfc16d7
1 changed files with 30 additions and 27 deletions
|
|
@ -28,8 +28,6 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
|
||||
|
|
@ -38,6 +36,9 @@ import mage.abilities.effects.Effect;
|
|||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
|
@ -46,37 +47,37 @@ import mage.target.targetpointer.FixedTarget;
|
|||
|
||||
/**
|
||||
* FAQ 2013/01/11
|
||||
*
|
||||
*
|
||||
* 702.97. Cipher
|
||||
*
|
||||
* 702.97a Cipher appears on some instants and sorceries. It represents two static
|
||||
* abilities, one that functions while the spell is on the stack and one that functions
|
||||
* while the card with cipher is in the exile zone. "Cipher" means "If this spell is
|
||||
* represented by a card, you may exile this card encoded on a creature you control"
|
||||
* and "As long as this card is encoded on that creature, that creature has 'Whenever
|
||||
* this creature deals combat damage to a player, you may copy this card and you may
|
||||
* cast the copy without paying its mana cost.'"
|
||||
* 702.97a Cipher appears on some instants and sorceries. It represents two
|
||||
* static abilities, one that functions while the spell is on the stack and one
|
||||
* that functions while the card with cipher is in the exile zone. "Cipher"
|
||||
* means "If this spell is represented by a card, you may exile this card
|
||||
* encoded on a creature you control" and "As long as this card is encoded on
|
||||
* that creature, that creature has 'Whenever this creature deals combat damage
|
||||
* to a player, you may copy this card and you may cast the copy without paying
|
||||
* its mana cost.'"
|
||||
*
|
||||
* 702.97b The term "encoded" describes the relationship between the card with cipher
|
||||
* while in the exile zone and the creature chosen when the spell represented by that
|
||||
* card resolves.
|
||||
* 702.97b The term "encoded" describes the relationship between the card with
|
||||
* cipher while in the exile zone and the creature chosen when the spell
|
||||
* represented by that card resolves.
|
||||
*
|
||||
* 702.97c The card with cipher remains encoded on the chosen creature as long as the
|
||||
* card with cipher remains exiled and the creature remains on the battlefield. The
|
||||
* card remains encoded on that object even if it changes controller or stops being
|
||||
* a creature, as long as it remains on the battlefield.
|
||||
* 702.97c The card with cipher remains encoded on the chosen creature as long
|
||||
* as the card with cipher remains exiled and the creature remains on the
|
||||
* battlefield. The card remains encoded on that object even if it changes
|
||||
* controller or stops being a creature, as long as it remains on the
|
||||
* battlefield.
|
||||
*
|
||||
* TODO: Implement Cipher as two static abilities concerning the rules.
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
|
||||
public class CipherEffect extends OneShotEffect {
|
||||
|
||||
public CipherEffect() {
|
||||
super(Outcome.Copy);
|
||||
staticText ="<br><br/>Cipher <i>(Then you may exile this spell card encoded on a creature you control. Whenever that creature deals combat damage to a player, its controller may cast a copy of the encoded card without paying its mana cost.)</i>";
|
||||
staticText = "<br><br/>Cipher <i>(Then you may exile this spell card encoded on a creature you control. Whenever that creature deals combat damage to a player, its controller may cast a copy of the encoded card without paying its mana cost.)</i>";
|
||||
}
|
||||
|
||||
public CipherEffect(final CipherEffect effect) {
|
||||
|
|
@ -86,10 +87,11 @@ public class CipherEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent();
|
||||
if (controller != null) {
|
||||
TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent();
|
||||
target.setNotTarget(true);
|
||||
if (target.canChoose(source.getControllerId(), game)
|
||||
&& controller.chooseUse(outcome, "Cipher this spell to a creature?", source, game)) {
|
||||
&& controller.chooseUse(outcome, "Cipher this spell to a creature?", source, game)) {
|
||||
controller.chooseTarget(outcome, target, source, game);
|
||||
Card sourceCard = game.getCard(source.getSourceId());
|
||||
Permanent targetCreature = game.getPermanent(target.getFirstTarget());
|
||||
|
|
@ -99,9 +101,10 @@ public class CipherEffect extends OneShotEffect {
|
|||
ContinuousEffect effect = new GainAbilityTargetEffect(ability, Duration.Custom);
|
||||
effect.setTargetPointer(new FixedTarget(target.getFirstTarget()));
|
||||
game.addEffect(effect, source);
|
||||
if (!game.isSimulation())
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(new StringBuilder(sourceCard.getLogName()).append(": Spell ciphered to ").append(targetCreature.getLogName()).toString());
|
||||
return sourceCard.moveToExile(null, "", source.getSourceId(), game);
|
||||
}
|
||||
return controller.moveCards(sourceCard, null, Zone.EXILED, source, game);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -119,7 +122,7 @@ public class CipherEffect extends OneShotEffect {
|
|||
|
||||
class CipherStoreEffect extends OneShotEffect {
|
||||
|
||||
private UUID cipherCardId;
|
||||
private final UUID cipherCardId;
|
||||
|
||||
public CipherStoreEffect(UUID cipherCardId, String ruleText) {
|
||||
super(Outcome.Copy);
|
||||
|
|
@ -141,13 +144,13 @@ class CipherStoreEffect extends OneShotEffect {
|
|||
SpellAbility ability = copyCard.getSpellAbility();
|
||||
// remove the cipher effect from the copy
|
||||
Effect cipherEffect = null;
|
||||
for (Effect effect :ability.getEffects()) {
|
||||
for (Effect effect : ability.getEffects()) {
|
||||
if (effect instanceof CipherEffect) {
|
||||
cipherEffect = effect;
|
||||
}
|
||||
}
|
||||
ability.getEffects().remove(cipherEffect);
|
||||
if (ability != null && ability instanceof SpellAbility) {
|
||||
if (ability instanceof SpellAbility) {
|
||||
controller.cast(ability, game, true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue