mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
Pulled from trunk.
This commit is contained in:
parent
7d1508e06a
commit
3376f418c6
166 changed files with 3732 additions and 2309 deletions
|
@ -259,7 +259,7 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sbMana = threadLocalBuilder.get();
|
||||
StringBuilder sbMana = new StringBuilder();
|
||||
if (colorless > 0) {
|
||||
sbMana.append("{").append(Integer.toString(colorless)).append("}");
|
||||
}
|
||||
|
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -54,48 +53,54 @@ import mage.target.Targets;
|
|||
import mage.watchers.Watcher;
|
||||
|
||||
/**
|
||||
* Practically everything in the game is started from an Ability. This
|
||||
* interface describes what an Ability is composed of at the highest level.
|
||||
* Practically everything in the game is started from an Ability. This interface
|
||||
* describes what an Ability is composed of at the highest level.
|
||||
*/
|
||||
public interface Ability extends Controllable, Serializable {
|
||||
|
||||
/**
|
||||
* Gets the globally unique id of the ability contained within the game.
|
||||
*
|
||||
* @return A {@link java.util.UUID} which the game will use to store and retrieve
|
||||
* the exact instance of this ability.
|
||||
*
|
||||
* @return A {@link java.util.UUID} which the game will use to store and
|
||||
* retrieve the exact instance of this ability.
|
||||
*/
|
||||
@Override
|
||||
UUID getId();
|
||||
|
||||
/**
|
||||
* Assigns a new {@link java.util.UUID}
|
||||
*
|
||||
* @see mage.players.PlayerImpl#playAbility(mage.abilities.ActivatedAbility, mage.game.Game)
|
||||
* @see mage.game.GameImpl#addTriggeredAbility(mage.abilities.TriggeredAbility)
|
||||
* @see mage.game.GameImpl#addDelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility)
|
||||
*
|
||||
* @see mage.players.PlayerImpl#playAbility(mage.abilities.ActivatedAbility,
|
||||
* mage.game.Game)
|
||||
* @see
|
||||
* mage.game.GameImpl#addTriggeredAbility(mage.abilities.TriggeredAbility)
|
||||
* @see
|
||||
* mage.game.GameImpl#addDelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility)
|
||||
*/
|
||||
void newId();
|
||||
|
||||
/**
|
||||
* Assigns a new {@link java.util.UUID}
|
||||
*
|
||||
* @see mage.players.PlayerImpl#playAbility(mage.abilities.ActivatedAbility, mage.game.Game)
|
||||
* @see mage.game.GameImpl#addTriggeredAbility(mage.abilities.TriggeredAbility)
|
||||
* @see mage.game.GameImpl#addDelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility)
|
||||
*
|
||||
* @see mage.players.PlayerImpl#playAbility(mage.abilities.ActivatedAbility,
|
||||
* mage.game.Game)
|
||||
* @see
|
||||
* mage.game.GameImpl#addTriggeredAbility(mage.abilities.TriggeredAbility)
|
||||
* @see
|
||||
* mage.game.GameImpl#addDelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility)
|
||||
*/
|
||||
void newOriginalId();
|
||||
|
||||
/**
|
||||
* Gets the {@link AbilityType} of this ability.
|
||||
*
|
||||
*
|
||||
* @return The {@link AbilityType type} of this ability.
|
||||
*/
|
||||
AbilityType getAbilityType();
|
||||
|
||||
/**
|
||||
* Gets the id of the player in control of this ability.
|
||||
*
|
||||
*
|
||||
* @return The {@link java.util.UUID} of the controlling player.
|
||||
*/
|
||||
@Override
|
||||
|
@ -103,28 +108,29 @@ public interface Ability extends Controllable, Serializable {
|
|||
|
||||
/**
|
||||
* Sets the id of the controller of this ability.
|
||||
*
|
||||
*
|
||||
* @param controllerId The {@link java.util.UUID} of the controller.
|
||||
*/
|
||||
void setControllerId(UUID controllerId);
|
||||
|
||||
/**
|
||||
* Gets the id of the object which put this ability in motion.
|
||||
*
|
||||
* @return The {@link java.util.UUID} of the object this ability is associated with.
|
||||
*
|
||||
* @return The {@link java.util.UUID} of the object this ability is
|
||||
* associated with.
|
||||
*/
|
||||
UUID getSourceId();
|
||||
|
||||
/**
|
||||
* Sets the id of the object which this ability orignates from.
|
||||
*
|
||||
*
|
||||
* @param sourceID {@link java.util.UUID} the source id to set.
|
||||
*/
|
||||
void setSourceId(UUID sourceID);
|
||||
|
||||
/**
|
||||
* Gets all {@link Costs} associated with this ability.
|
||||
*
|
||||
*
|
||||
* @return All {@link Costs} associated with this ability.
|
||||
*/
|
||||
Costs<Cost> getCosts();
|
||||
|
@ -132,25 +138,25 @@ public interface Ability extends Controllable, Serializable {
|
|||
/**
|
||||
* Adds a {@link Cost} to this ability that must be paid before this ability
|
||||
* is activated.
|
||||
*
|
||||
*
|
||||
* @param cost The {@link Cost} to add.
|
||||
*/
|
||||
void addCost(Cost cost);
|
||||
|
||||
/**
|
||||
* Gets all {@link ManaCosts} associated with this ability. These returned
|
||||
* Gets all {@link ManaCosts} associated with this ability. These returned
|
||||
* costs should never be modified as they represent the base costs before
|
||||
* any modifications.
|
||||
*
|
||||
*
|
||||
* @return All {@link ManaCosts} that must be paid.
|
||||
*/
|
||||
ManaCosts<ManaCost> getManaCosts();
|
||||
|
||||
/**
|
||||
* Gets all the {@link ManaCosts} that must be paid before activating this
|
||||
* ability. These costs should be modified by any modification effects currently
|
||||
* present within the game state.
|
||||
*
|
||||
* ability. These costs should be modified by any modification effects
|
||||
* currently present within the game state.
|
||||
*
|
||||
* @return All {@link ManaCosts} that must be paid.
|
||||
*/
|
||||
ManaCosts<ManaCost> getManaCostsToPay();
|
||||
|
@ -158,52 +164,61 @@ public interface Ability extends Controllable, Serializable {
|
|||
/**
|
||||
* Adds a {@link ManaCost} to this ability that must be paid before this
|
||||
* ability is activated.
|
||||
*
|
||||
*
|
||||
* @param cost The {@link ManaCost} to add.
|
||||
*/
|
||||
void addManaCost(ManaCost cost);
|
||||
|
||||
/**
|
||||
* Gets all {@link AlternativeCost} associated with this ability.
|
||||
*
|
||||
* @return All {@link AlternativeCost}'s that can be paid instead of the {@link ManaCosts}
|
||||
*
|
||||
* @return All {@link AlternativeCost}'s that can be paid instead of the
|
||||
* {@link ManaCosts}
|
||||
*/
|
||||
List<AlternativeCost> getAlternativeCosts();
|
||||
|
||||
/**
|
||||
* Adds an {@link AlternativeCost} this ability that may be paid instead of
|
||||
* any other cost.
|
||||
*
|
||||
*
|
||||
* @param cost The {@link AlternativeCost} to add.
|
||||
*/
|
||||
void addAlternativeCost(AlternativeCost cost);
|
||||
|
||||
/**
|
||||
* TODO Method is unused, keep it around?
|
||||
*
|
||||
* Gets all costs that are optional to this ability. These costs can be paid
|
||||
*
|
||||
* Gets all costs that are optional to this ability. These costs can be paid
|
||||
* in addition to other costs to have other effects put into place.
|
||||
*
|
||||
*
|
||||
* @return All {@link Costs} that can be paid above and beyond other costs.
|
||||
*/
|
||||
Costs<Cost> getOptionalCosts();
|
||||
|
||||
/**
|
||||
* Adds a {@link Cost} that is optional to this ability.
|
||||
*
|
||||
*
|
||||
* @param cost The {@link Cost} to add to the optional costs.
|
||||
*/
|
||||
void addOptionalCost(Cost cost);
|
||||
|
||||
/**
|
||||
* Retrieves the effects that are put into the place by the resolution of this
|
||||
* ability.
|
||||
*
|
||||
* Retrieves the effects that are put into the place by the resolution of
|
||||
* this ability.
|
||||
*
|
||||
* @return All {@link Effects} that will be put into place by the resolution
|
||||
* of this ability.
|
||||
*/
|
||||
Effects getEffects();
|
||||
|
||||
/**
|
||||
* Retrieves all effects of an ability. That means effects from all modes
|
||||
* event those modes that are not seleced (yet).
|
||||
*
|
||||
* @return All {@link Effects} of this ability.
|
||||
*/
|
||||
Effects getAllEffects();
|
||||
|
||||
/**
|
||||
* Retrieves the effects of the specified {@link EffectType type} that are
|
||||
* put into place by the resolution of this ability.
|
||||
|
@ -216,26 +231,28 @@ public interface Ability extends Controllable, Serializable {
|
|||
|
||||
/**
|
||||
* Adds an effect to this ability.
|
||||
*
|
||||
*
|
||||
* @param effect The {@link Effect} to add.
|
||||
*/
|
||||
void addEffect(Effect effect);
|
||||
|
||||
/**
|
||||
* Retrieves all targets that must be satisfied before this ability is
|
||||
* Retrieves all targets that must be satisfied before this ability is put
|
||||
* onto the stack.
|
||||
*
|
||||
* @return All {@link Targets} that must be satisfied before this ability is
|
||||
* put onto the stack.
|
||||
*
|
||||
* @return All {@link Targets} that must be satisfied before this ability is put onto
|
||||
* the stack.
|
||||
*/
|
||||
Targets getTargets();
|
||||
|
||||
/**
|
||||
* Retrieves the {@link Target} located at the 0th index in the {@link Targets}.
|
||||
* A call to the method is equivalent to {@link #getTargets()}.get(0).getFirstTarget().
|
||||
*
|
||||
* @return The {@link java.util.UUID} of the first target within the targets list.
|
||||
*
|
||||
* Retrieves the {@link Target} located at the 0th index in the
|
||||
* {@link Targets}. A call to the method is equivalent to
|
||||
* {@link #getTargets()}.get(0).getFirstTarget().
|
||||
*
|
||||
* @return The {@link java.util.UUID} of the first target within the targets
|
||||
* list.
|
||||
*
|
||||
* @see mage.target.Target
|
||||
*/
|
||||
UUID getFirstTarget();
|
||||
|
@ -243,53 +260,54 @@ public interface Ability extends Controllable, Serializable {
|
|||
/**
|
||||
* Adds a target to this ability that must be satisfied before this ability
|
||||
* is put onto the stack.
|
||||
*
|
||||
*
|
||||
* @param target The {@link Target} to add.
|
||||
*/
|
||||
void addTarget(Target target);
|
||||
|
||||
/**
|
||||
* Choices
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Choices getChoices();
|
||||
|
||||
/**
|
||||
* TODO: Javadoc me
|
||||
*
|
||||
* @param choice
|
||||
*
|
||||
* @param choice
|
||||
*/
|
||||
void addChoice(Choice choice);
|
||||
|
||||
/**
|
||||
* Retrieves the {@link Zone} that this ability is active within.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Zone getZone();
|
||||
|
||||
/**
|
||||
* Retrieves whether or not this abilities activation will use the stack.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isUsesStack();
|
||||
|
||||
/**
|
||||
* Retrieves a human readable string representing what the ability states it
|
||||
* accomplishes. This call is equivalent to {@link #getRule(boolean) getRule(false)}
|
||||
*
|
||||
* accomplishes. This call is equivalent to
|
||||
* {@link #getRule(boolean) getRule(false)}
|
||||
*
|
||||
* @return A human readable string representing what the ability states it
|
||||
* accomplishes
|
||||
*/
|
||||
String getRule();
|
||||
|
||||
/**
|
||||
* Retrieves a human readable string including any costs associated with this
|
||||
* ability if the all parameter is true, and just the abilities rule text if
|
||||
* the all parameter is false.
|
||||
*
|
||||
* Retrieves a human readable string including any costs associated with
|
||||
* this ability if the all parameter is true, and just the abilities rule
|
||||
* text if the all parameter is false.
|
||||
*
|
||||
* @param all True if costs are desired in the output, false otherwise.
|
||||
* @return
|
||||
*/
|
||||
|
@ -297,51 +315,60 @@ public interface Ability extends Controllable, Serializable {
|
|||
|
||||
/**
|
||||
* Retrieves the rule associated with the given source.
|
||||
*
|
||||
*
|
||||
* @param source
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
String getRule(String source);
|
||||
|
||||
/**
|
||||
* Activates this ability prompting the controller to pay any mandatory
|
||||
* {@link Costs} or {@link AlternativeCost} associated with this ability.
|
||||
*
|
||||
* @param game A reference the {@link Game} for which this ability should be activated within.
|
||||
*
|
||||
* @param game A reference the {@link Game} for which this ability should be
|
||||
* activated within.
|
||||
* @param noMana Whether or not {@link ManaCosts} have to be paid.
|
||||
* @return True if this ability was successfully activated.
|
||||
*
|
||||
* @see mage.players.PlayerImpl#cast(mage.abilities.SpellAbility, mage.game.Game, boolean)
|
||||
* @see mage.players.PlayerImpl#playAbility(mage.abilities.ActivatedAbility, mage.game.Game)
|
||||
* @see mage.players.PlayerImpl#triggerAbility(mage.abilities.TriggeredAbility, mage.game.Game)
|
||||
*
|
||||
* @see mage.players.PlayerImpl#cast(mage.abilities.SpellAbility,
|
||||
* mage.game.Game, boolean)
|
||||
* @see mage.players.PlayerImpl#playAbility(mage.abilities.ActivatedAbility,
|
||||
* mage.game.Game)
|
||||
* @see
|
||||
* mage.players.PlayerImpl#triggerAbility(mage.abilities.TriggeredAbility,
|
||||
* mage.game.Game)
|
||||
*/
|
||||
boolean activate(Game game, boolean noMana);
|
||||
|
||||
boolean isActivated();
|
||||
|
||||
|
||||
/**
|
||||
* Resolves this ability and puts any effects it produces into play. This
|
||||
* method should only be called if the {@link #activate(mage.game.Game, boolean)}
|
||||
* method returned true.
|
||||
*
|
||||
* Resolves this ability and puts any effects it produces into play. This
|
||||
* method should only be called if the
|
||||
* {@link #activate(mage.game.Game, boolean)} method returned true.
|
||||
*
|
||||
* @param game The {@link Game} for which this ability resolves within.
|
||||
* @return Whether or not this ability successfully resolved.
|
||||
*
|
||||
* @see mage.players.PlayerImpl#playManaAbility(mage.abilities.mana.ManaAbility, mage.game.Game)
|
||||
* @see mage.players.PlayerImpl#specialAction(mage.abilities.SpecialAction, mage.game.Game)
|
||||
*
|
||||
* @see
|
||||
* mage.players.PlayerImpl#playManaAbility(mage.abilities.mana.ManaAbility,
|
||||
* mage.game.Game)
|
||||
* @see mage.players.PlayerImpl#specialAction(mage.abilities.SpecialAction,
|
||||
* mage.game.Game)
|
||||
*/
|
||||
boolean resolve(Game game);
|
||||
|
||||
/**
|
||||
* Used to reset the state of this ability.
|
||||
*
|
||||
* @param game
|
||||
*
|
||||
* @param game
|
||||
*/
|
||||
void reset(Game game);
|
||||
|
||||
/**
|
||||
* Overridden by triggered abilities with intervening if clauses - rule 20110715 - 603.4
|
||||
*
|
||||
* Overridden by triggered abilities with intervening if clauses - rule
|
||||
* 20110715 - 603.4
|
||||
*
|
||||
* @param game
|
||||
* @return Whether or not the intervening if clause is satisfied
|
||||
*/
|
||||
|
@ -349,7 +376,7 @@ public interface Ability extends Controllable, Serializable {
|
|||
|
||||
/**
|
||||
* Creates a fresh copy of this ability.
|
||||
*
|
||||
*
|
||||
* @return A new copy of this ability.
|
||||
*/
|
||||
Ability copy();
|
||||
|
@ -364,43 +391,47 @@ public interface Ability extends Controllable, Serializable {
|
|||
|
||||
/**
|
||||
* Gets the list of sub-abilities associated with this ability.
|
||||
* @return
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<Ability> getSubAbilities();
|
||||
|
||||
/**
|
||||
* Adds a sub-ability to this ability.
|
||||
*
|
||||
*
|
||||
* @param ability The {@link Ability} to add.
|
||||
*/
|
||||
void addSubAbility(Ability ability);
|
||||
|
||||
List<Watcher> getWatchers();
|
||||
|
||||
void addWatcher(Watcher watcher);
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if this abilities source is in the zone for the ability
|
||||
*
|
||||
*
|
||||
* @param game
|
||||
* @param source
|
||||
* @param event
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
boolean isInUseableZone(Game game, MageObject source, GameEvent event);
|
||||
|
||||
/**
|
||||
* Returns true if the source object has currently the ability
|
||||
* (e.g. The object can have lost all or some abilities for some time (e.g. Turn to Frog)
|
||||
*
|
||||
* Returns true if the source object has currently the ability (e.g. The
|
||||
* object can have lost all or some abilities for some time (e.g. Turn to
|
||||
* Frog)
|
||||
*
|
||||
* @param game
|
||||
* @param source
|
||||
* @param event
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
boolean hasSourceObjectAbility(Game game, MageObject source, GameEvent event);
|
||||
|
||||
/**
|
||||
* Returns true if this ability has to be shown as topmost of all the rules of the object
|
||||
* Returns true if this ability has to be shown as topmost of all the rules
|
||||
* of the object
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
@ -415,10 +446,9 @@ public interface Ability extends Controllable, Serializable {
|
|||
*/
|
||||
void setRuleAtTheTop(boolean ruleAtTheTop);
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if this ability has to work also with face down object
|
||||
* (set to not visible normally).
|
||||
* Returns true if this ability has to work also with face down object (set
|
||||
* to not visible normally).
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
@ -439,20 +469,20 @@ public interface Ability extends Controllable, Serializable {
|
|||
* @return
|
||||
*/
|
||||
boolean getRuleVisible();
|
||||
|
||||
|
||||
/**
|
||||
* Sets the value for the ruleVisible attribute
|
||||
*
|
||||
* true = rule will be shown for the card / permanent
|
||||
* false = rule won't be shown
|
||||
* true = rule will be shown for the card / permanent false = rule won't be
|
||||
* shown
|
||||
*
|
||||
* @param ruleVisible
|
||||
*/
|
||||
void setRuleVisible(boolean ruleVisible);
|
||||
|
||||
/**
|
||||
* Returns true if the additional costs of the abilitiy should be visible on the tooltip text
|
||||
* Returns true if the additional costs of the abilitiy should be visible on
|
||||
* the tooltip text
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
@ -461,35 +491,34 @@ public interface Ability extends Controllable, Serializable {
|
|||
/**
|
||||
* Sets the value for the additional costs rule attribute
|
||||
*
|
||||
* true = rule will be shown for the card / permanent
|
||||
* false = rule won't be shown
|
||||
* true = rule will be shown for the card / permanent false = rule won't be
|
||||
* shown
|
||||
*
|
||||
* @param ruleAdditionalCostsVisible
|
||||
*/
|
||||
void setAdditionalCostsRuleVisible(boolean ruleAdditionalCostsVisible);
|
||||
|
||||
|
||||
/**
|
||||
* Get the originalId of the ability
|
||||
*
|
||||
*
|
||||
* @return originalId
|
||||
*/
|
||||
UUID getOriginalId();
|
||||
|
||||
|
||||
/**
|
||||
* Sets the ability word for the given ability.
|
||||
* An ability word is a word that, in essence, groups, and reminds players of, cards
|
||||
* that have a common functionality and does not imply any particular rules.
|
||||
*
|
||||
* Sets the ability word for the given ability. An ability word is a word
|
||||
* that, in essence, groups, and reminds players of, cards that have a
|
||||
* common functionality and does not imply any particular rules.
|
||||
*
|
||||
* --- Not usable yet for rule text generation of triggered abilities ---
|
||||
*
|
||||
* @param abilityWord
|
||||
*
|
||||
* @param abilityWord
|
||||
*/
|
||||
void setAbilityWord(AbilityWord abilityWord);
|
||||
|
||||
/**
|
||||
* Creates the message about the ability casting/triggering/activating to post in the game log
|
||||
* before the ability resolves.
|
||||
* Creates the message about the ability casting/triggering/activating to
|
||||
* post in the game log before the ability resolves.
|
||||
*
|
||||
* @param game
|
||||
* @return
|
||||
|
@ -497,46 +526,46 @@ public interface Ability extends Controllable, Serializable {
|
|||
String getGameLogMessage(Game game);
|
||||
|
||||
/**
|
||||
* Used to deactivate cost modification logic of ability activation for some special handling
|
||||
* (e.g. FlashbackAbility gets cost modifiaction twice because of how it's handled now)
|
||||
* Used to deactivate cost modification logic of ability activation for some
|
||||
* special handling (e.g. FlashbackAbility gets cost modifiaction twice
|
||||
* because of how it's handled now)
|
||||
*
|
||||
* @param active execute no cost modification
|
||||
*/
|
||||
void setCostModificationActive(boolean active);
|
||||
|
||||
boolean activateAlternateOrAdditionalCosts(MageObject sourceObject, boolean noMana, Player controller, Game game);
|
||||
|
||||
|
||||
/**
|
||||
* Sets the object that actually existed while a ability triggerd or
|
||||
* an ability was activated.
|
||||
*
|
||||
* @param mageObject
|
||||
* @param game
|
||||
* Sets the object that actually existed while a ability triggerd or an
|
||||
* ability was activated.
|
||||
*
|
||||
* @param mageObject
|
||||
* @param game
|
||||
*/
|
||||
void setSourceObject(MageObject mageObject, Game game);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the object that actually existed while a ability triggerd or
|
||||
* an ability was activated.
|
||||
* If not set yet, the current object will be retrieved from the game.
|
||||
*
|
||||
* Returns the object that actually existed while a ability triggerd or an
|
||||
* ability was activated. If not set yet, the current object will be
|
||||
* retrieved from the game.
|
||||
*
|
||||
* @param game
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
MageObject getSourceObject(Game game);
|
||||
|
||||
int getSourceObjectZoneChangeCounter();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the object that actually existed while a ability triggerd or
|
||||
* an ability was activated only if it has not changed zone meanwhile.
|
||||
* If not set yet, the current object will be retrieved from the game.
|
||||
*
|
||||
* Returns the object that actually existed while a ability triggerd or an
|
||||
* ability was activated only if it has not changed zone meanwhile. If not
|
||||
* set yet, the current object will be retrieved from the game.
|
||||
*
|
||||
* @param game
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
|
||||
MageObject getSourceObjectIfItStillExists(Game game);
|
||||
|
||||
|
||||
String getTargetDescription(Targets targets, Game game);
|
||||
}
|
||||
|
|
|
@ -445,25 +445,36 @@ public abstract class AbilityImpl implements Ability {
|
|||
public boolean activateAlternateOrAdditionalCosts(MageObject sourceObject, boolean noMana, Player controller, Game game) {
|
||||
boolean alternativeCostisUsed = false;
|
||||
if (sourceObject != null && !(sourceObject instanceof Permanent) && !(this instanceof FlashbackAbility)) {
|
||||
for (Ability ability : sourceObject.getAbilities()) {
|
||||
// if cast for noMana no Alternative costs are allowed
|
||||
if (!noMana && ability instanceof AlternativeSourceCosts) {
|
||||
AlternativeSourceCosts alternativeSpellCosts = (AlternativeSourceCosts) ability;
|
||||
if (alternativeSpellCosts.isAvailable(this, game)) {
|
||||
if (alternativeSpellCosts.askToActivateAlternativeCosts(this, game)) {
|
||||
// only one alternative costs may be activated
|
||||
alternativeCostisUsed = true;
|
||||
break;
|
||||
Abilities<Ability> abilities = null;
|
||||
if (sourceObject instanceof Card) {
|
||||
abilities = ((Card) sourceObject).getAbilities(game);
|
||||
} else {
|
||||
sourceObject.getAbilities();
|
||||
}
|
||||
if (abilities != null) {
|
||||
for (Ability ability : abilities) {
|
||||
// if cast for noMana no Alternative costs are allowed
|
||||
if (!noMana && ability instanceof AlternativeSourceCosts) {
|
||||
AlternativeSourceCosts alternativeSpellCosts = (AlternativeSourceCosts) ability;
|
||||
if (alternativeSpellCosts.isAvailable(this, game)) {
|
||||
if (alternativeSpellCosts.askToActivateAlternativeCosts(this, game)) {
|
||||
// only one alternative costs may be activated
|
||||
alternativeCostisUsed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ability instanceof OptionalAdditionalSourceCosts) {
|
||||
((OptionalAdditionalSourceCosts) ability).addOptionalAdditionalCosts(this, game);
|
||||
if (ability instanceof OptionalAdditionalSourceCosts) {
|
||||
((OptionalAdditionalSourceCosts) ability).addOptionalAdditionalCosts(this, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
// controller specific alternate spell costs
|
||||
if (!noMana && !alternativeCostisUsed) {
|
||||
if (this.getAbilityType().equals(AbilityType.SPELL)) {
|
||||
if (this.getAbilityType().equals(AbilityType.SPELL)
|
||||
// 117.9a Only one alternative cost can be applied to any one spell as it’s being cast.
|
||||
// So an alternate spell ability can't be paid with Omniscience
|
||||
&& !((SpellAbility) this).getSpellAbilityType().equals(SpellAbilityType.BASE_ALTERNATE)) {
|
||||
for (AlternativeSourceCosts alternativeSourceCosts : controller.getAlternativeSourceCosts()) {
|
||||
if (alternativeSourceCosts.isAvailable(this, game)) {
|
||||
if (alternativeSourceCosts.askToActivateAlternativeCosts(this, game)) {
|
||||
|
@ -673,6 +684,15 @@ public abstract class AbilityImpl implements Ability {
|
|||
return modes.getMode().getEffects();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Effects getAllEffects() {
|
||||
Effects allEffects = new Effects();
|
||||
for (Mode mode : getModes().values()) {
|
||||
allEffects.addAll(mode.getEffects());
|
||||
}
|
||||
return allEffects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Effects getEffects(Game game, EffectType effectType) {
|
||||
Effects typedEffects = new Effects();
|
||||
|
@ -935,7 +955,10 @@ public abstract class AbilityImpl implements Ability {
|
|||
// for singleton abilities like Flying we can't rely on abilities' source because it's only once in continuous effects
|
||||
// so will use the sourceId of the object itself that came as a parameter if it is not null
|
||||
if (object == null) {
|
||||
object = game.getObject(getSourceId());
|
||||
object = game.getPermanentEntering(getSourceId());
|
||||
if (object == null) {
|
||||
object = game.getObject(getSourceId());
|
||||
}
|
||||
}
|
||||
if (object != null && !object.getAbilities().contains(this)) {
|
||||
if (object instanceof Permanent) {
|
||||
|
|
|
@ -99,10 +99,6 @@ public class SpellAbility extends ActivatedAbilityImpl {
|
|||
&& !controllerId.equals(playerId)) {
|
||||
return false;
|
||||
}
|
||||
// Check if spell has no costs (not {0} mana costs), than it's not castable. E.g. for spells like Living End, that only can be cast by Suspend Ability.
|
||||
if (this.getManaCosts().isEmpty() && this.getCosts().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
// Check if rule modifying events prevent to cast the spell in check playable mode
|
||||
if (this.isCheckPlayableMode()) {
|
||||
if (game.getContinuousEffects().preventedByRuleModification(
|
||||
|
|
|
@ -95,7 +95,7 @@ public class TriggeredAbilities extends ConcurrentHashMap<String, TriggeredAbili
|
|||
if (object != null) {
|
||||
boolean controllerSet = false;
|
||||
if (!ability.getZone().equals(Zone.COMMAND) && event != null && event.getTargetId() != null && event.getTargetId().equals(ability.getSourceId())
|
||||
&& (event.getType().equals(EventType.ZONE_CHANGE) || event.getType().equals(EventType.DESTROYED_PERMANENT))) {
|
||||
&& (event.getType().equals(EventType.ZONE_CHANGE) || event.getType().equals(EventType.DESTROYED_PERMANENT) || event.getType().equals(EventType.SACRIFICED_PERMANENT))) {
|
||||
// need to check if object was face down for dies and destroy events because the ability triggers in the new zone, zone counter -1 is used
|
||||
Permanent permanent = (Permanent) game.getLastKnownInformation(ability.getSourceId(), Zone.BATTLEFIELD, ability.getSourceObjectZoneChangeCounter() - 1);
|
||||
if (permanent != null) {
|
||||
|
|
|
@ -77,11 +77,6 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
|
|||
return true;
|
||||
}
|
||||
|
||||
// TODO: Implement for all TriggeredAbilities so this default method can be removed
|
||||
/*@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return true;
|
||||
}*/
|
||||
@Override
|
||||
public boolean resolve(Game game) {
|
||||
if (isOptional()) {
|
||||
|
|
|
@ -30,8 +30,11 @@ public class AnotherCreatureEntersBattlefieldTriggeredAbility extends TriggeredA
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getTargetId() != this.getSourceId()) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent.getCardType().contains(CardType.CREATURE)) {
|
||||
Permanent permanent = game.getPermanentEntering(event.getTargetId());
|
||||
if (permanent == null) {
|
||||
permanent = game.getPermanent(event.getTargetId());
|
||||
}
|
||||
if (permanent != null && permanent.getCardType().contains(CardType.CREATURE)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,11 +39,11 @@ import mage.constants.Zone;
|
|||
public class AsEntersBattlefieldAbility extends StaticAbility {
|
||||
|
||||
public AsEntersBattlefieldAbility(Effect effect) {
|
||||
super(Zone.BATTLEFIELD, new EntersBattlefieldEffect(effect));
|
||||
super(Zone.ALL, new EntersBattlefieldEffect(effect));
|
||||
}
|
||||
|
||||
public AsEntersBattlefieldAbility(Effect effect, String text) {
|
||||
super(Zone.BATTLEFIELD, new EntersBattlefieldEffect(effect, text));
|
||||
super(Zone.ALL, new EntersBattlefieldEffect(effect, text));
|
||||
}
|
||||
|
||||
public AsEntersBattlefieldAbility(AsEntersBattlefieldAbility ability) {
|
||||
|
@ -59,10 +59,9 @@ public class AsEntersBattlefieldAbility extends StaticAbility {
|
|||
return;
|
||||
}
|
||||
}
|
||||
super.addEffect(effect);
|
||||
super.addEffect(effect);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AsEntersBattlefieldAbility copy() {
|
||||
return new AsEntersBattlefieldAbility(this);
|
||||
|
|
|
@ -2,17 +2,25 @@ package mage.abilities.common;
|
|||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
public class AttacksOrBlocksTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
protected String startText = "Whenever";
|
||||
|
||||
public AttacksOrBlocksTriggeredAbility(Effect effect, boolean optional) {
|
||||
super(Zone.BATTLEFIELD, effect, optional);
|
||||
if (effect instanceof CreateDelayedTriggeredAbilityEffect) {
|
||||
startText = "When";
|
||||
}
|
||||
}
|
||||
|
||||
public AttacksOrBlocksTriggeredAbility(final AttacksOrBlocksTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.startText = ability.startText;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,8 +30,9 @@ public class AttacksOrBlocksTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "When {this} attacks or blocks, " + super.getRule();
|
||||
return startText + " {this} attacks or blocks, " + super.getRule();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.ATTACKER_DECLARED || event.getType() == GameEvent.EventType.BLOCKER_DECLARED;
|
||||
|
|
|
@ -27,11 +27,13 @@
|
|||
*/
|
||||
package mage.abilities.common;
|
||||
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterStackObject;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.stack.StackObject;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -39,12 +41,20 @@ import mage.game.events.GameEvent;
|
|||
*/
|
||||
public class BecomesTargetTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private final FilterStackObject filter;
|
||||
|
||||
public BecomesTargetTriggeredAbility(Effect effect) {
|
||||
this(effect, new FilterStackObject("a spell or ability"));
|
||||
}
|
||||
|
||||
public BecomesTargetTriggeredAbility(Effect effect, FilterStackObject filter) {
|
||||
super(Zone.BATTLEFIELD, effect);
|
||||
this.filter = filter.copy();
|
||||
}
|
||||
|
||||
public BecomesTargetTriggeredAbility(final BecomesTargetTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.filter = ability.filter.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,11 +69,12 @@ public class BecomesTargetTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return event.getTargetId().equals(getSourceId());
|
||||
StackObject sourceObject = game.getStack().getStackObject(event.getSourceId());
|
||||
return event.getTargetId().equals(getSourceId()) && filter.match(sourceObject, getSourceId(), getControllerId(), game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "When {this} becomes the target of a spell or ability, " + super.getRule();
|
||||
return "When {this} becomes the target of " + filter.getMessage() + ", " + super.getRule();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
|
@ -20,16 +20,16 @@
|
|||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.common;
|
||||
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.DamagedPlayerEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
|
@ -72,7 +72,7 @@ public class DealsCombatDamageToAPlayerTriggeredAbility extends TriggeredAbility
|
|||
if (event.getSourceId().equals(getSourceId())
|
||||
&& ((DamagedPlayerEvent) event).isCombatDamage()) {
|
||||
if (setTargetPointer) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
for (Effect effect : this.getAllEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||
effect.setValue("damage", event.getAmount());
|
||||
}
|
||||
|
|
|
@ -1,21 +1,26 @@
|
|||
package mage.abilities.common;
|
||||
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.SetTargetPointer;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
* "When enchanted/equipped creature dies" triggered ability
|
||||
*
|
||||
* @author Loki
|
||||
*/
|
||||
public class DiesAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
|
||||
private String attachedDescription;
|
||||
private boolean diesRuleText;
|
||||
|
||||
protected SetTargetPointer setTargetPointer;
|
||||
|
||||
public DiesAttachedTriggeredAbility(Effect effect, String attachedDescription) {
|
||||
this(effect, attachedDescription, false);
|
||||
}
|
||||
|
@ -25,16 +30,21 @@ public class DiesAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
}
|
||||
|
||||
public DiesAttachedTriggeredAbility(Effect effect, String attachedDescription, boolean optional, boolean diesRuleText) {
|
||||
this(effect, attachedDescription, optional, diesRuleText, SetTargetPointer.NONE);
|
||||
}
|
||||
|
||||
public DiesAttachedTriggeredAbility(Effect effect, String attachedDescription, boolean optional, boolean diesRuleText, SetTargetPointer setTargetPointer) {
|
||||
super(Zone.ALL, effect, optional); // because the trigger only triggers if the object was attached, it doesn't matter where the Attachment was moved to (e.g. by replacement effect) after the trigger triggered, so Zone.all
|
||||
this.attachedDescription = attachedDescription;
|
||||
this.diesRuleText = diesRuleText;
|
||||
this.setTargetPointer = setTargetPointer;
|
||||
}
|
||||
|
||||
|
||||
public DiesAttachedTriggeredAbility(final DiesAttachedTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.attachedDescription = ability.attachedDescription;
|
||||
this.diesRuleText = ability.diesRuleText;
|
||||
this.setTargetPointer = ability.setTargetPointer;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -49,11 +59,35 @@ public class DiesAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (((ZoneChangeEvent)event).isDiesEvent()) {
|
||||
if (((ZoneChangeEvent) event).isDiesEvent()) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
boolean triggered = false;
|
||||
if (zEvent.getTarget().getAttachments().contains(this.getSourceId())) {
|
||||
triggered = true;
|
||||
} else {
|
||||
// If both (attachment and attached went to graveyard at the same time, the attachemnets can be already removed from the attached object.)
|
||||
// So check here with the LKI of the enchantment
|
||||
Permanent attachment = game.getPermanentOrLKIBattlefield(getSourceId());
|
||||
if (attachment != null
|
||||
&& zEvent.getTargetId() != null && attachment.getAttachedTo() != null
|
||||
&& zEvent.getTargetId().equals(attachment.getAttachedTo())
|
||||
&& attachment.getAttachedToZoneChangeCounter() == zEvent.getTarget().getZoneChangeCounter(game) - 1) {
|
||||
triggered = true;
|
||||
}
|
||||
}
|
||||
if (triggered) {
|
||||
for (Effect effect : getEffects()) {
|
||||
effect.setValue("attachedTo", zEvent.getTarget());
|
||||
if (setTargetPointer.equals(SetTargetPointer.ATTACHED_TO_CONTROLLER)) {
|
||||
Permanent attachment = game.getPermanentOrLKIBattlefield(getSourceId());
|
||||
if (attachment != null && attachment.getAttachedTo() != null) {
|
||||
Permanent attachedTo = (Permanent) game.getLastKnownInformation(attachment.getAttachedTo(), Zone.BATTLEFIELD, attachment.getAttachedToZoneChangeCounter());
|
||||
if (attachedTo != null) {
|
||||
effect.setTargetPointer(new FixedTarget(attachedTo.getControllerId()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public class DiesTriggeredAbility extends ZoneChangeTriggeredAbility {
|
|||
if (super.checkEventType(event, game)) {
|
||||
return ((ZoneChangeEvent) event).getFromZone().equals(Zone.BATTLEFIELD) && ((ZoneChangeEvent) event).getToZone().equals(Zone.GRAVEYARD);
|
||||
}
|
||||
return event.getType() == GameEvent.EventType.ZONE_CHANGE;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.StaticAbility;
|
||||
|
@ -41,39 +40,50 @@ import mage.constants.Zone;
|
|||
public class EntersBattlefieldAbility extends StaticAbility {
|
||||
|
||||
protected String abilityRule;
|
||||
|
||||
protected boolean optional;
|
||||
|
||||
public EntersBattlefieldAbility(Effect effect) {
|
||||
this(effect, true);
|
||||
this(effect, false);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param effect effect that happens when the permanent enters the battlefield
|
||||
* @param showRule show the rule for this ability
|
||||
*/
|
||||
public EntersBattlefieldAbility(Effect effect, Boolean showRule) {
|
||||
this(effect, null, showRule, null, null);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param effect effect that happens when the permanent enters the
|
||||
* battlefiely
|
||||
* @param optional
|
||||
*/
|
||||
public EntersBattlefieldAbility(Effect effect, boolean optional) {
|
||||
this(effect, optional, null, null, null);
|
||||
}
|
||||
|
||||
public EntersBattlefieldAbility(Effect effect, String effectText) {
|
||||
this(effect, null, true, null, effectText);
|
||||
this(effect, null, null, effectText);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param effect effect that happens when the permanent enters the battlefield
|
||||
* @param condition only if this condition is true, the effect will happen
|
||||
* @param ruleVisible show the rule for this ability
|
||||
* @param abilityRule rule for this ability (no text from effects will be added)
|
||||
* @param effectText this text will be used for the EnterBattlefieldEffect
|
||||
*/
|
||||
public EntersBattlefieldAbility(Effect effect, Condition condition, Boolean ruleVisible, String abilityRule, String effectText) {
|
||||
super(Zone.BATTLEFIELD, new EntersBattlefieldEffect(effect, condition, effectText));
|
||||
this.setRuleVisible(ruleVisible);
|
||||
|
||||
public EntersBattlefieldAbility(Effect effect, Condition condition, String abilityRule, String effectText) {
|
||||
this(effect, false, condition, abilityRule, effectText);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param effect effect that happens when the permanent enters the
|
||||
* battlefield
|
||||
* @param optional
|
||||
* @param condition only if this condition is true, the effect will happen
|
||||
* @param abilityRule rule for this ability (no text from effects will be
|
||||
* added)
|
||||
* @param effectText this text will be used for the EnterBattlefieldEffect
|
||||
*/
|
||||
public EntersBattlefieldAbility(Effect effect, boolean optional, Condition condition, String abilityRule, String effectText) {
|
||||
super(Zone.ALL, new EntersBattlefieldEffect(effect, condition, effectText, true, optional));
|
||||
this.abilityRule = abilityRule;
|
||||
this.optional = optional;
|
||||
}
|
||||
|
||||
public EntersBattlefieldAbility(final EntersBattlefieldAbility ability) {
|
||||
super(ability);
|
||||
this.abilityRule = ability.abilityRule;
|
||||
this.optional = ability.optional;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -95,12 +105,9 @@ public class EntersBattlefieldAbility extends StaticAbility {
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
if (!ruleVisible) {
|
||||
return "";
|
||||
}
|
||||
if (abilityRule != null && !abilityRule.isEmpty()) {
|
||||
return abilityRule;
|
||||
}
|
||||
return "{this} enters the battlefield " + super.getRule();
|
||||
return (optional ? "you may have " : "") + "{this} enter" + (optional ? "" : "s") + " the battlefield " + super.getRule();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
|
@ -20,18 +20,17 @@
|
|||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.common;
|
||||
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.StaticAbility;
|
||||
import mage.abilities.effects.EntersBattlefieldEffect;
|
||||
import mage.abilities.effects.common.TapSourceEffect;
|
||||
import mage.constants.Zone;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -40,9 +39,9 @@ import mage.abilities.effects.common.TapSourceEffect;
|
|||
public class EntersBattlefieldTappedAbility extends StaticAbility {
|
||||
|
||||
private String ruleText;
|
||||
|
||||
|
||||
public EntersBattlefieldTappedAbility() {
|
||||
super(Zone.BATTLEFIELD, new EntersBattlefieldEffect(new TapSourceEffect(true)));
|
||||
super(Zone.ALL, new EntersBattlefieldEffect(new TapSourceEffect(true)));
|
||||
}
|
||||
|
||||
public EntersBattlefieldTappedAbility(String ruleText) {
|
||||
|
|
|
@ -78,7 +78,7 @@ public class LandfallAbility extends TriggeredAbilityImpl {
|
|||
&& permanent.getControllerId().equals(this.controllerId)) {
|
||||
triggeringLand = permanent;
|
||||
if (setTargetPointer.equals(SetTargetPointer.PERMANENT)) {
|
||||
for (Effect effect : getEffects()) {
|
||||
for (Effect effect : getAllEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(permanent, game));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.counters.CounterType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class PlanswalkerEntersWithLoyalityCountersAbility extends EntersBattlefieldAbility {
|
||||
|
||||
public PlanswalkerEntersWithLoyalityCountersAbility(int loyality) {
|
||||
super(new AddCountersSourceEffect(CounterType.LOYALTY.createInstance(loyality)));
|
||||
setRuleVisible(false);
|
||||
}
|
||||
|
||||
public PlanswalkerEntersWithLoyalityCountersAbility(final PlanswalkerEntersWithLoyalityCountersAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlanswalkerEntersWithLoyalityCountersAbility copy() {
|
||||
return new PlanswalkerEntersWithLoyalityCountersAbility(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.delayed.AtTheBeginOfNextCleanupDelayedTriggeredAbility;
|
||||
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
|
||||
import mage.abilities.effects.common.SacrificeSourceEffect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.stack.Spell;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Lonefox
|
||||
*/
|
||||
public class SacrificeIfCastAtInstantTimeTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public SacrificeIfCastAtInstantTimeTriggeredAbility() {
|
||||
super(Zone.STACK, new CreateDelayedTriggeredAbilityEffect(new AtTheBeginOfNextCleanupDelayedTriggeredAbility(new SacrificeSourceEffect())));
|
||||
}
|
||||
|
||||
public SacrificeIfCastAtInstantTimeTriggeredAbility(final SacrificeIfCastAtInstantTimeTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SacrificeIfCastAtInstantTimeTriggeredAbility copy() {
|
||||
return new SacrificeIfCastAtInstantTimeTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.SPELL_CAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
// The sacrifice occurs only if you cast it using its own ability. If you cast it using some other
|
||||
// effect (for instance, if it gained flash from Vedalken Orrery), then it won't be sacrificed.
|
||||
// CHECK
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell != null && spell.getSourceId().equals(getSourceId())) {
|
||||
return !(game.isMainPhase() && game.getActivePlayerId().equals(event.getPlayerId()) && game.getStack().size() == 1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "If you cast it any time a sorcery couldn't have been cast, the controller of the permanent it becomes sacrifices it at the beginning of the next cleanup step.";
|
||||
}
|
||||
}
|
||||
|
|
@ -27,13 +27,12 @@
|
|||
*/
|
||||
package mage.abilities.common.delayed;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.DelayedTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
|
@ -50,9 +49,9 @@ import mage.util.CardUtil;
|
|||
* Returns the exiled cards/permanents as source leaves battlefield
|
||||
*
|
||||
* Uses no stack
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class OnLeaveReturnExiledToBattlefieldAbility extends DelayedTriggeredAbility {
|
||||
|
||||
public OnLeaveReturnExiledToBattlefieldAbility() {
|
||||
|
@ -108,22 +107,12 @@ class ReturnExiledPermanentsEffect extends OneShotEffect {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (sourceObject != null && controller != null) {
|
||||
int zoneChangeCounter = (sourceObject instanceof PermanentToken) ? source.getSourceObjectZoneChangeCounter() : source.getSourceObjectZoneChangeCounter() -1;
|
||||
int zoneChangeCounter = (sourceObject instanceof PermanentToken) ? source.getSourceObjectZoneChangeCounter() : source.getSourceObjectZoneChangeCounter() - 1;
|
||||
UUID exileZone = CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter);
|
||||
if (exileZone != null) {
|
||||
ExileZone exile = game.getExile().getExileZone(exileZone);
|
||||
if (exile != null) {
|
||||
LinkedList<UUID> cards = new LinkedList<>(exile);
|
||||
for (UUID cardId : cards) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null) {
|
||||
Player owner = game.getPlayer(card.getOwnerId());
|
||||
if (owner != null && owner.isInGame()) {
|
||||
owner.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId());
|
||||
}
|
||||
}
|
||||
}
|
||||
exile.clear();
|
||||
controller.moveCards(new LinkedHashSet<>(exile.getCards(game)), Zone.BATTLEFIELD, source, game, false, false, true, null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -12,10 +12,14 @@ import mage.watchers.Watcher;
|
|||
* @author Loki
|
||||
*/
|
||||
public class CastFromHandCondition implements Condition {
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent p = game.getPermanent(source.getSourceId());
|
||||
if (p != null) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent == null) {
|
||||
permanent = game.getPermanentEntering(source.getSourceId());
|
||||
}
|
||||
if (permanent != null) {
|
||||
Watcher watcher = game.getState().getWatchers().get("CastFromHand", source.getSourceId());
|
||||
if (watcher != null && watcher.conditionMet()) {
|
||||
return true;
|
||||
|
@ -29,5 +33,4 @@ public class CastFromHandCondition implements Condition {
|
|||
return "you cast it from your hand";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
|
||||
package mage.abilities.condition.common;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.constants.CardType;
|
||||
|
@ -15,8 +13,8 @@ import mage.target.Target;
|
|||
* @author Jeff
|
||||
*/
|
||||
public class EnchantedTargetCondition implements Condition {
|
||||
|
||||
private static EnchantedTargetCondition fInstance = new EnchantedTargetCondition();
|
||||
|
||||
private static final EnchantedTargetCondition fInstance = new EnchantedTargetCondition();
|
||||
|
||||
public static Condition getInstance() {
|
||||
return fInstance;
|
||||
|
|
|
@ -49,4 +49,9 @@ public class MorbidCondition implements Condition {
|
|||
return watcher.conditionMet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "if a creature died this turn";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ import mage.abilities.condition.Condition;
|
|||
import mage.game.Game;
|
||||
|
||||
public class NotMyTurnCondition implements Condition {
|
||||
|
||||
|
||||
private static final NotMyTurnCondition fInstance = new NotMyTurnCondition();
|
||||
|
||||
public static Condition getInstance() {
|
||||
|
@ -48,4 +48,9 @@ public class NotMyTurnCondition implements Condition {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "if it's not your turn";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,11 +39,11 @@ import mage.game.Game;
|
|||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class OpponentControllsMoreCondition implements Condition {
|
||||
public class OpponentControlsMoreCondition implements Condition {
|
||||
|
||||
private final FilterPermanent filter;
|
||||
|
||||
public OpponentControllsMoreCondition(FilterPermanent filter) {
|
||||
public OpponentControlsMoreCondition(FilterPermanent filter) {
|
||||
this.filter = filter;
|
||||
}
|
||||
|
|
@ -25,20 +25,18 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.costs;
|
||||
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
* Alternative costs
|
||||
*
|
||||
*
|
||||
* @author LevelX2
|
||||
*
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
|
||||
public class AlternativeCost2Impl <T extends AlternativeCost2Impl<T>> extends CostsImpl<Cost> implements AlternativeCost2 {
|
||||
public class AlternativeCost2Impl<T extends AlternativeCost2Impl<T>> extends CostsImpl<Cost> implements AlternativeCost2 {
|
||||
|
||||
protected String name;
|
||||
protected String reminderText;
|
||||
|
@ -72,6 +70,7 @@ public class AlternativeCost2Impl <T extends AlternativeCost2Impl<T>> extends Co
|
|||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the complete text for the addional cost or if onlyCost is true
|
||||
* only the pure text for the included native cost
|
||||
|
@ -84,7 +83,7 @@ public class AlternativeCost2Impl <T extends AlternativeCost2Impl<T>> extends Co
|
|||
if (onlyCost) {
|
||||
return getText();
|
||||
} else {
|
||||
return new StringBuffer(name != null ? name: "").append(delimiter != null ? delimiter: "").append(getText()).toString();
|
||||
return (name != null ? name : "") + (delimiter != null ? delimiter : "") + getText();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,20 +102,20 @@ public class AlternativeCost2Impl <T extends AlternativeCost2Impl<T>> extends Co
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a text suffix for the game log, that can be added to
|
||||
* the cast message.
|
||||
* Returns a text suffix for the game log, that can be added to the cast
|
||||
* message.
|
||||
*
|
||||
* @param position - if there are multiple costs, it's the postion the cost is set (starting with 0)
|
||||
* @param position - if there are multiple costs, it's the postion the cost
|
||||
* is set (starting with 0)
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getCastSuffixMessage(int position) {
|
||||
StringBuilder sb = new StringBuilder(position > 0 ? " and ":"").append(" with ");
|
||||
StringBuilder sb = new StringBuilder(position > 0 ? " and " : "").append(" with ");
|
||||
sb.append(name);
|
||||
return sb.toString();
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If the player intends to pay the cost, the cost will be activated
|
||||
*
|
||||
|
@ -124,7 +123,7 @@ public class AlternativeCost2Impl <T extends AlternativeCost2Impl<T>> extends Co
|
|||
@Override
|
||||
public void activate() {
|
||||
activated = true;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the activate and count information
|
||||
|
@ -142,9 +141,11 @@ public class AlternativeCost2Impl <T extends AlternativeCost2Impl<T>> extends Co
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isActivated(Game game){
|
||||
public boolean isActivated(Game game) {
|
||||
return activated;
|
||||
};
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
@Override
|
||||
public AlternativeCost2Impl copy() {
|
||||
|
|
|
@ -29,6 +29,7 @@ package mage.abilities.costs;
|
|||
|
||||
import java.util.Iterator;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.StaticAbility;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
|
@ -39,6 +40,7 @@ import mage.constants.Zone;
|
|||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -145,28 +147,39 @@ public class AlternativeCostSourceAbility extends StaticAbility implements Alter
|
|||
}
|
||||
Player player = game.getPlayer(ability.getControllerId());
|
||||
if (player != null) {
|
||||
Costs<AlternativeCost2> alternativeCosts;
|
||||
Costs<AlternativeCost2> alternativeCostsToCheck;
|
||||
if (dynamicCost != null) {
|
||||
alternativeCosts = new CostsImpl<>();
|
||||
alternativeCosts.add(convertToAlternativeCost(dynamicCost.getCost(ability, game)));
|
||||
alternativeCostsToCheck = new CostsImpl<>();
|
||||
alternativeCostsToCheck.add(convertToAlternativeCost(dynamicCost.getCost(ability, game)));
|
||||
} else {
|
||||
alternativeCosts = this.alternateCosts;
|
||||
alternativeCostsToCheck = this.alternateCosts;
|
||||
}
|
||||
|
||||
String costChoiceText;
|
||||
if (dynamicCost != null) {
|
||||
costChoiceText = dynamicCost.getText(ability, game);
|
||||
} else {
|
||||
costChoiceText = alternativeCosts.isEmpty() ? "Cast without paying its mana cost?" : "Pay alternative costs? (" + alternativeCosts.getText() + ")";
|
||||
costChoiceText = alternativeCostsToCheck.isEmpty() ? "Cast without paying its mana cost?" : "Pay alternative costs? (" + alternativeCostsToCheck.getText() + ")";
|
||||
}
|
||||
|
||||
if (alternativeCosts.canPay(ability, ability.getSourceId(), ability.getControllerId(), game)
|
||||
if (alternativeCostsToCheck.canPay(ability, ability.getSourceId(), ability.getControllerId(), game)
|
||||
&& player.chooseUse(Outcome.Benefit, costChoiceText, this, game)) {
|
||||
ability.getManaCostsToPay().clear();
|
||||
if (ability instanceof SpellAbility) {
|
||||
for (Iterator<ManaCost> iterator = ability.getManaCostsToPay().iterator(); iterator.hasNext();) {
|
||||
ManaCost manaCost = iterator.next();
|
||||
if (manaCost instanceof VariableCost) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
CardUtil.reduceCost((SpellAbility) ability, ability.getManaCosts());
|
||||
|
||||
} else {
|
||||
ability.getManaCostsToPay().clear();
|
||||
}
|
||||
if (!onlyMana) {
|
||||
ability.getCosts().clear();
|
||||
}
|
||||
for (Cost cost : alternativeCosts) {
|
||||
for (Cost cost : alternativeCostsToCheck) {
|
||||
AlternativeCost2 alternateCost = (AlternativeCost2) cost;
|
||||
alternateCost.activate();
|
||||
for (Iterator it = ((Costs) alternateCost).iterator(); it.hasNext();) {
|
||||
|
@ -190,14 +203,14 @@ public class AlternativeCostSourceAbility extends StaticAbility implements Alter
|
|||
|
||||
@Override
|
||||
public boolean isActivated(Ability source, Game game) {
|
||||
Costs<AlternativeCost2> alternativeCosts;
|
||||
Costs<AlternativeCost2> alternativeCostsToCheck;
|
||||
if (dynamicCost != null) {
|
||||
alternativeCosts = new CostsImpl<>();
|
||||
alternativeCosts.add(convertToAlternativeCost(dynamicCost.getCost(source, game)));
|
||||
alternativeCostsToCheck = new CostsImpl<>();
|
||||
alternativeCostsToCheck.add(convertToAlternativeCost(dynamicCost.getCost(source, game)));
|
||||
} else {
|
||||
alternativeCosts = this.alternateCosts;
|
||||
alternativeCostsToCheck = this.alternateCosts;
|
||||
}
|
||||
for (AlternativeCost2 cost : alternativeCosts) {
|
||||
for (AlternativeCost2 cost : alternativeCostsToCheck) {
|
||||
if (cost.isActivated(game)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package mage.abilities.costs;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.game.Game;
|
||||
import mage.target.Targets;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class CompositeCost implements Cost {
|
||||
private Cost firstCost;
|
||||
private Cost secondCost;
|
||||
|
||||
private final Cost firstCost;
|
||||
private final Cost secondCost;
|
||||
private String description;
|
||||
|
||||
public CompositeCost(Cost firstCost, Cost secondCost, String description) {
|
||||
|
@ -28,6 +28,11 @@ public class CompositeCost implements Cost {
|
|||
throw new RuntimeException("Not supported method");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(String text) {
|
||||
this.description = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return description;
|
||||
|
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.costs;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -37,12 +36,21 @@ import mage.target.Targets;
|
|||
public interface Cost extends Serializable {
|
||||
|
||||
UUID getId();
|
||||
|
||||
String getText();
|
||||
|
||||
void setText(String text);
|
||||
|
||||
boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game);
|
||||
|
||||
boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana);
|
||||
|
||||
boolean isPaid();
|
||||
|
||||
void clearPaid();
|
||||
|
||||
void setPaid();
|
||||
|
||||
Targets getTargets();
|
||||
|
||||
Cost copy();
|
||||
|
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.costs;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -57,6 +56,7 @@ public abstract class CostImpl implements Cost {
|
|||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.costs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -44,12 +43,16 @@ import mage.target.Targets;
|
|||
*/
|
||||
public class CostsImpl<T extends Cost> extends ArrayList<T> implements Costs<T> {
|
||||
|
||||
public CostsImpl() {}
|
||||
protected String text = null;
|
||||
|
||||
public CostsImpl() {
|
||||
}
|
||||
|
||||
public CostsImpl(final CostsImpl<T> costs) {
|
||||
for (Cost cost: costs) {
|
||||
this.add((T)cost.copy());
|
||||
for (Cost cost : costs) {
|
||||
this.add((T) cost.copy());
|
||||
}
|
||||
this.text = costs.text;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -57,20 +60,28 @@ public class CostsImpl<T extends Cost> extends ArrayList<T> implements Costs<T>
|
|||
throw new RuntimeException("Not supported method");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
if (text != null) {
|
||||
return text;
|
||||
}
|
||||
if (this.size() == 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
StringBuilder sbText = new StringBuilder();
|
||||
for (T cost: this) {
|
||||
String text = cost.getText();
|
||||
if (text != null && !text.isEmpty()) {
|
||||
sbText.append(Character.toUpperCase(text.charAt(0))).append(text.substring(1)).append(", ");
|
||||
for (T cost : this) {
|
||||
String textCost = cost.getText();
|
||||
if (textCost != null && !textCost.isEmpty()) {
|
||||
sbText.append(Character.toUpperCase(textCost.charAt(0))).append(textCost.substring(1)).append(", ");
|
||||
}
|
||||
}
|
||||
if (sbText.length() > 1){
|
||||
if (sbText.length() > 1) {
|
||||
sbText.setLength(sbText.length() - 2);
|
||||
}
|
||||
return sbText.toString();
|
||||
|
@ -78,7 +89,7 @@ public class CostsImpl<T extends Cost> extends ArrayList<T> implements Costs<T>
|
|||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
for (T cost: this) {
|
||||
for (T cost : this) {
|
||||
if (!cost.canPay(ability, sourceId, controllerId, game)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -101,7 +112,7 @@ public class CostsImpl<T extends Cost> extends ArrayList<T> implements Costs<T>
|
|||
|
||||
@Override
|
||||
public boolean isPaid() {
|
||||
for (T cost: this) {
|
||||
for (T cost : this) {
|
||||
if (!(cost instanceof VariableManaCost) && !cost.isPaid()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -111,14 +122,14 @@ public class CostsImpl<T extends Cost> extends ArrayList<T> implements Costs<T>
|
|||
|
||||
@Override
|
||||
public void clearPaid() {
|
||||
for (T cost: this) {
|
||||
for (T cost : this) {
|
||||
cost.clearPaid();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPaid() {
|
||||
for (T cost: this) {
|
||||
for (T cost : this) {
|
||||
cost.setPaid();
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +137,7 @@ public class CostsImpl<T extends Cost> extends ArrayList<T> implements Costs<T>
|
|||
@Override
|
||||
public Costs<T> getUnpaid() {
|
||||
Costs<T> unpaid = new CostsImpl<>();
|
||||
for (T cost: this) {
|
||||
for (T cost : this) {
|
||||
if (!cost.isPaid()) {
|
||||
unpaid.add(cost);
|
||||
}
|
||||
|
@ -140,17 +151,17 @@ public class CostsImpl<T extends Cost> extends ArrayList<T> implements Costs<T>
|
|||
return unpaid.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VariableCost> getVariableCosts() {
|
||||
List<VariableCost> variableCosts = new ArrayList<>();
|
||||
for (T cost: this) {
|
||||
for (T cost : this) {
|
||||
if (cost instanceof VariableCost) {
|
||||
variableCosts.add((VariableCost) cost);
|
||||
}
|
||||
if (cost instanceof ManaCosts) {
|
||||
variableCosts.addAll(((ManaCosts)cost).getVariableCosts());
|
||||
variableCosts.addAll(((ManaCosts) cost).getVariableCosts());
|
||||
}
|
||||
}
|
||||
return variableCosts;
|
||||
|
@ -159,7 +170,7 @@ public class CostsImpl<T extends Cost> extends ArrayList<T> implements Costs<T>
|
|||
@Override
|
||||
public Targets getTargets() {
|
||||
Targets targets = new Targets();
|
||||
for (T cost: this) {
|
||||
for (T cost : this) {
|
||||
if (cost.getTargets() != null) {
|
||||
targets.addAll(cost.getTargets());
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class OptionalAdditionalCostImpl<T extends OptionalAdditionalCostImpl> ex
|
|||
this.activated = false;
|
||||
this.name = name;
|
||||
this.delimiter = delimiter;
|
||||
this.reminderText = new StringBuilder("<i>").append(reminderText).append("</i>").toString();
|
||||
this.reminderText = "<i>(" + reminderText + ")</i>";
|
||||
this.activatedCounter = 0;
|
||||
this.add((Cost) cost);
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public class OptionalAdditionalCostImpl<T extends OptionalAdditionalCostImpl> ex
|
|||
if (onlyCost) {
|
||||
return getText();
|
||||
} else {
|
||||
return new StringBuffer(name).append(delimiter).append(getText()).toString();
|
||||
return name + delimiter + getText();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,8 +37,8 @@ import mage.target.Targets;
|
|||
|
||||
public class OrCost implements Cost {
|
||||
|
||||
private Cost firstCost;
|
||||
private Cost secondCost;
|
||||
private final Cost firstCost;
|
||||
private final Cost secondCost;
|
||||
private String description;
|
||||
// which cost was slected to pay
|
||||
private Cost selectedCost;
|
||||
|
@ -61,6 +61,11 @@ public class OrCost implements Cost {
|
|||
throw new RuntimeException("Not supported method");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(String text) {
|
||||
this.description = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return description;
|
||||
|
|
|
@ -77,6 +77,11 @@ public abstract class VariableCostImpl implements Cost, VariableCost {
|
|||
this.amountPaid = cost.amountPaid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return text;
|
||||
|
@ -157,8 +162,7 @@ public abstract class VariableCostImpl implements Cost, VariableCost {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
xValue = controller.announceXCost(getMinValue(source, game), getMaxValue(source, game),
|
||||
new StringBuilder("Announce the number of ").append(actionText).toString(),
|
||||
game, source, this);
|
||||
"Announce the number of " + actionText, game, source, this);
|
||||
}
|
||||
return xValue;
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
|
@ -20,21 +20,20 @@
|
|||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.costs.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.constants.Outcome;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.CostImpl;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInHand;
|
||||
|
@ -44,47 +43,46 @@ import mage.target.common.TargetCardInHand;
|
|||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class DiscardTargetCost extends CostImpl {
|
||||
|
||||
|
||||
List<Card> cards = new ArrayList<>();
|
||||
protected boolean randomDiscard;
|
||||
|
||||
public DiscardTargetCost(TargetCardInHand target) {
|
||||
this(target, false);
|
||||
}
|
||||
|
||||
|
||||
public DiscardTargetCost(TargetCardInHand target, boolean randomDiscard) {
|
||||
this.addTarget(target);
|
||||
this.randomDiscard = randomDiscard;
|
||||
this.text = "Discard " + target.getTargetName();
|
||||
this.text = "discard " + target.getTargetName();
|
||||
}
|
||||
|
||||
public DiscardTargetCost(DiscardTargetCost cost) {
|
||||
super(cost);
|
||||
for (Card card: cost.cards) {
|
||||
this.cards.add(card.copy());
|
||||
}
|
||||
this.cards.addAll(cost.cards);
|
||||
this.randomDiscard = cost.randomDiscard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
|
||||
this.cards.clear();
|
||||
this.targets.clearChosen();;
|
||||
Player player = game.getPlayer(controllerId);
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
int amount = this.getTargets().get(0).getNumberOfTargets();
|
||||
if (randomDiscard) {
|
||||
if (randomDiscard) {
|
||||
this.cards.addAll(player.discard(amount, true, ability, game).getCards(game));
|
||||
} else {
|
||||
if (targets.choose(Outcome.Discard, controllerId, sourceId, game)) {
|
||||
for (UUID targetId: targets.get(0).getTargets()) {
|
||||
if (targets.choose(Outcome.Discard, controllerId, sourceId, game)) {
|
||||
for (UUID targetId : targets.get(0).getTargets()) {
|
||||
Card card = player.getHand().get(targetId, game);
|
||||
if (card == null) {
|
||||
return false;
|
||||
}
|
||||
player.discard(card, ability, game);
|
||||
this.cards.add(card.copy());
|
||||
this.cards.add(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -94,8 +92,9 @@ public class DiscardTargetCost extends CostImpl {
|
|||
|
||||
@Override
|
||||
public void clearPaid() {
|
||||
super.clearPaid();
|
||||
cards.clear();
|
||||
super.clearPaid();
|
||||
this.cards.clear();
|
||||
this.targets.clearChosen();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -84,6 +84,9 @@ public class RemoveCounterCost extends CostImpl {
|
|||
int countersRemoved = 0;
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
if (countersToRemove == 0) { // Can happen when used for X costs where X = 0;
|
||||
return paid = true;
|
||||
}
|
||||
target.clearChosen();
|
||||
if (target.choose(Outcome.UnboostCreature, controllerId, sourceId, game)) {
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
|
|
|
@ -76,7 +76,7 @@ public class TapTargetCost extends CostImpl {
|
|||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
return target.canChoose(controllerId, game);
|
||||
return target.canChoose(sourceId, controllerId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -51,6 +51,7 @@ import mage.util.ManaUtil;
|
|||
public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements ManaCosts<T> {
|
||||
|
||||
protected UUID id;
|
||||
protected String text = null;
|
||||
|
||||
private static Map<String, ManaCosts> costs = new HashMap<>();
|
||||
|
||||
|
@ -372,8 +373,16 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
|
|||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
if (text != null) {
|
||||
return text;
|
||||
}
|
||||
if (this.size() == 0) {
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ import mage.game.events.GameEvent;
|
|||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class ConditionalContinuousRuleModifyingEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
public class ConditionalContinuousRuleModifyingEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
|
||||
protected ContinuousRuleModifyingEffect effect;
|
||||
protected ContinuousRuleModifyingEffect otherwiseEffect;
|
||||
|
@ -88,7 +88,6 @@ public class ConditionalContinuousRuleModifyingEffect extends ContinuousRuleModi
|
|||
initDone = true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isDiscarded() {
|
||||
return effect.isDiscarded() || (otherwiseEffect != null && otherwiseEffect.isDiscarded());
|
||||
|
@ -136,4 +135,20 @@ public class ConditionalContinuousRuleModifyingEffect extends ContinuousRuleModi
|
|||
public ConditionalContinuousRuleModifyingEffect copy() {
|
||||
return new ConditionalContinuousRuleModifyingEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sendMessageToGameLog() {
|
||||
return effect.sendMessageToGameLog(); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sendMessageToUser() {
|
||||
return effect.sendMessageToUser(); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessage(Ability source, GameEvent event, Game game) {
|
||||
return effect.getInfoMessage(source, event, game); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.dynamicvalue.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.game.Game;
|
||||
import mage.watchers.common.CreaturesDiedWatcher;
|
||||
|
||||
/**
|
||||
* @author LoneFox
|
||||
*/
|
||||
public class CreaturesDiedThisTurnCount implements DynamicValue {
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
CreaturesDiedWatcher watcher = (CreaturesDiedWatcher)game.getState().getWatchers().get("CreaturesDiedWatcher");
|
||||
if (watcher != null) {
|
||||
return watcher.getAmountOfCreaturesDiesThisTurn();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreaturesDiedThisTurnCount copy() {
|
||||
return new CreaturesDiedThisTurnCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "X";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "creature that died this turn";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
|
@ -20,17 +20,16 @@
|
|||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.AsThoughEffectType;
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.AsThoughEffectType;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
|
@ -40,7 +39,9 @@ import mage.game.Game;
|
|||
public interface AsThoughEffect extends ContinuousEffect {
|
||||
|
||||
boolean applies(UUID sourceId, Ability affectedAbility, Ability source, Game game);
|
||||
|
||||
boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game);
|
||||
|
||||
AsThoughEffectType getAsThoughEffectType();
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
|
@ -20,12 +20,11 @@
|
|||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -54,7 +53,7 @@ public abstract class AsThoughEffectImpl extends ContinuousEffectImpl implements
|
|||
super(effect);
|
||||
this.type = effect.type;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game) {
|
||||
return applies(objectId, source, affectedAbility.getControllerId(), game);
|
||||
|
|
45
Mage/src/mage/abilities/effects/AsThoughManaEffect.java
Normal file
45
Mage/src/mage/abilities/effects/AsThoughManaEffect.java
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.effects;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.ManaType;
|
||||
import mage.game.Game;
|
||||
import mage.players.ManaPoolItem;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public interface AsThoughManaEffect extends AsThoughEffect {
|
||||
|
||||
// return a mana type that can be used to pay a mana cost instead of the normally needed mana type
|
||||
ManaType getAsThoughManaType(ManaType manaType, ManaPoolItem mana, UUID affectedControllerId, Ability source, Game game);
|
||||
|
||||
}
|
|
@ -36,13 +36,13 @@ import mage.cards.Card;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SpellAbilityType;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.PermanentCard;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackAbility;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
|
@ -103,12 +103,12 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
|
|||
UUID targetId = null;
|
||||
MageObject sourceObject = game.getObject(sourceId);
|
||||
boolean enchantCardInGraveyard = false;
|
||||
if (sourceObject instanceof Spell) {
|
||||
if (fromZone.equals(Zone.EXILED)) {
|
||||
// cast from exile (e.g. Neightveil Spector) -> no replacement
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// if (sourceObject instanceof Spell) {
|
||||
// if (fromZone.equals(Zone.EXILED)) {
|
||||
// // cast from exile (e.g. Neightveil Spector) -> no replacement
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
if (sourceObject instanceof StackAbility) {
|
||||
StackAbility stackAbility = (StackAbility) sourceObject;
|
||||
if (!stackAbility.getEffects().isEmpty()) {
|
||||
|
@ -118,25 +118,34 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
|
|||
|
||||
game.applyEffects(); // So continuousEffects are removed if previous effect of the same ability did move objects that cuase continuous effects
|
||||
if (targetId == null) {
|
||||
Target target = card.getSpellAbility().getTargets().get(0).copy();
|
||||
SpellAbility spellAbility = card.getSpellAbility();
|
||||
if (spellAbility.getTargets().isEmpty()) {
|
||||
for (Ability ability : card.getAbilities(game)) {
|
||||
if ((ability instanceof SpellAbility)
|
||||
&& SpellAbilityType.BASE_ALTERNATE.equals(((SpellAbility) ability).getSpellAbilityType())
|
||||
&& !ability.getTargets().isEmpty()) {
|
||||
spellAbility = (SpellAbility) ability;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (spellAbility.getTargets().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
Target target = spellAbility.getTargets().get(0).copy();
|
||||
Outcome auraOutcome = Outcome.BoostCreature;
|
||||
for (Effect effect : spellAbility.getEffects()) {
|
||||
if (effect instanceof AttachEffect) {
|
||||
auraOutcome = effect.getOutcome();
|
||||
break;
|
||||
}
|
||||
}
|
||||
enchantCardInGraveyard = target instanceof TargetCardInGraveyard;
|
||||
if (target != null) {
|
||||
target.setNotTarget(true); // always not target because this way it's not handled targeted
|
||||
target.clearChosen(); // neccessary if e.g. aura is blinked multiple times
|
||||
}
|
||||
Player player = game.getPlayer(card.getOwnerId());
|
||||
Outcome auraOutcome = Outcome.BoostCreature;
|
||||
Ability:
|
||||
for (Ability ability : card.getAbilities()) {
|
||||
if (ability instanceof SpellAbility) {
|
||||
for (Effect effect : ability.getEffects()) {
|
||||
if (effect instanceof AttachEffect) {
|
||||
auraOutcome = effect.getOutcome();
|
||||
break Ability;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (target != null && player != null && player.choose(auraOutcome, target, card.getId(), game)) {
|
||||
targetId = target.getFirstTarget();
|
||||
}
|
||||
|
@ -151,44 +160,27 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
|
|||
}
|
||||
Player targetPlayer = game.getPlayer(targetId);
|
||||
if (targetCard != null || targetPermanent != null || targetPlayer != null) {
|
||||
switch (fromZone) {
|
||||
case EXILED:
|
||||
game.getExile().removeCard(card, game);
|
||||
break;
|
||||
case GRAVEYARD:
|
||||
game.getPlayer(card.getOwnerId()).removeFromGraveyard(card, game);
|
||||
break;
|
||||
case HAND:
|
||||
game.getPlayer(card.getOwnerId()).removeFromHand(card, game);
|
||||
break;
|
||||
case LIBRARY:
|
||||
game.getPlayer(card.getOwnerId()).removeFromLibrary(card, game);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
game.rememberLKI(card.getId(), fromZone, card);
|
||||
|
||||
card.removeFromZone(game, fromZone, sourceId);
|
||||
card.updateZoneChangeCounter(game);
|
||||
PermanentCard permanent = new PermanentCard(card, card.getOwnerId(), game);
|
||||
game.getBattlefield().addPermanent(permanent);
|
||||
card.setZone(Zone.BATTLEFIELD, game);
|
||||
boolean entered = permanent.entersBattlefield(event.getSourceId(), game, fromZone, true);
|
||||
game.applyEffects();
|
||||
if (!entered) {
|
||||
return false;
|
||||
}
|
||||
game.fireEvent(new ZoneChangeEvent(permanent, controllerId, fromZone, Zone.BATTLEFIELD));
|
||||
if (permanent.entersBattlefield(event.getSourceId(), game, fromZone, true)) {
|
||||
if (targetCard != null) {
|
||||
permanent.attachTo(targetCard.getId(), game);
|
||||
} else if (targetPermanent != null) {
|
||||
targetPermanent.addAttachment(permanent.getId(), game);
|
||||
} else if (targetPlayer != null) {
|
||||
targetPlayer.addAttachment(permanent.getId(), game);
|
||||
}
|
||||
game.applyEffects();
|
||||
|
||||
if (targetCard != null) {
|
||||
permanent.attachTo(targetCard.getId(), game);
|
||||
}
|
||||
if (targetPermanent != null) {
|
||||
targetPermanent.addAttachment(permanent.getId(), game);
|
||||
}
|
||||
if (targetPlayer != null) {
|
||||
targetPlayer.addAttachment(permanent.getId(), game);
|
||||
game.fireEvent(new ZoneChangeEvent(permanent, controllerId, fromZone, Zone.BATTLEFIELD));
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -199,7 +191,7 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (((ZoneChangeEvent) event).getToZone().equals(Zone.BATTLEFIELD)
|
||||
&& !(((ZoneChangeEvent) event).getFromZone().equals(Zone.HAND))) {
|
||||
&& !(((ZoneChangeEvent) event).getFromZone().equals(Zone.STACK))) {
|
||||
Card card = game.getCard(event.getTargetId());
|
||||
if (card != null && card.getCardType().contains(CardType.ENCHANTMENT) && card.hasSubtype("Aura")) {
|
||||
return true;
|
||||
|
|
|
@ -55,6 +55,7 @@ import mage.constants.CostModificationType;
|
|||
import mage.constants.Duration;
|
||||
import mage.constants.EffectType;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.ManaType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SpellAbilityType;
|
||||
import mage.constants.SubLayer;
|
||||
|
@ -70,6 +71,7 @@ import mage.game.events.ZoneChangeEvent;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.PermanentCard;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.players.ManaPoolItem;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInHand;
|
||||
import org.apache.log4j.Logger;
|
||||
|
@ -546,6 +548,37 @@ public class ContinuousEffects implements Serializable {
|
|||
|
||||
}
|
||||
|
||||
public ManaType asThoughMana(ManaType manaType, ManaPoolItem mana, UUID objectId, Ability affectedAbility, UUID controllerId, Game game) {
|
||||
// First check existing only effects
|
||||
List<AsThoughEffect> asThoughEffectsList = getApplicableAsThoughEffects(AsThoughEffectType.SPEND_ONLY_MANA, game);
|
||||
for (AsThoughEffect effect : asThoughEffectsList) {
|
||||
HashSet<Ability> abilities = asThoughEffectsMap.get(AsThoughEffectType.SPEND_ONLY_MANA).getAbility(effect.getId());
|
||||
for (Ability ability : abilities) {
|
||||
if ((affectedAbility == null && effect.applies(objectId, ability, controllerId, game))
|
||||
|| effect.applies(objectId, affectedAbility, ability, game)) {
|
||||
if (((AsThoughManaEffect) effect).getAsThoughManaType(manaType, mana, controllerId, ability, game) == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// then check effects that allow to use other mana types to pay the current mana type to pay
|
||||
asThoughEffectsList = getApplicableAsThoughEffects(AsThoughEffectType.SPEND_OTHER_MANA, game);
|
||||
for (AsThoughEffect effect : asThoughEffectsList) {
|
||||
HashSet<Ability> abilities = asThoughEffectsMap.get(AsThoughEffectType.SPEND_OTHER_MANA).getAbility(effect.getId());
|
||||
for (Ability ability : abilities) {
|
||||
if ((affectedAbility == null && effect.applies(objectId, ability, controllerId, game))
|
||||
|| effect.applies(objectId, affectedAbility, ability, game)) {
|
||||
ManaType usableManaType = ((AsThoughManaEffect) effect).getAsThoughManaType(manaType, mana, controllerId, ability, game);
|
||||
if (usableManaType != null) {
|
||||
return usableManaType;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return manaType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters out asThough effects that are not active.
|
||||
*
|
||||
|
@ -843,8 +876,10 @@ public class ContinuousEffects implements Serializable {
|
|||
}
|
||||
}
|
||||
// Must be called here for some effects to be able to work correctly
|
||||
// TODO: add info which effects need that call
|
||||
game.applyEffects();
|
||||
// For example: Vesuva copying a Dark Depth (VesuvaTest:testDarkDepth)
|
||||
// This call should be removed if possible as replacement effects of EntersTheBattlefield events
|
||||
// do no longer work correctly because the entering permanents are not yet on the battlefield (before they were).
|
||||
// game.applyEffects();
|
||||
} while (true);
|
||||
return caught;
|
||||
}
|
||||
|
@ -1114,18 +1149,18 @@ public class ContinuousEffects implements Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
private void setControllerForEffect(ContinuousEffectsList<?> effects, UUID cardId, UUID controllerId) {
|
||||
private void setControllerForEffect(ContinuousEffectsList<?> effects, UUID sourceId, UUID controllerId) {
|
||||
for (Effect effect : effects) {
|
||||
HashSet<Ability> abilities = effects.getAbility(effect.getId());
|
||||
if (abilities != null) {
|
||||
for (Ability ability : abilities) {
|
||||
if (ability.getSourceId() != null) {
|
||||
if (ability.getSourceId().equals(cardId)) {
|
||||
if (ability.getSourceId().equals(sourceId)) {
|
||||
ability.setControllerId(controllerId);
|
||||
}
|
||||
} else {
|
||||
if (!ability.getZone().equals(Zone.COMMAND)) {
|
||||
logger.fatal(new StringBuilder("No sourceId Ability: ").append(ability));
|
||||
logger.fatal("Continuous effect for ability with no sourceId Ability: " + ability);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1213,7 +1248,7 @@ public class ContinuousEffects implements Serializable {
|
|||
HashSet<Ability> abilities = preventionEffects.getAbility(effect.getId());
|
||||
for (Ability ability : abilities) {
|
||||
if (ability.getSourceId().equals(sourceId)) {
|
||||
if (controllerFound == null || controllerFound == ability.getControllerId()) {
|
||||
if (controllerFound == null || controllerFound.equals(ability.getControllerId())) {
|
||||
controllerFound = ability.getControllerId();
|
||||
} else {
|
||||
// not unique controller - No solution yet
|
||||
|
@ -1227,7 +1262,7 @@ public class ContinuousEffects implements Serializable {
|
|||
for (Ability ability : abilities) {
|
||||
if (ability.getSourceId() != null) {
|
||||
if (ability.getSourceId().equals(sourceId)) {
|
||||
if (controllerFound == null || controllerFound == ability.getControllerId()) {
|
||||
if (controllerFound == null || controllerFound.equals(ability.getControllerId())) {
|
||||
controllerFound = ability.getControllerId();
|
||||
} else {
|
||||
// not unique controller - No solution yet
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
/*
|
||||
* Copyright 2012 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL , EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
* Copyright 2012 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL , EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.effects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -46,18 +46,19 @@ import org.apache.log4j.Logger;
|
|||
* @param <T>
|
||||
*/
|
||||
public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList<T> {
|
||||
|
||||
|
||||
private static final Logger logger = Logger.getLogger(ContinuousEffectsList.class);
|
||||
|
||||
// the effectAbilityMap holds for each effect all abilities that are connected (used) with this effect
|
||||
private final Map<UUID, HashSet<Ability>> effectAbilityMap = new HashMap<>();
|
||||
|
||||
public ContinuousEffectsList() { }
|
||||
public ContinuousEffectsList() {
|
||||
}
|
||||
|
||||
public ContinuousEffectsList(final ContinuousEffectsList<T> effects) {
|
||||
this.ensureCapacity(effects.size());
|
||||
for (ContinuousEffect cost: effects) {
|
||||
this.add((T)cost.copy());
|
||||
for (ContinuousEffect cost : effects) {
|
||||
this.add((T) cost.copy());
|
||||
}
|
||||
for (Map.Entry<UUID, HashSet<Ability>> entry : effects.effectAbilityMap.entrySet()) {
|
||||
HashSet<Ability> newSet = new HashSet<>();
|
||||
|
@ -113,12 +114,12 @@ public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList
|
|||
Ability ability = it.next();
|
||||
if (ability == null) {
|
||||
it.remove();
|
||||
} else if (ability instanceof MageSingleton) {
|
||||
} else if (ability instanceof MageSingleton) {
|
||||
return false;
|
||||
} else if (effect.isDiscarded()) {
|
||||
} else if (effect.isDiscarded()) {
|
||||
it.remove();
|
||||
} else {
|
||||
switch(effect.getDuration()) {
|
||||
switch (effect.getDuration()) {
|
||||
case WhileOnBattlefield:
|
||||
case WhileInGraveyard:
|
||||
case WhileOnStack:
|
||||
|
@ -133,8 +134,8 @@ public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList
|
|||
break;
|
||||
case Custom:
|
||||
case UntilYourNextTurn:
|
||||
if (effect.isInactive(ability , game)) {
|
||||
it.remove();
|
||||
if (effect.isInactive(ability, game)) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -143,9 +144,9 @@ public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList
|
|||
}
|
||||
|
||||
/**
|
||||
* Adds an effect and its connected ability to the list.
|
||||
* For each effect will be stored, which abilities are connected to the effect.
|
||||
* So an effect can be connected to multiple abilities.
|
||||
* Adds an effect and its connected ability to the list. For each effect
|
||||
* will be stored, which abilities are connected to the effect. So an effect
|
||||
* can be connected to multiple abilities.
|
||||
*
|
||||
* @param effect - effect to add
|
||||
* @param source - connected ability
|
||||
|
@ -153,8 +154,8 @@ public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList
|
|||
public void addEffect(T effect, Ability source) {
|
||||
if (effectAbilityMap.containsKey(effect.getId())) {
|
||||
HashSet<Ability> set = effectAbilityMap.get(effect.getId());
|
||||
for (Ability ability: set) {
|
||||
if (ability.getId().equals(source.getId()) && ability.getSourceId().equals(source.getSourceId()) ) {
|
||||
for (Ability ability : set) {
|
||||
if (ability.getId().equals(source.getId()) && ability.getSourceId().equals(source.getSourceId())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.effects;
|
||||
|
||||
import mage.MageObject;
|
||||
|
@ -45,20 +44,18 @@ public abstract class ContinuousRuleModifyingEffectImpl extends ContinuousEffect
|
|||
protected final boolean messageToUser;
|
||||
protected final boolean messageToGameLog;
|
||||
protected final String infoMessage;
|
||||
|
||||
|
||||
// 613.10
|
||||
// Some continuous effects affect game rules rather than objects. For example, effects may modify
|
||||
// Some continuous effects affect game rules rather than objects. For example, effects may modify
|
||||
// a players maximum hand size, or say that a creature must attack this turn if able. These effects
|
||||
// are applied after all other continuous effects have been applied. Continuous effects that affect
|
||||
// the costs of spells or abilities are applied according to the order specified in rule 601.2e.
|
||||
// All other such effects are applied in timestamp order. See also the rules for timestamp order
|
||||
// the costs of spells or abilities are applied according to the order specified in rule 601.2e.
|
||||
// All other such effects are applied in timestamp order. See also the rules for timestamp order
|
||||
// and dependency (rules 613.6 and 613.7).
|
||||
|
||||
// Some of this rule modifying effects are implemented as normal CONTINUOUS effects using the Layer.RulesEffects.
|
||||
// But if the rule change can be implemented simply by preventing an event from happening, CONTINUOUS_RULE_MODIFICATION effects can be used.
|
||||
// They work technical like a replacement effect that replaces the event completely.
|
||||
// They work technical like a replacement effect that replaces the event completely.
|
||||
// But player isn't asked to choose order of effects if multiple are applied to the same event.
|
||||
|
||||
public ContinuousRuleModifyingEffectImpl(Duration duration, Outcome outcome) {
|
||||
this(duration, outcome, true, false);
|
||||
}
|
||||
|
@ -67,11 +64,13 @@ public abstract class ContinuousRuleModifyingEffectImpl extends ContinuousEffect
|
|||
*
|
||||
* @param duration
|
||||
* @param outcome
|
||||
* @param messageToUser - Every time the effect replaces an event, the user gets a message in a dialog window.
|
||||
* Don't set it to true if the event happens regularly or very often. The message itself can be
|
||||
* changed by overriding the getInfoMessage method.
|
||||
* @param messageToLog - Every time the effect replaces an event, a message is posted to the game log. The message
|
||||
* can be changed by overriding the getInfoMessage method.
|
||||
* @param messageToUser - Every time the effect replaces an event, the user
|
||||
* gets a message in a dialog window. Don't set it to true if the event
|
||||
* happens regularly or very often. The message itself can be changed by
|
||||
* overriding the getInfoMessage method.
|
||||
* @param messageToLog - Every time the effect replaces an event, a message
|
||||
* is posted to the game log. The message can be changed by overriding the
|
||||
* getInfoMessage method.
|
||||
*/
|
||||
public ContinuousRuleModifyingEffectImpl(Duration duration, Outcome outcome, boolean messageToUser, boolean messageToLog) {
|
||||
super(duration, outcome);
|
||||
|
@ -89,9 +88,11 @@ public abstract class ContinuousRuleModifyingEffectImpl extends ContinuousEffect
|
|||
}
|
||||
|
||||
/**
|
||||
* An early check for the event types this effect applies to. This check was added
|
||||
* to speed up event handling. Once all existing ContinuousRuleModifiyingEffects have
|
||||
* implemented this method, the method should be changed to abstract here or removed.
|
||||
* An early check for the event types this effect applies to. This check was
|
||||
* added to speed up event handling. Once all existing
|
||||
* ContinuousRuleModifiyingEffects have implemented this method, the method
|
||||
* should be changed to abstract here or removed.
|
||||
*
|
||||
* @param event
|
||||
* @param game
|
||||
* @return
|
||||
|
@ -112,10 +113,10 @@ public abstract class ContinuousRuleModifyingEffectImpl extends ContinuousEffect
|
|||
String message;
|
||||
MageObject object = game.getObject(source.getSourceId());
|
||||
if (object != null) {
|
||||
message = source.getRule(object.getLogName());
|
||||
message = source.getRule(messageToUser ? object.getIdName() : object.getLogName());
|
||||
} else {
|
||||
message = source.getRule();
|
||||
}
|
||||
}
|
||||
return message;
|
||||
} else {
|
||||
return infoMessage;
|
||||
|
@ -132,5 +133,4 @@ public abstract class ContinuousRuleModifyingEffectImpl extends ContinuousEffect
|
|||
return messageToGameLog;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,42 +1,43 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.effects;
|
||||
|
||||
import mage.constants.Duration;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
|
@ -64,10 +65,6 @@ public class EntersBattlefieldEffect extends ReplacementEffectImpl {
|
|||
this(baseEffect, null, text, true, optional);
|
||||
}
|
||||
|
||||
public EntersBattlefieldEffect(Effect baseEffect, Condition condition, String text) {
|
||||
this(baseEffect, condition, text, true, false);
|
||||
}
|
||||
|
||||
public EntersBattlefieldEffect(Effect baseEffect, Condition condition, String text, boolean selfScope, boolean optional) {
|
||||
super(Duration.WhileOnBattlefield, baseEffect.getOutcome(), selfScope);
|
||||
this.baseEffects.add(baseEffect);
|
||||
|
@ -111,24 +108,29 @@ public class EntersBattlefieldEffect extends ReplacementEffectImpl {
|
|||
if (controller == null || object == null) {
|
||||
return false;
|
||||
}
|
||||
if (!controller.chooseUse(outcome, new StringBuilder("Use effect of ").append(object.getLogName()).append("?").toString(), source, game)) {
|
||||
if (!controller.chooseUse(outcome, "Use effect of " + object.getLogName() + "?", source, game)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Spell spell = game.getStack().getSpell(event.getSourceId());
|
||||
for (Effect effect: baseEffects) {
|
||||
if (source.activate(game, false)) {
|
||||
if (effect instanceof ContinuousEffect) {
|
||||
game.addEffect((ContinuousEffect) effect, source);
|
||||
}
|
||||
else {
|
||||
if (spell != null) {
|
||||
effect.setValue(SOURCE_CAST_SPELL_ABILITY, spell.getSpellAbility());
|
||||
}
|
||||
effect.apply(game, source);
|
||||
}
|
||||
if (spell == null) {
|
||||
StackObject stackObject = (StackObject) game.getLastKnownInformation(event.getSourceId(), Zone.STACK);
|
||||
if (stackObject instanceof Spell) {
|
||||
spell = (Spell) stackObject;
|
||||
}
|
||||
}
|
||||
for (Effect effect : baseEffects) {
|
||||
// if (source.activate(game, false)) { // Why is this needed????
|
||||
if (effect instanceof ContinuousEffect) {
|
||||
game.addEffect((ContinuousEffect) effect, source);
|
||||
} else {
|
||||
if (spell != null) {
|
||||
effect.setValue(SOURCE_CAST_SPELL_ABILITY, spell.getSpellAbility());
|
||||
}
|
||||
effect.apply(game, source);
|
||||
}
|
||||
// }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
|
@ -20,12 +20,11 @@
|
|||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
@ -46,36 +45,67 @@ import mage.target.Target;
|
|||
public abstract class RedirectionEffect extends ReplacementEffectImpl {
|
||||
|
||||
protected Target redirectTarget;
|
||||
protected int amountToRedirect;
|
||||
protected boolean oneUsage;
|
||||
|
||||
public RedirectionEffect(Duration duration) {
|
||||
this(duration, Integer.MAX_VALUE, false);
|
||||
}
|
||||
|
||||
public RedirectionEffect(Duration duration, int amountToRedirect, boolean oneUsage) {
|
||||
super(duration, Outcome.RedirectDamage);
|
||||
this.effectType = EffectType.REDIRECTION;
|
||||
this.amountToRedirect = amountToRedirect;
|
||||
this.oneUsage = oneUsage;
|
||||
}
|
||||
|
||||
public RedirectionEffect(final RedirectionEffect effect) {
|
||||
super(effect);
|
||||
this.redirectTarget = effect.redirectTarget;
|
||||
this.amountToRedirect = effect.amountToRedirect;
|
||||
this.oneUsage = effect.oneUsage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
DamageEvent damageEvent = (DamageEvent)event;
|
||||
Permanent permanent = game.getPermanent(redirectTarget.getFirstTarget());
|
||||
if (permanent != null) {
|
||||
permanent.damage(damageEvent.getAmount(), event.getSourceId(), game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), event.getAppliedEffects());
|
||||
return true;
|
||||
}
|
||||
Player player = game.getPlayer(redirectTarget.getFirstTarget());
|
||||
if (player != null) {
|
||||
player.damage(damageEvent.getAmount(), event.getSourceId(), game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), event.getAppliedEffects());
|
||||
return true;
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
switch (event.getType()) {
|
||||
case DAMAGE_CREATURE:
|
||||
case DAMAGE_PLAYER:
|
||||
case DAMAGE_PLANESWALKER:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
String sourceLogName = source != null ? game.getObject(source.getSourceId()).getLogName() + ": " : "";
|
||||
DamageEvent damageEvent = (DamageEvent) event;
|
||||
int restDamage = 0;
|
||||
int damageToRedirect = event.getAmount();
|
||||
if (damageEvent.getAmount() > amountToRedirect) {
|
||||
restDamage = damageEvent.getAmount() - amountToRedirect;
|
||||
damageToRedirect = amountToRedirect;
|
||||
}
|
||||
if (damageToRedirect > 0 && oneUsage) {
|
||||
this.discard();
|
||||
}
|
||||
Permanent permanent = game.getPermanent(redirectTarget.getFirstTarget());
|
||||
if (permanent != null) {
|
||||
permanent.damage(damageToRedirect, event.getSourceId(), game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), event.getAppliedEffects());
|
||||
game.informPlayers(sourceLogName + "Redirected " + damageToRedirect + " damage to " + permanent.getLogName());
|
||||
} else {
|
||||
Player player = game.getPlayer(redirectTarget.getFirstTarget());
|
||||
if (player != null) {
|
||||
player.damage(damageToRedirect, event.getSourceId(), game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), event.getAppliedEffects());
|
||||
game.informPlayers(sourceLogName + "Redirected " + damageToRedirect + " damage to " + player.getLogName());
|
||||
}
|
||||
}
|
||||
if (restDamage > 0) {
|
||||
damageEvent.setAmount(restDamage);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -62,17 +61,17 @@ public class AddManaInAnyCombinationEffect extends ManaEffect {
|
|||
this.amount = amount;
|
||||
this.staticText = setText();
|
||||
}
|
||||
|
||||
|
||||
public AddManaInAnyCombinationEffect(int amount, String text) {
|
||||
this(amount);
|
||||
this.staticText = text;
|
||||
}
|
||||
|
||||
|
||||
public AddManaInAnyCombinationEffect(int amount, String text, ColoredManaSymbol... coloredManaSymbols) {
|
||||
this(amount, coloredManaSymbols);
|
||||
this.staticText = text;
|
||||
}
|
||||
|
||||
|
||||
public AddManaInAnyCombinationEffect(DynamicValue amount, String text, ColoredManaSymbol... coloredManaSymbols) {
|
||||
this(amount, coloredManaSymbols);
|
||||
this.staticText = text;
|
||||
|
@ -92,13 +91,13 @@ public class AddManaInAnyCombinationEffect extends ManaEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null){
|
||||
if (player != null) {
|
||||
Mana mana = new Mana();
|
||||
int amountOfManaLeft = amount.calculate(game, source, this);
|
||||
|
||||
while (amountOfManaLeft > 0 && player.canRespond()) {
|
||||
for (ColoredManaSymbol coloredManaSymbol: manaSymbols) {
|
||||
int number = player.getAmount(0, amountOfManaLeft, new StringBuilder("How many ").append(coloredManaSymbol.name()).append(" mana?").toString(), game);
|
||||
for (ColoredManaSymbol coloredManaSymbol : manaSymbols) {
|
||||
int number = player.getAmount(0, amountOfManaLeft, "How many " + coloredManaSymbol.getColorName() + " mana?", game);
|
||||
if (number > 0) {
|
||||
for (int i = 0; i < number; i++) {
|
||||
mana.add(new Mana(coloredManaSymbol));
|
||||
|
@ -111,7 +110,7 @@ public class AddManaInAnyCombinationEffect extends ManaEffect {
|
|||
}
|
||||
}
|
||||
checkToFirePossibleEvents(mana, game, source);
|
||||
player.getManaPool().addMana(mana, game, source);
|
||||
player.getManaPool().addMana(mana, game, source);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -130,7 +129,7 @@ public class AddManaInAnyCombinationEffect extends ManaEffect {
|
|||
sb.append("colors");
|
||||
} else {
|
||||
int i = 0;
|
||||
for (ColoredManaSymbol coloredManaSymbol: manaSymbols) {
|
||||
for (ColoredManaSymbol coloredManaSymbol : manaSymbols) {
|
||||
i++;
|
||||
if (i > 1) {
|
||||
sb.append(" and/or ");
|
||||
|
|
|
@ -19,6 +19,7 @@ import mage.filter.common.FilterCreatureCard;
|
|||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.EntersTheBattlefieldEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
@ -27,15 +28,13 @@ import mage.target.common.TargetCardInHand;
|
|||
/**
|
||||
* Effect for the AmplifyAbility
|
||||
*
|
||||
* 702.37. Amplify
|
||||
* 702.37a Amplify is a static ability. “Amplify N” means “As
|
||||
* this object enters the battlefield, reveal any number of cards from your hand
|
||||
* that share a creature type with it. This permanent enters the battlefield
|
||||
* with N +1/+1 counters on it for each card revealed this way. You can’t reveal
|
||||
* this card or any other cards that are entering the battlefield at the same
|
||||
* time as this card.”
|
||||
* 702.37b If a creature has multiple instances of amplify,
|
||||
* each one works separately.
|
||||
* 702.37. Amplify 702.37a Amplify is a static ability. “Amplify N” means “As
|
||||
* this object enters the battlefield, reveal any number of cards from your hand
|
||||
* that share a creature type with it. This permanent enters the battlefield
|
||||
* with N +1/+1 counters on it for each card revealed this way. You can’t reveal
|
||||
* this card or any other cards that are entering the battlefield at the same
|
||||
* time as this card.” 702.37b If a creature has multiple instances of amplify,
|
||||
* each one works separately.
|
||||
*
|
||||
*
|
||||
* @author FenrisulfrX
|
||||
|
@ -45,6 +44,7 @@ public class AmplifyEffect extends ReplacementEffectImpl {
|
|||
private final AmplifyFactor amplifyFactor;
|
||||
|
||||
public enum AmplifyFactor {
|
||||
|
||||
Amplify1("Amplify 1", "put one +1/+1 counters on it", 1),
|
||||
Amplify2("Amplify 2", "put two +1/+1 counters on it", 2),
|
||||
Amplify3("Amplify 3", "put three +1/+1 counters on it", 3);
|
||||
|
@ -95,7 +95,7 @@ public class AmplifyEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Permanent sourceCreature = game.getPermanent(event.getTargetId());
|
||||
Permanent sourceCreature = ((EntersTheBattlefieldEvent) event).getTarget();
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null && sourceCreature != null) {
|
||||
FilterCreatureCard filter = new FilterCreatureCard("creatures cards to reveal");
|
||||
|
@ -108,7 +108,7 @@ public class AmplifyEffect extends ReplacementEffectImpl {
|
|||
} else if (filterSubtypes.size() == 1) {
|
||||
filter.add(filterSubtypes.get(0));
|
||||
}
|
||||
if (controller.getHand().count(filter, source.getSourceId(), source.getControllerId(), game) > 0){
|
||||
if (controller.getHand().count(filter, source.getSourceId(), source.getControllerId(), game) > 0) {
|
||||
if (controller.chooseUse(outcome, "Reveal cards to Amplify?", source, game)) {
|
||||
TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, filter);
|
||||
if (controller.chooseTarget(outcome, target, source, game) && !target.getTargets().isEmpty()) {
|
||||
|
@ -116,7 +116,7 @@ public class AmplifyEffect extends ReplacementEffectImpl {
|
|||
cards.addAll(target.getTargets());
|
||||
int amountCounters = cards.size() * amplifyFactor.getFactor();
|
||||
sourceCreature.addCounters(CounterType.P1P1.createInstance(amountCounters), game);
|
||||
controller.revealCards(sourceCreature.getName(), cards, game);
|
||||
controller.revealCards(sourceCreature.getIdName(), cards, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -128,11 +128,11 @@ public class AmplifyEffect extends ReplacementEffectImpl {
|
|||
public String getText(Mode mode) {
|
||||
StringBuilder sb = new StringBuilder(amplifyFactor.toString());
|
||||
sb.append("<i>(As this enter the battlefield, ");
|
||||
sb.append(amplifyFactor.getRuleText()).append(" for each card" +
|
||||
" you reveal that shares a type with it in your hand.)</i>");
|
||||
sb.append(amplifyFactor.getRuleText()).append(" for each card"
|
||||
+ " you reveal that shares a type with it in your hand.)</i>");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AmplifyEffect copy() {
|
||||
return new AmplifyEffect(this);
|
||||
|
|
|
@ -6,18 +6,19 @@ import mage.abilities.Ability;
|
|||
import mage.game.Game;
|
||||
|
||||
public class BasicManaEffect extends ManaEffect {
|
||||
|
||||
protected Mana mana;
|
||||
|
||||
public BasicManaEffect(Mana mana) {
|
||||
super();
|
||||
this.mana = mana;
|
||||
staticText = "Add " + mana.toString() + " to your mana pool";
|
||||
staticText = "add " + mana.toString() + " to your mana pool";
|
||||
}
|
||||
|
||||
public BasicManaEffect(ConditionalMana conditionalMana) {
|
||||
super();
|
||||
this.mana = conditionalMana;
|
||||
staticText = "Add " + mana.toString() + " to your mana pool. " + conditionalMana.getDescription();
|
||||
staticText = "add " + mana.toString() + " to your mana pool. " + conditionalMana.getDescription();
|
||||
}
|
||||
|
||||
public BasicManaEffect(final BasicManaEffect effect) {
|
||||
|
|
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackAbility;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.Targets;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class ChangeATargetOfTargetSpellAbilityToSourceEffect extends OneShotEffect {
|
||||
|
||||
public ChangeATargetOfTargetSpellAbilityToSourceEffect() {
|
||||
super(Outcome.Neutral);
|
||||
staticText = "Change a target of target spell or ability to {this}";
|
||||
}
|
||||
|
||||
public ChangeATargetOfTargetSpellAbilityToSourceEffect(final ChangeATargetOfTargetSpellAbilityToSourceEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
StackObject stackObject = game.getStack().getStackObject(source.getFirstTarget());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (stackObject != null && sourceObject != null) {
|
||||
Targets targets = new Targets();
|
||||
Ability sourceAbility;
|
||||
String oldTargetName = null;
|
||||
if (stackObject instanceof Spell) {
|
||||
Spell spell = (Spell) stackObject;
|
||||
sourceAbility = spell.getSpellAbility();
|
||||
} else if (stackObject instanceof StackAbility) {
|
||||
StackAbility stackAbility = (StackAbility) stackObject;
|
||||
sourceAbility = stackAbility;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
for (UUID modeId : sourceAbility.getModes().getSelectedModes()) {
|
||||
sourceAbility.getModes().setActiveMode(modeId);
|
||||
targets.addAll(sourceAbility.getTargets());
|
||||
}
|
||||
|
||||
boolean twoTimesTarget = false;
|
||||
if (targets.size() == 1 && targets.get(0).getTargets().size() == 1) {
|
||||
Target target = targets.get(0);
|
||||
if (target.canTarget(stackObject.getControllerId(), source.getSourceId(), sourceAbility, game)) {
|
||||
oldTargetName = getTargetName(targets.getFirstTarget(), game);
|
||||
target.clearChosen();
|
||||
// The source is still the spell on the stack
|
||||
target.addTarget(source.getSourceId(), stackObject.getStackAbility(), game);
|
||||
}
|
||||
} else {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
boolean validTargets = false;
|
||||
do {
|
||||
for (Target target : targets) {
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
String name = getTargetName(targets.getFirstTarget(), game);
|
||||
if (!targetId.equals(source.getSourceId()) && target.getTargets().contains(source.getSourceId())) {
|
||||
// you can't change this target to source because the source is already another targetId of that target.
|
||||
twoTimesTarget = true;
|
||||
continue;
|
||||
}
|
||||
if (target.canTarget(stackObject.getControllerId(), source.getSourceId(), sourceAbility, game)) {
|
||||
validTargets = true;
|
||||
if (name != null
|
||||
&& controller.chooseUse(Outcome.Neutral, "Change target from " + name + " to " + sourceObject.getLogName() + "?", source, game)) {
|
||||
oldTargetName = getTargetName(targetId, game);
|
||||
target.remove(targetId);
|
||||
// The source is still the spell on the stack
|
||||
target.addTarget(source.getSourceId(), stackObject.getStackAbility(), game);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (oldTargetName != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (oldTargetName == null) {
|
||||
game.informPlayer(controller, "You have to select at least one target to change to " + sourceObject.getIdName() + "!");
|
||||
}
|
||||
} while (validTargets && oldTargetName == null);
|
||||
}
|
||||
if (oldTargetName != null) {
|
||||
game.informPlayers(sourceObject.getLogName() + ": Changed target of " + stackObject.getLogName() + " from " + oldTargetName + " to " + sourceObject.getLogName());
|
||||
} else {
|
||||
if (twoTimesTarget) {
|
||||
game.informPlayers(sourceObject.getLogName() + ": Target not changed to " + sourceObject.getLogName() + " because its not valid to target it twice for " + stackObject.getLogName());
|
||||
} else {
|
||||
game.informPlayers(sourceObject.getLogName() + ": Target not changed to " + sourceObject.getLogName() + " because its no valid target for " + stackObject.getLogName());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChangeATargetOfTargetSpellAbilityToSourceEffect copy() {
|
||||
return new ChangeATargetOfTargetSpellAbilityToSourceEffect(this);
|
||||
}
|
||||
|
||||
private String getTargetName(UUID objectId, Game game) {
|
||||
MageObject object = game.getObject(objectId);
|
||||
if (object != null) {
|
||||
return object.getLogName();
|
||||
}
|
||||
Player player = game.getPlayer(objectId);
|
||||
if (player != null) {
|
||||
return player.getLogName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.choices.ChoiceImpl;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class ChooseBasicLandTypeEffect extends OneShotEffect {
|
||||
|
||||
public static String VALUE_KEY = "BasicLandType";
|
||||
|
||||
public ChooseBasicLandTypeEffect(Outcome outcome) {
|
||||
super(outcome);
|
||||
this.staticText = "Choose a basic land type";
|
||||
}
|
||||
|
||||
public ChooseBasicLandTypeEffect(final ChooseBasicLandTypeEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChooseBasicLandTypeEffect copy() {
|
||||
return new ChooseBasicLandTypeEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject mageObject = game.getPermanentEntering(source.getSourceId());
|
||||
if (mageObject == null) {
|
||||
mageObject = game.getObject(source.getSourceId());
|
||||
}
|
||||
if (controller != null && mageObject != null) {
|
||||
ChoiceImpl choices = new ChoiceImpl(true);
|
||||
choices.setMessage("Choose basic land type");
|
||||
choices.isRequired();
|
||||
choices.getChoices().add("Forest");
|
||||
choices.getChoices().add("Plains");
|
||||
choices.getChoices().add("Mountain");
|
||||
choices.getChoices().add("Island");
|
||||
choices.getChoices().add("Swamp");
|
||||
if (controller.choose(Outcome.Neutral, choices, game)) {
|
||||
game.informPlayers(mageObject.getName() + ": Chosen basic land type is " + choices.getChoice());
|
||||
game.getState().setValue(mageObject.getId().toString() + VALUE_KEY, choices.getChoice());
|
||||
if (mageObject instanceof Permanent) {
|
||||
((Permanent) mageObject).addInfo("chosen color", CardUtil.addToolTipMarkTags("Chosen basic land type: " + choices.getChoice()), game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -25,9 +25,9 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.choices.ChoiceColor;
|
||||
|
@ -55,8 +55,11 @@ public class ChooseColorEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (controller != null && permanent != null) {
|
||||
MageObject mageObject = game.getPermanentEntering(source.getSourceId());
|
||||
if (mageObject == null) {
|
||||
mageObject = game.getObject(source.getSourceId());
|
||||
}
|
||||
if (controller != null && mageObject != null) {
|
||||
ChoiceColor choice = new ChoiceColor();
|
||||
while (!choice.isChosen()) {
|
||||
controller.choose(outcome, choice, game);
|
||||
|
@ -65,10 +68,12 @@ public class ChooseColorEffect extends OneShotEffect {
|
|||
}
|
||||
}
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(permanent.getLogName()+": "+controller.getLogName()+" has chosen "+choice.getChoice());
|
||||
game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice());
|
||||
}
|
||||
game.getState().setValue(mageObject.getId() + "_color", choice.getColor());
|
||||
if (mageObject instanceof Permanent) {
|
||||
((Permanent) mageObject).addInfo("chosen color", CardUtil.addToolTipMarkTags("Chosen color: " + choice.getChoice()), game);
|
||||
}
|
||||
game.getState().setValue(source.getSourceId() + "_color", choice.getColor());
|
||||
permanent.addInfo("chosen color", CardUtil.addToolTipMarkTags("Chosen color: " + choice.getChoice()), game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -79,4 +84,4 @@ public class ChooseColorEffect extends OneShotEffect {
|
|||
return new ChooseColorEffect(this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.repository.CardRepository;
|
||||
|
@ -42,7 +43,6 @@ import mage.util.CardUtil;
|
|||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class ChooseCreatureTypeEffect extends OneShotEffect {
|
||||
|
||||
public ChooseCreatureTypeEffect(Outcome outcome) {
|
||||
|
@ -57,8 +57,11 @@ public class ChooseCreatureTypeEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (controller != null && permanent != null) {
|
||||
MageObject mageObject = game.getPermanentEntering(source.getSourceId());
|
||||
if (mageObject == null) {
|
||||
mageObject = game.getObject(source.getSourceId());
|
||||
}
|
||||
if (controller != null && mageObject != null) {
|
||||
Choice typeChoice = new ChoiceImpl(true);
|
||||
typeChoice.setMessage("Choose creature type");
|
||||
typeChoice.setChoices(CardRepository.instance.getCreatureTypes());
|
||||
|
@ -68,10 +71,12 @@ public class ChooseCreatureTypeEffect extends OneShotEffect {
|
|||
}
|
||||
}
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(permanent.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice());
|
||||
game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice());
|
||||
}
|
||||
game.getState().setValue(mageObject.getId() + "_type", typeChoice.getChoice());
|
||||
if (mageObject instanceof Permanent) {
|
||||
((Permanent) mageObject).addInfo("chosen type", CardUtil.addToolTipMarkTags("Chosen type: " + typeChoice.getChoice()), game);
|
||||
}
|
||||
game.getState().setValue(permanent.getId() + "_type", typeChoice.getChoice());
|
||||
permanent.addInfo("chosen type", CardUtil.addToolTipMarkTags("Chosen type: " + typeChoice.getChoice()), game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.repository.CardRepository;
|
||||
|
@ -34,8 +35,11 @@ public class ChooseLandTypeEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (controller != null && permanent != null) {
|
||||
MageObject mageObject = game.getPermanentEntering(source.getSourceId());
|
||||
if (mageObject == null) {
|
||||
mageObject = game.getObject(source.getSourceId());
|
||||
}
|
||||
if (controller != null && mageObject != null) {
|
||||
Choice typeChoice = new ChoiceImpl(true);
|
||||
typeChoice.setMessage("Choose land type");
|
||||
typeChoice.setChoices(CardRepository.instance.getLandTypes());
|
||||
|
@ -45,10 +49,12 @@ public class ChooseLandTypeEffect extends OneShotEffect {
|
|||
}
|
||||
}
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(permanent.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice());
|
||||
game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice());
|
||||
}
|
||||
game.getState().setValue(mageObject.getId() + "_type", typeChoice.getChoice());
|
||||
if (mageObject instanceof Permanent) {
|
||||
((Permanent) mageObject).addInfo("chosen type", CardUtil.addToolTipMarkTags("Chosen type: " + typeChoice.getChoice()), game);
|
||||
}
|
||||
game.getState().setValue(permanent.getId() + "_type", typeChoice.getChoice());
|
||||
permanent.addInfo("chosen type", CardUtil.addToolTipMarkTags("Chosen type: " + typeChoice.getChoice()), game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -69,6 +69,9 @@ public class ChooseModeEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
if (sourcePermanent == null) {
|
||||
sourcePermanent = game.getPermanentEntering(source.getSourceId());
|
||||
}
|
||||
if (controller != null) {
|
||||
Choice choice = new ChoiceImpl(true);
|
||||
choice.setMessage(choiceMessage);
|
||||
|
@ -80,8 +83,9 @@ public class ChooseModeEffect extends OneShotEffect {
|
|||
controller.choose(Outcome.Neutral, choice, game);
|
||||
}
|
||||
if (choice.isChosen()) {
|
||||
if (!game.isSimulation())
|
||||
game.informPlayers(new StringBuilder(sourcePermanent.getLogName()).append(": ").append(controller.getLogName()).append(" has chosen ").append(choice.getChoice()).toString());
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(sourcePermanent.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice());
|
||||
}
|
||||
game.getState().setValue(source.getSourceId() + "_modeChoice", choice.getChoice());
|
||||
sourcePermanent.addInfo("_modeChoice", "<font color = 'blue'>Chosen mode: " + choice.getChoice() + "</font>", game);
|
||||
}
|
||||
|
@ -93,7 +97,7 @@ public class ChooseModeEffect extends OneShotEffect {
|
|||
private String setText() {
|
||||
StringBuilder sb = new StringBuilder("choose ");
|
||||
int count = 0;
|
||||
for (String choice: modes) {
|
||||
for (String choice : modes) {
|
||||
count++;
|
||||
sb.append(choice);
|
||||
if (count + 1 < modes.size()) {
|
||||
|
|
|
@ -1,38 +1,36 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.constants.Outcome;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.filter.Filter;
|
||||
import mage.constants.Outcome;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.stack.StackObject;
|
||||
|
@ -46,21 +44,22 @@ public class ChooseNewTargetsTargetEffect extends OneShotEffect {
|
|||
private boolean forceChange;
|
||||
private boolean onlyOneTarget;
|
||||
private FilterPermanent filterNewTarget;
|
||||
|
||||
|
||||
public ChooseNewTargetsTargetEffect() {
|
||||
this(false, false);
|
||||
}
|
||||
|
||||
public ChooseNewTargetsTargetEffect(boolean forceChange, boolean onlyOneTarget) {
|
||||
this(forceChange, onlyOneTarget, null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param forceChange forces the user to choose another target (only targets with maxtargets = 1 supported)
|
||||
* @param forceChange forces the user to choose another target (only targets
|
||||
* with maxtargets = 1 supported)
|
||||
* @param onlyOneTarget only one target can be selected for the change
|
||||
* @param filterNewTarget restriction to the new target
|
||||
*/
|
||||
|
||||
public ChooseNewTargetsTargetEffect(boolean forceChange, boolean onlyOneTarget, FilterPermanent filterNewTarget) {
|
||||
super(Outcome.Benefit);
|
||||
this.forceChange = forceChange;
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetOpponent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class ChooseOpponentEffect extends OneShotEffect {
|
||||
|
||||
public static String VALUE_KEY = "_opponent";
|
||||
|
||||
public ChooseOpponentEffect(Outcome outcome) {
|
||||
super(outcome);
|
||||
this.staticText = "choose an opponent";
|
||||
}
|
||||
|
||||
public ChooseOpponentEffect(final ChooseOpponentEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChooseOpponentEffect copy() {
|
||||
return new ChooseOpponentEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject mageObject = game.getPermanentEntering(source.getSourceId());
|
||||
if (mageObject == null) {
|
||||
mageObject = game.getObject(source.getSourceId());
|
||||
}
|
||||
if (controller != null && mageObject != null) {
|
||||
TargetOpponent target = new TargetOpponent(true);
|
||||
if (controller.choose(this.outcome, target, source.getSourceId(), game)) {
|
||||
Player chosenPlayer = game.getPlayer(target.getFirstTarget());
|
||||
if (chosenPlayer != null) {
|
||||
game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + chosenPlayer.getLogName());
|
||||
game.getState().setValue(mageObject.getId() + VALUE_KEY, target.getFirstTarget());
|
||||
if (mageObject instanceof Permanent) {
|
||||
((Permanent) mageObject).addInfo("chosen opponent", CardUtil.addToolTipMarkTags("Chosen player: " + chosenPlayer.getLogName()), game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPlayer;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class ChoosePlayerEffect extends OneShotEffect {
|
||||
|
||||
public ChoosePlayerEffect(Outcome outcome) {
|
||||
super(outcome);
|
||||
this.staticText = "choose a player";
|
||||
}
|
||||
|
||||
public ChoosePlayerEffect(final ChoosePlayerEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChoosePlayerEffect copy() {
|
||||
return new ChoosePlayerEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject mageObject = game.getPermanentEntering(source.getSourceId());
|
||||
if (mageObject == null) {
|
||||
mageObject = game.getObject(source.getSourceId());
|
||||
}
|
||||
if (controller != null && mageObject != null) {
|
||||
TargetPlayer target = new TargetPlayer(1, 1, true);
|
||||
if (controller.choose(this.outcome, target, source.getSourceId(), game)) {
|
||||
Player chosenPlayer = game.getPlayer(target.getFirstTarget());
|
||||
if (chosenPlayer != null) {
|
||||
game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + chosenPlayer.getLogName());
|
||||
game.getState().setValue(mageObject.getId() + "_player", target.getFirstTarget());
|
||||
if (mageObject instanceof Permanent) {
|
||||
((Permanent) mageObject).addInfo("chosen player", CardUtil.addToolTipMarkTags("Chosen player: " + chosenPlayer.getLogName()), game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
|
@ -20,21 +20,20 @@
|
|||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
|
@ -56,35 +55,47 @@ public class CopyEffect extends ContinuousEffectImpl {
|
|||
/**
|
||||
* Object we copy from
|
||||
*/
|
||||
private MageObject target;
|
||||
|
||||
private UUID sourceId;
|
||||
private ApplyToPermanent applier;
|
||||
|
||||
public CopyEffect(MageObject target, UUID sourceId) {
|
||||
this(Duration.Custom, target, sourceId);
|
||||
protected MageObject copyFromObject;
|
||||
|
||||
protected UUID copyToObjectId;
|
||||
protected ApplyToPermanent applier;
|
||||
|
||||
public CopyEffect(MageObject copyFromObject, UUID copyToObjectId) {
|
||||
this(Duration.Custom, copyFromObject, copyToObjectId);
|
||||
}
|
||||
|
||||
public CopyEffect(Duration duration, MageObject target, UUID sourceId) {
|
||||
|
||||
public CopyEffect(Duration duration, MageObject copyFromObject, UUID copyToObjectId) {
|
||||
super(duration, Layer.CopyEffects_1, SubLayer.NA, Outcome.BecomeCreature);
|
||||
this.target = target;
|
||||
this.sourceId = sourceId;
|
||||
this.copyFromObject = copyFromObject;
|
||||
this.copyToObjectId = copyToObjectId;
|
||||
}
|
||||
|
||||
public CopyEffect(final CopyEffect effect) {
|
||||
super(effect);
|
||||
this.target = effect.target.copy();
|
||||
this.sourceId = effect.sourceId;
|
||||
this.copyFromObject = effect.copyFromObject.copy();
|
||||
this.copyToObjectId = effect.copyToObjectId;
|
||||
this.applier = effect.applier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
if (!(target instanceof Permanent) && (target instanceof Card)) {
|
||||
this.target = new PermanentCard((Card)target, source.getControllerId(), game);
|
||||
if (!(copyFromObject instanceof Permanent) && (copyFromObject instanceof Card)) {
|
||||
this.copyFromObject = new PermanentCard((Card) copyFromObject, source.getControllerId(), game);
|
||||
}
|
||||
Permanent permanent = game.getPermanent(copyToObjectId);
|
||||
if (permanent != null) {
|
||||
affectedObjectList.add(new MageObjectReference(permanent, game));
|
||||
} else if (source.getAbilityType().equals(AbilityType.STATIC)) {
|
||||
// for replacement effects that let a permanent enter the battlefield as a copy of another permanent we need to apply that copy
|
||||
// before the permanent is added to the battlefield
|
||||
permanent = game.getPermanentEntering(copyToObjectId);
|
||||
if (permanent != null) {
|
||||
copyToPermanent(permanent, game, source);
|
||||
// set reference to the permanent later on the battlefield so we have to add already one to the zone change counter
|
||||
affectedObjectList.add(new MageObjectReference(permanent.getId(), game.getState().getZoneChangeCounter(copyToObjectId) + 1, game));
|
||||
}
|
||||
}
|
||||
affectedObjectList.add(new MageObjectReference(getSourceId(), game));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -98,32 +109,36 @@ public class CopyEffect extends ContinuousEffectImpl {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
return copyToPermanent(permanent, game, source);
|
||||
}
|
||||
|
||||
protected boolean copyToPermanent(Permanent permanent, Game game, Ability source) {
|
||||
permanent.setCopy(true);
|
||||
permanent.setName(target.getName());
|
||||
permanent.getColor(game).setColor(target.getColor(game));
|
||||
permanent.setName(copyFromObject.getName());
|
||||
permanent.getColor(game).setColor(copyFromObject.getColor(game));
|
||||
permanent.getManaCost().clear();
|
||||
permanent.getManaCost().add(target.getManaCost());
|
||||
permanent.getManaCost().add(copyFromObject.getManaCost());
|
||||
permanent.getCardType().clear();
|
||||
for (CardType type: target.getCardType()) {
|
||||
for (CardType type : copyFromObject.getCardType()) {
|
||||
permanent.getCardType().add(type);
|
||||
}
|
||||
permanent.getSubtype().clear();
|
||||
for (String type: target.getSubtype()) {
|
||||
for (String type : copyFromObject.getSubtype()) {
|
||||
permanent.getSubtype().add(type);
|
||||
}
|
||||
permanent.getSupertype().clear();
|
||||
for (String type: target.getSupertype()) {
|
||||
for (String type : copyFromObject.getSupertype()) {
|
||||
permanent.getSupertype().add(type);
|
||||
}
|
||||
|
||||
permanent.removeAllAbilities(source.getSourceId(), game);
|
||||
for (Ability ability: target.getAbilities()) {
|
||||
permanent.addAbility(ability, getSourceId(), game, false); // no new Id so consumed replacement effects are known while new continuousEffects.apply happen.
|
||||
for (Ability ability : copyFromObject.getAbilities()) {
|
||||
permanent.addAbility(ability, getSourceId(), game, false); // no new Id so consumed replacement effects are known while new continuousEffects.apply happen.
|
||||
}
|
||||
permanent.getPower().setValue(target.getPower().getValue());
|
||||
permanent.getToughness().setValue(target.getToughness().getValue());
|
||||
if (target instanceof Permanent) {
|
||||
Permanent targetPermanent = (Permanent) target;
|
||||
permanent.getPower().setValue(copyFromObject.getPower().getValue());
|
||||
permanent.getToughness().setValue(copyFromObject.getToughness().getValue());
|
||||
if (copyFromObject instanceof Permanent) {
|
||||
Permanent targetPermanent = (Permanent) copyFromObject;
|
||||
permanent.setTransformed(targetPermanent.isTransformed());
|
||||
permanent.setSecondCardFace(targetPermanent.getSecondCardFace());
|
||||
permanent.setFlipCard(targetPermanent.isFlipCard());
|
||||
|
@ -131,13 +146,13 @@ public class CopyEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
// to get the image of the copied permanent copy number und expansionCode
|
||||
if (target instanceof PermanentCard) {
|
||||
permanent.setCardNumber(((PermanentCard) target).getCard().getCardNumber());
|
||||
permanent.setExpansionSetCode(((PermanentCard) target).getCard().getExpansionSetCode());
|
||||
} else if (target instanceof PermanentToken || target instanceof Card) {
|
||||
permanent.setCardNumber(((Card) target).getCardNumber());
|
||||
permanent.setExpansionSetCode(((Card) target).getExpansionSetCode());
|
||||
}
|
||||
if (copyFromObject instanceof PermanentCard) {
|
||||
permanent.setCardNumber(((PermanentCard) copyFromObject).getCard().getCardNumber());
|
||||
permanent.setExpansionSetCode(((PermanentCard) copyFromObject).getCard().getExpansionSetCode());
|
||||
} else if (copyFromObject instanceof PermanentToken || copyFromObject instanceof Card) {
|
||||
permanent.setCardNumber(((Card) copyFromObject).getCardNumber());
|
||||
permanent.setExpansionSetCode(((Card) copyFromObject).getExpansionSetCode());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -147,15 +162,15 @@ public class CopyEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
public MageObject getTarget() {
|
||||
return target;
|
||||
return copyFromObject;
|
||||
}
|
||||
|
||||
public void setTarget(MageObject target) {
|
||||
this.target = target;
|
||||
this.copyFromObject = target;
|
||||
}
|
||||
|
||||
public UUID getSourceId() {
|
||||
return sourceId;
|
||||
return copyToObjectId;
|
||||
}
|
||||
|
||||
public ApplyToPermanent getApplier() {
|
||||
|
@ -165,5 +180,5 @@ public class CopyEffect extends ContinuousEffectImpl {
|
|||
public void setApplier(ApplyToPermanent applier) {
|
||||
this.applier = applier;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
|
@ -20,13 +20,14 @@
|
|||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
|
@ -66,12 +67,13 @@ public class CopyPermanentEffect extends OneShotEffect {
|
|||
public CopyPermanentEffect(FilterPermanent filter, ApplyToPermanent applier) {
|
||||
this(filter, applier, false);
|
||||
}
|
||||
|
||||
public CopyPermanentEffect(FilterPermanent filter, ApplyToPermanent applier, boolean useTarget) {
|
||||
super(Outcome.Copy);
|
||||
this.applier = applier;
|
||||
this.filter = filter;
|
||||
this.useTargetOfAbility = useTarget;
|
||||
this.staticText = "You may have {this} enter the battlefield as a copy of any " + filter.getMessage() + " on the battlefield";
|
||||
this.staticText = "as a copy of any " + filter.getMessage() + " on the battlefield";
|
||||
}
|
||||
|
||||
public CopyPermanentEffect(final CopyPermanentEffect effect) {
|
||||
|
@ -85,21 +87,24 @@ public class CopyPermanentEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
if (player != null && sourcePermanent != null) {
|
||||
MageObject sourceObject = game.getPermanentEntering(source.getSourceId());
|
||||
if (sourceObject == null) {
|
||||
sourceObject = game.getObject(source.getSourceId());
|
||||
}
|
||||
if (player != null && sourceObject != null) {
|
||||
Permanent copyFromPermanent = null;
|
||||
if (useTargetOfAbility) {
|
||||
copyFromPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
} else {
|
||||
Target target = new TargetPermanent(filter);
|
||||
target.setNotTarget(true);
|
||||
if (target.canChoose(source.getControllerId(), game)) {
|
||||
if (target.canChoose(source.getSourceId(), player.getId(), game)) {
|
||||
player.choose(Outcome.Copy, target, source.getSourceId(), game);
|
||||
copyFromPermanent = game.getPermanent(target.getFirstTarget());
|
||||
}
|
||||
}
|
||||
if (copyFromPermanent != null) {
|
||||
bluePrintPermanent = game.copyPermanent(copyFromPermanent, sourcePermanent, source, applier);
|
||||
bluePrintPermanent = game.copyPermanent(copyFromPermanent, sourceObject.getId(), source, applier);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
|
@ -56,7 +55,8 @@ public class CounterTargetWithReplacementEffect extends OneShotEffect {
|
|||
/**
|
||||
*
|
||||
* @param targetZone
|
||||
* @param flag use to specify when moving card to library <ul><li>true = put on top</li><li>false = put on bottom</li></ul>
|
||||
* @param flag use to specify when moving card to library <ul><li>true = put
|
||||
* on top</li><li>false = put on bottom</li></ul>
|
||||
*/
|
||||
public CounterTargetWithReplacementEffect(Zone targetZone, boolean flag) {
|
||||
super(Outcome.Detriment);
|
||||
|
@ -83,33 +83,14 @@ public class CounterTargetWithReplacementEffect extends OneShotEffect {
|
|||
if (controller != null) {
|
||||
StackObject stackObject = game.getStack().getStackObject(objectId);
|
||||
if (stackObject != null && !game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER, objectId, sourceId, stackObject.getControllerId()))) {
|
||||
boolean spell = false;
|
||||
if (stackObject instanceof Spell) {
|
||||
game.rememberLKI(objectId, Zone.STACK, stackObject);
|
||||
spell = true;
|
||||
}
|
||||
game.getStack().remove(stackObject);
|
||||
if (spell && !((Spell) stackObject).isCopiedSpell()) {
|
||||
MageObject mageObject = game.getObject(stackObject.getSourceId());
|
||||
if (mageObject instanceof Card) {
|
||||
Card card = (Card) mageObject;
|
||||
switch (targetZone) {
|
||||
case LIBRARY:
|
||||
controller.moveCardToLibraryWithInfo(card, sourceId, game, Zone.STACK, flag, true);
|
||||
break;
|
||||
case EXILED:
|
||||
controller.moveCardToExileWithInfo(card, null, "", sourceId, game, Zone.STACK, true);
|
||||
break;
|
||||
default:
|
||||
controller.moveCards(card, Zone.STACK, targetZone, source, game);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
controller.moveCards((Card) stackObject, null, targetZone, source, game);
|
||||
} else {
|
||||
game.getStack().remove(stackObject);
|
||||
}
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTERED, objectId, sourceId, stackObject.getControllerId()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ import mage.counters.CounterType;
|
|||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.predicate.permanent.AnotherPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.EntersTheBattlefieldEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
@ -47,30 +48,32 @@ import mage.target.common.TargetControlledCreaturePermanent;
|
|||
|
||||
/**
|
||||
* Effect for the DevourAbility
|
||||
*
|
||||
* 702.81. Devour
|
||||
* 702.81a Devour is a static ability. "Devour N" means "As this object enters the battlefield,
|
||||
* you may sacrifice any number of creatures. This permanent enters the battlefield with N +1/+1
|
||||
* counters on it for each creature sacrificed this way."
|
||||
* 702.81b Some objects have abilities that refer to the number of creatures the permanent devoured.
|
||||
* "It devoured" means "sacrificed as a result of its devour ability as it entered the battlefield."
|
||||
*
|
||||
*
|
||||
* 702.81. Devour 702.81a Devour is a static ability. "Devour N" means "As this
|
||||
* object enters the battlefield, you may sacrifice any number of creatures.
|
||||
* This permanent enters the battlefield with N +1/+1 counters on it for each
|
||||
* creature sacrificed this way." 702.81b Some objects have abilities that refer
|
||||
* to the number of creatures the permanent devoured. "It devoured" means
|
||||
* "sacrificed as a result of its devour ability as it entered the battlefield."
|
||||
*
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class DevourEffect extends ReplacementEffectImpl {
|
||||
|
||||
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("creatures to devour");
|
||||
|
||||
static {
|
||||
filter.add(new AnotherPredicate());
|
||||
}
|
||||
private final DevourFactor devourFactor;
|
||||
|
||||
public enum DevourFactor {
|
||||
Devour1 ("Devour 1", "that many +1/+1 counters on it", 1),
|
||||
Devour2 ("Devour 2", "twice that many +1/+1 counters on it", 2),
|
||||
Devour3 ("Devour 3", "three times that many +1/+1 counters on it", 3),
|
||||
DevourX ("Devour X, where X is the number of creatures devoured this way", "X +1/+1 counters on it for each of those creatures", Integer.MAX_VALUE);
|
||||
|
||||
Devour1("Devour 1", "that many +1/+1 counters on it", 1),
|
||||
Devour2("Devour 2", "twice that many +1/+1 counters on it", 2),
|
||||
Devour3("Devour 3", "three times that many +1/+1 counters on it", 3),
|
||||
DevourX("Devour X, where X is the number of creatures devoured this way", "X +1/+1 counters on it for each of those creatures", Integer.MAX_VALUE);
|
||||
|
||||
private final String text;
|
||||
private final String ruleText;
|
||||
|
@ -114,9 +117,9 @@ public class DevourEffect extends ReplacementEffectImpl {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getTargetId().equals(source.getSourceId())) {
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
game.getState().setValue(sourcePermanent.getId().toString() + "devoured", null);
|
||||
return true;
|
||||
Permanent sourcePermanent = ((EntersTheBattlefieldEvent) event).getTarget();
|
||||
game.getState().setValue(sourcePermanent.getId().toString() + "devoured", null);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -128,7 +131,7 @@ public class DevourEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Permanent creature = game.getPermanent(event.getTargetId());
|
||||
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (creature != null && controller != null) {
|
||||
Target target = new TargetControlledCreaturePermanent(1, Integer.MAX_VALUE, filter, true);
|
||||
|
@ -141,9 +144,10 @@ public class DevourEffect extends ReplacementEffectImpl {
|
|||
if (target.getTargets().size() > 0) {
|
||||
List<ArrayList<String>> cardSubtypes = new ArrayList<>();
|
||||
int devouredCreatures = target.getTargets().size();
|
||||
if (!game.isSimulation())
|
||||
game.informPlayers(new StringBuilder(creature.getName()).append(" devours ").append(devouredCreatures).append(" creatures").toString());
|
||||
for (UUID targetId: target.getTargets()) {
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(creature.getLogName() + " devours " + devouredCreatures + " creatures");
|
||||
}
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
Permanent targetCreature = game.getPermanent(targetId);
|
||||
if (targetCreature != null) {
|
||||
cardSubtypes.add((ArrayList<String>) targetCreature.getSubtype());
|
||||
|
@ -172,7 +176,7 @@ public class DevourEffect extends ReplacementEffectImpl {
|
|||
StringBuilder sb = new StringBuilder(devourFactor.toString());
|
||||
sb.append(" <i>(As this enters the battlefield, you may sacrifice any number of creatures. This creature enters the battlefield with ");
|
||||
sb.append(devourFactor.getRuleText()).append(")</i>");
|
||||
return sb.toString();
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public List<ArrayList<String>> getSubtypes(Game game, UUID permanentId) {
|
||||
|
|
|
@ -34,8 +34,8 @@ import mage.constants.Duration;
|
|||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
|
@ -85,7 +85,7 @@ public class DiscardOntoBattlefieldEffect extends ReplacementEffectImpl {
|
|||
if (card != null) {
|
||||
Player owner = game.getPlayer(card.getOwnerId());
|
||||
if (owner != null) {
|
||||
if (owner.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId())) {
|
||||
if (owner.moveCards(card, Zone.BATTLEFIELD, source, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,11 +27,11 @@
|
|||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
|
@ -44,7 +44,11 @@ import mage.game.permanent.Permanent;
|
|||
public class DontUntapInControllersUntapStepSourceEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
|
||||
public DontUntapInControllersUntapStepSourceEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Detriment, false, true);
|
||||
this(false, true);
|
||||
}
|
||||
|
||||
public DontUntapInControllersUntapStepSourceEffect(boolean messageToUser, boolean messageToLog) {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Detriment, messageToUser, messageToLog);
|
||||
staticText = "{this} doesn't untap during your untap step";
|
||||
}
|
||||
|
||||
|
@ -78,4 +82,5 @@ public class DontUntapInControllersUntapStepSourceEffect extends ContinuousRuleM
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
|
@ -20,12 +20,11 @@
|
|||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
@ -51,6 +50,7 @@ public class DrawCardTargetEffect extends OneShotEffect {
|
|||
public DrawCardTargetEffect(int amount) {
|
||||
this(new StaticValue(amount));
|
||||
}
|
||||
|
||||
public DrawCardTargetEffect(int amount, boolean optional) {
|
||||
this(new StaticValue(amount), optional);
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ public class DrawCardTargetEffect extends OneShotEffect {
|
|||
if (upTo) {
|
||||
sb.append("up to ");
|
||||
}
|
||||
sb.append(CardUtil.numberToText(amount.toString())).append(" card");
|
||||
sb.append(CardUtil.numberToText(amount.toString(), "a")).append(" card");
|
||||
try {
|
||||
if (Integer.parseInt(amount.toString()) > 1) {
|
||||
sb.append("s");
|
||||
|
@ -133,5 +133,4 @@ public class DrawCardTargetEffect extends OneShotEffect {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.effects.EntersBattlefieldEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.counters.Counter;
|
||||
import mage.game.Game;
|
||||
|
@ -59,11 +60,16 @@ public class EntersBattlefieldWithXCountersEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent == null) {
|
||||
if (permanent == null && source.getAbilityType().equals(AbilityType.STATIC)) {
|
||||
permanent = game.getPermanentEntering(source.getSourceId());
|
||||
}
|
||||
}
|
||||
if (permanent != null) {
|
||||
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
|
||||
if (spellAbility != null
|
||||
&& spellAbility.getSourceId().equals(source.getSourceId())
|
||||
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
|
||||
&& permanent.getZoneChangeCounter(game) == spellAbility.getSourceObjectZoneChangeCounter()) {
|
||||
if (spellAbility.getSourceId().equals(source.getSourceId())) { // put into play by normal cast
|
||||
int amount = spellAbility.getManaCostsToPay().getX();
|
||||
if (amount > 0) {
|
||||
|
|
|
@ -61,12 +61,11 @@ public class ExileAndReturnTransformedSourceEffect extends OneShotEffect {
|
|||
Permanent sourceObject = game.getPermanent(source.getSourceId());
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (sourceObject != null && controller != null && sourceObject.getZoneChangeCounter(game) == source.getSourceObjectZoneChangeCounter()) {
|
||||
Card card = (Card) sourceObject;
|
||||
if (controller.moveCards(card, Zone.BATTLEFIELD, Zone.EXILED, source, game)) {
|
||||
Player owner = game.getPlayer(card.getOwnerId());
|
||||
if (owner != null) {
|
||||
game.getState().setValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + source.getSourceId(), Boolean.TRUE);
|
||||
owner.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId());
|
||||
if (controller.moveCards(sourceObject, Zone.EXILED, source, game)) {
|
||||
game.getState().setValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + source.getSourceId(), Boolean.TRUE);
|
||||
Card cardFromExile = game.getCard(source.getSourceId());
|
||||
if (cardFromExile != null) {
|
||||
controller.moveCards(cardFromExile, Zone.BATTLEFIELD, source, game, false, false, true, null);
|
||||
if (additionalEffect != null) {
|
||||
if (additionalEffect instanceof ContinuousEffect) {
|
||||
game.addEffect((ContinuousEffect) additionalEffect, source);
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
|
@ -20,7 +20,7 @@
|
|||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
|
@ -28,17 +28,18 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.TargetCardInHand;
|
||||
import mage.target.common.TargetCardInYourGraveyard;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -90,16 +91,11 @@ public class ExileFromZoneTargetEffect extends OneShotEffect {
|
|||
default:
|
||||
}
|
||||
if (target != null && target.canChoose(source.getSourceId(), player.getId(), game)) {
|
||||
if (target.choose(Outcome.Exile, player.getId(), source.getSourceId(), game)) {
|
||||
for (UUID cardId : target.getTargets()) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null) {
|
||||
card.moveToExile(exileId, exileName, source.getSourceId(), game);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
if (target.chooseTarget(Outcome.Exile, player.getId(), source, game)) {
|
||||
player.moveCardsToExile(new CardsImpl(target.getTargets()).getCards(game), source, game, true, exileId, exileName);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -110,10 +106,6 @@ public class ExileFromZoneTargetEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
private void setText() {
|
||||
if (amount == 1) {
|
||||
staticText = "Target player exiles a " + filter.getMessage() + " from his or her " + zone.toString().toLowerCase();
|
||||
} else {
|
||||
staticText = "Target player exiles " + amount + " " + filter.getMessage() + " from his or her " + zone.toString().toLowerCase();
|
||||
}
|
||||
staticText = "target player exiles " + CardUtil.numberToText(amount, "a") + " " + filter.getMessage() + " from his or her " + zone.toString().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
|
@ -20,12 +20,11 @@
|
|||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -49,11 +48,12 @@ public class ExileSourceEffect extends OneShotEffect {
|
|||
public ExileSourceEffect() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param toUniqueExileZone moves the card to a source object dependant unique exile zone, so another
|
||||
* effect of the same source object (e.g. Deadeye Navigator) can identify the card
|
||||
*
|
||||
* @param toUniqueExileZone moves the card to a source object dependant
|
||||
* unique exile zone, so another effect of the same source object (e.g.
|
||||
* Deadeye Navigator) can identify the card
|
||||
*/
|
||||
public ExileSourceEffect(boolean toUniqueExileZone) {
|
||||
super(Outcome.Exile);
|
||||
|
@ -72,10 +72,10 @@ public class ExileSourceEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
MageObject sourceObject = source.getSourceObjectIfItStillExists(game);
|
||||
MageObject sourceObject = source.getSourceObjectIfItStillExists(game);
|
||||
if (sourceObject instanceof Card) {
|
||||
UUID exileZoneId = null;
|
||||
String exileZoneName = "";
|
||||
|
@ -84,7 +84,7 @@ public class ExileSourceEffect extends OneShotEffect {
|
|||
exileZoneName = sourceObject.getName();
|
||||
}
|
||||
Card sourceCard = (Card) sourceObject;
|
||||
return controller.moveCardToExileWithInfo(sourceCard, exileZoneId, exileZoneName, source.getSourceId(), game, game.getState().getZone(sourceCard.getId()), true);
|
||||
return controller.moveCardsToExile(sourceCard, source, game, true, exileZoneId, exileZoneName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
@ -58,14 +57,14 @@ public class ExileSpellEffect extends OneShotEffect implements MageSingleton {
|
|||
public ExileSpellEffect copy() {
|
||||
return fINSTANCE;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard();
|
||||
if (spellCard != null) {
|
||||
controller.moveCardToExileWithInfo(spellCard, null, "", source.getSourceId(), game, Zone.STACK, true);
|
||||
controller.moveCards(spellCard, null, Zone.EXILED, source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
|
@ -128,28 +127,13 @@ public class LookLibraryAndPickControllerEffect extends LookLibraryControllerEff
|
|||
if (!optional || player.chooseUse(Outcome.DrawCard, getMayText(), source, game)) {
|
||||
FilterCard pickFilter = filter.copy();
|
||||
pickFilter.setMessage(getPickText());
|
||||
TargetCard target = new TargetCard((upTo ? 0 : numberToPick.calculate(game, source, this)), numberToPick.calculate(game, source, this), Zone.PICK, pickFilter);
|
||||
TargetCard target = new TargetCard((upTo ? 0 : numberToPick.calculate(game, source, this)), numberToPick.calculate(game, source, this), Zone.LIBRARY, pickFilter);
|
||||
if (player.choose(Outcome.DrawCard, cards, target, game)) {
|
||||
Cards reveal = new CardsImpl();
|
||||
for (UUID cardId : target.getTargets()) {
|
||||
Card card = cards.get(cardId, game);
|
||||
if (card != null) {
|
||||
cards.remove(card);
|
||||
if (targetZoneLookedCards.equals(Zone.BATTLEFIELD)) {
|
||||
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
|
||||
} else {
|
||||
card.moveToZone(targetPickedCards, source.getSourceId(), game, false);
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(player.getLogName() + " moves a card to " + targetPickedCards.toString().toLowerCase());
|
||||
}
|
||||
}
|
||||
if (revealPickedCards) {
|
||||
reveal.add(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
Cards pickedCards = new CardsImpl(target.getTargets());
|
||||
cards.removeAll(pickedCards);
|
||||
player.moveCards(pickedCards.getCards(game), targetPickedCards, source, game);
|
||||
if (revealPickedCards) {
|
||||
player.revealCards(windowName, reveal, game);
|
||||
player.revealCards(windowName, pickedCards, game);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -71,7 +71,10 @@ public class NameACardEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
MageObject sourceObject = game.getPermanentEntering(source.getSourceId());
|
||||
if (sourceObject == null) {
|
||||
sourceObject = game.getObject(source.getSourceId());
|
||||
}
|
||||
if (controller != null && sourceObject != null) {
|
||||
Choice cardChoice = new ChoiceImpl();
|
||||
switch (typeOfName) {
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
@ -50,10 +49,11 @@ public class PutLandFromHandOntoBattlefieldEffect extends OneShotEffect {
|
|||
public PutLandFromHandOntoBattlefieldEffect() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
public PutLandFromHandOntoBattlefieldEffect(boolean tapped) {
|
||||
super(Outcome.PutLandInPlay);
|
||||
this.tapped = tapped;
|
||||
staticText = "you may put a land card from your hand onto the battlefield" + (tapped ? " tapped":"");
|
||||
staticText = "you may put a land card from your hand onto the battlefield" + (tapped ? " tapped" : "");
|
||||
}
|
||||
|
||||
public PutLandFromHandOntoBattlefieldEffect(final PutLandFromHandOntoBattlefieldEffect effect) {
|
||||
|
@ -66,12 +66,12 @@ public class PutLandFromHandOntoBattlefieldEffect extends OneShotEffect {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Target target = new TargetCardInHand(new FilterLandCard("land card"));
|
||||
if (target.canChoose(source.getSourceId(), source.getControllerId(), game) &&
|
||||
controller.chooseUse(outcome, "Put land onto battlefield?", source, game) &&
|
||||
controller.choose(outcome, target, source.getSourceId(), game)) {
|
||||
if (target.canChoose(source.getSourceId(), source.getControllerId(), game)
|
||||
&& controller.chooseUse(outcome, "Put land onto battlefield?", source, game)
|
||||
&& controller.choose(outcome, target, source.getSourceId(), game)) {
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
if (card != null) {
|
||||
controller.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId(), tapped);
|
||||
controller.moveCards(card, Zone.BATTLEFIELD, source, game, tapped, false, false, null);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -85,4 +85,4 @@ public class PutLandFromHandOntoBattlefieldEffect extends OneShotEffect {
|
|||
return new PutLandFromHandOntoBattlefieldEffect(this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,10 +48,9 @@ public class PutPermanentOnBattlefieldEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player;
|
||||
if(useTargetController) {
|
||||
if (useTargetController) {
|
||||
player = game.getPlayer(getTargetPointer().getFirst(game, source));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
player = game.getPlayer(source.getControllerId());
|
||||
}
|
||||
String choiceText = "Put " + filter.getMessage() + " from your hand onto the battlefield?";
|
||||
|
@ -63,23 +62,21 @@ public class PutPermanentOnBattlefieldEffect extends OneShotEffect {
|
|||
if (player.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) {
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
if (card != null) {
|
||||
player.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId());
|
||||
return true;
|
||||
return player.moveCards(card, Zone.BATTLEFIELD, source, game);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if(this.staticText != null && !this.staticText.isEmpty()) {
|
||||
if (this.staticText != null && !this.staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
|
||||
if(useTargetController) {
|
||||
if (useTargetController) {
|
||||
return "that player may put " + filter.getMessage() + " from his or her hand onto the battlefield";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return "you may put " + filter.getMessage() + " from your hand onto the battlefield";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.RedirectionEffect;
|
||||
import mage.constants.Duration;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class RedirectDamageFromSourceToTargetEffect extends RedirectionEffect {
|
||||
|
||||
public RedirectDamageFromSourceToTargetEffect(Duration duration, int amountToRedirect, boolean oneUsage) {
|
||||
super(duration, amountToRedirect, oneUsage);
|
||||
staticText = "The next " + amountToRedirect + " damage that would be dealt to {this} this turn is dealt to target creature you control instead.";
|
||||
}
|
||||
|
||||
public RedirectDamageFromSourceToTargetEffect(final RedirectDamageFromSourceToTargetEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedirectDamageFromSourceToTargetEffect copy() {
|
||||
return new RedirectDamageFromSourceToTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getTargetId().equals(source.getSourceId())) {
|
||||
this.redirectTarget = source.getTargets().get(0);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LoneFox
|
||||
*/
|
||||
public class RemoveAllCountersSourceEffect extends OneShotEffect {
|
||||
|
||||
private final CounterType counterType;
|
||||
|
||||
public RemoveAllCountersSourceEffect(CounterType counterType) {
|
||||
super(Outcome.Neutral);
|
||||
this.counterType = counterType;
|
||||
staticText = "remove all " + counterType.getName() + " counters from it.";
|
||||
}
|
||||
|
||||
public RemoveAllCountersSourceEffect(final RemoveAllCountersSourceEffect effect) {
|
||||
super(effect);
|
||||
this.counterType = effect.counterType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RemoveAllCountersSourceEffect copy() {
|
||||
return new RemoveAllCountersSourceEffect(this);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
if(sourcePermanent != null) {
|
||||
int count = sourcePermanent.getCounters().getCount(counterType);
|
||||
sourcePermanent.getCounters().removeCounter(counterType, count);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -30,7 +30,6 @@ package mage.abilities.effects.common;
|
|||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import static mage.constants.Zone.BATTLEFIELD;
|
||||
|
@ -103,14 +102,9 @@ public class ReturnFromExileForSourceEffect extends OneShotEffect {
|
|||
ExileZone exile = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter));
|
||||
if (exile != null) { // null is valid if source left battlefield before enters the battlefield effect resolved
|
||||
if (returnToZone.equals(Zone.BATTLEFIELD)) {
|
||||
for (Card card : exile.getCards(game)) {
|
||||
Player owner = game.getPlayer(card.getOwnerId());
|
||||
if (owner != null) {
|
||||
owner.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId());
|
||||
}
|
||||
}
|
||||
controller.moveCards(exile.getCards(game), returnToZone, source, game, false, false, true, null);
|
||||
} else {
|
||||
controller.moveCards(exile, Zone.EXILED, returnToZone, source, game);
|
||||
controller.moveCards(exile, null, returnToZone, source, game);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -73,7 +73,7 @@ public class ReturnFromGraveyardToBattlefieldTargetEffect extends OneShotEffect
|
|||
for (UUID targetId : getTargetPointer().getTargets(game, source)) {
|
||||
Card card = game.getCard(targetId);
|
||||
if (card != null) {
|
||||
controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId(), tapped);
|
||||
controller.moveCards(card, Zone.BATTLEFIELD, source, game, tapped, false, false, null);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
|
@ -20,19 +20,18 @@
|
|||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
|
@ -54,6 +53,7 @@ public class ReturnSourceFromGraveyardToBattlefieldEffect extends OneShotEffect
|
|||
this.tapped = tapped;
|
||||
setText();
|
||||
}
|
||||
|
||||
public ReturnSourceFromGraveyardToBattlefieldEffect(boolean tapped, boolean ownerControl) {
|
||||
super(Outcome.PutCreatureInPlay);
|
||||
this.tapped = tapped;
|
||||
|
@ -76,32 +76,31 @@ public class ReturnSourceFromGraveyardToBattlefieldEffect extends OneShotEffect
|
|||
public boolean apply(Game game, Ability source) {
|
||||
if (!game.getState().getZone(source.getSourceId()).equals(Zone.GRAVEYARD)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Card card = game.getCard(source.getSourceId());
|
||||
if (card == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Player player;
|
||||
|
||||
Player player;
|
||||
if (ownerControl) {
|
||||
player = game.getPlayer(card.getOwnerId());
|
||||
} else {
|
||||
player = game.getPlayer(source.getControllerId());
|
||||
}
|
||||
if (player == null) {
|
||||
}
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId(), tapped);
|
||||
}
|
||||
return player.moveCards(card, Zone.BATTLEFIELD, source, game, tapped, false, true, null);
|
||||
}
|
||||
|
||||
private void setText() {
|
||||
StringBuilder sb = new StringBuilder("return {this} from your graveyard to the battlefield");
|
||||
if (tapped) {
|
||||
sb.append(" tapped");
|
||||
}
|
||||
}
|
||||
if (ownerControl) {
|
||||
sb.append(" under its owner's control");
|
||||
sb.append(" under its owner's control");
|
||||
}
|
||||
staticText = sb.toString();
|
||||
}
|
||||
|
|
|
@ -88,8 +88,7 @@ public class ReturnToBattlefieldUnderYourControlTargetEffect extends OneShotEffe
|
|||
card = game.getCard(getTargetPointer().getFirst(game, source));
|
||||
}
|
||||
if (card != null) {
|
||||
Zone currentZone = game.getState().getZone(card.getId());
|
||||
controller.putOntoBattlefieldWithInfo(card, game, currentZone, source.getSourceId());
|
||||
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,29 +1,26 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.constants.Outcome;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: Loki
|
||||
* Date: 21.12.10
|
||||
* Time: 9:21
|
||||
* Created by IntelliJ IDEA. User: Loki Date: 21.12.10 Time: 9:21
|
||||
*/
|
||||
public class SacrificeSourceUnlessPaysEffect extends OneShotEffect {
|
||||
|
||||
protected Cost cost;
|
||||
|
||||
public SacrificeSourceUnlessPaysEffect(Cost cost) {
|
||||
super(Outcome.Sacrifice);
|
||||
this.cost = cost;
|
||||
}
|
||||
}
|
||||
|
||||
public SacrificeSourceUnlessPaysEffect(final SacrificeSourceUnlessPaysEffect effect) {
|
||||
super(effect);
|
||||
|
@ -33,14 +30,13 @@ public class SacrificeSourceUnlessPaysEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (sourceObject != null && player != null && permanent != null) {
|
||||
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
if (player != null && sourcePermanent != null) {
|
||||
StringBuilder sb = new StringBuilder(cost.getText()).append("?");
|
||||
if (!sb.toString().toLowerCase().startsWith("exile ") && !sb.toString().toLowerCase().startsWith("return ") ) {
|
||||
if (!sb.toString().toLowerCase().startsWith("exile ") && !sb.toString().toLowerCase().startsWith("return ")) {
|
||||
sb.insert(0, "Pay ");
|
||||
}
|
||||
String message = CardUtil.replaceSourceName(sb.toString(), sourceObject.getLogName());
|
||||
String message = CardUtil.replaceSourceName(sb.toString(), sourcePermanent.getLogName());
|
||||
message = Character.toUpperCase(message.charAt(0)) + message.substring(1);
|
||||
if (player.chooseUse(Outcome.Benefit, message, source, game)) {
|
||||
cost.clearPaid();
|
||||
|
@ -48,7 +44,7 @@ public class SacrificeSourceUnlessPaysEffect extends OneShotEffect {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
permanent.sacrifice(source.getSourceId(), game);
|
||||
sourcePermanent.sacrifice(source.getSourceId(), game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -61,7 +57,7 @@ public class SacrificeSourceUnlessPaysEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if(staticText != null && !staticText.isEmpty()) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
|
||||
|
@ -74,11 +70,10 @@ public class SacrificeSourceUnlessPaysEffect extends OneShotEffect {
|
|||
|| costText.toLowerCase().startsWith("sacrifice")) {
|
||||
sb.append(costText.substring(0, 1).toLowerCase());
|
||||
sb.append(costText.substring(1));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sb.append("pay ").append(costText);
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,37 +1,35 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.MageSingleton;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
|
@ -59,15 +57,15 @@ public class ShuffleSpellEffect extends OneShotEffect implements MageSingleton {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Spell spell = game.getStack().getSpell(source.getSourceId());
|
||||
// We have to use the spell id because in case of copied spells, the sourceId can be multiple times on the stack
|
||||
Spell spell = game.getStack().getSpell(source.getId());
|
||||
if (spell != null) {
|
||||
Card spellCard = spell.getCard();
|
||||
if (spellCard != null) {
|
||||
Player owner = game.getPlayer(spellCard.getOwnerId());
|
||||
if (controller.moveCards(spell, Zone.LIBRARY, source, game) && !spell.isCopy()) {
|
||||
Player owner = game.getPlayer(spell.getCard().getOwnerId());
|
||||
if (owner != null) {
|
||||
controller.moveCardToLibraryWithInfo(spellCard, source.getSourceId(), game, Zone.STACK, true, true);
|
||||
owner.shuffleLibrary(game);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -1,36 +1,35 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.constants.Outcome;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
|
@ -39,6 +38,7 @@ import mage.game.permanent.Permanent;
|
|||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class TapSourceEffect extends OneShotEffect {
|
||||
|
||||
private boolean withoutTrigger;
|
||||
|
||||
public TapSourceEffect() {
|
||||
|
@ -64,6 +64,9 @@ public class TapSourceEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent == null) {
|
||||
permanent = game.getPermanentEntering(source.getSourceId());
|
||||
}
|
||||
if (permanent != null) {
|
||||
if (withoutTrigger) {
|
||||
permanent.setTapped(true);
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
|
@ -20,17 +20,17 @@
|
|||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
@ -59,7 +59,10 @@ public class TapSourceUnlessPaysEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (player != null && permanent != null) {
|
||||
if (permanent == null && source.getAbilityType().equals(AbilityType.STATIC)) {
|
||||
permanent = game.getPermanentEntering(source.getSourceId());
|
||||
}
|
||||
if (player != null && permanent != null) {
|
||||
if (cost.canPay(source, source.getSourceId(), source.getControllerId(), game)
|
||||
&& player.chooseUse(Outcome.Benefit, cost.getText() + "? (otherwise " + permanent.getName() + " becomes tapped)", source, game)) {
|
||||
cost.clearPaid();
|
||||
|
@ -78,5 +81,4 @@ public class TapSourceUnlessPaysEffect extends OneShotEffect {
|
|||
return new TapSourceUnlessPaysEffect(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.effects.common.combat;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.RestrictionEffect;
|
||||
import mage.constants.Duration;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class CantBeBlockedByAllTargetEffect extends RestrictionEffect {
|
||||
|
||||
private final FilterCreaturePermanent filterBlockedBy;
|
||||
|
||||
public CantBeBlockedByAllTargetEffect(FilterCreaturePermanent filterBlockedBy, Duration duration) {
|
||||
super(Duration.WhileOnBattlefield);
|
||||
this.filterBlockedBy = filterBlockedBy;
|
||||
staticText = "Target creature"
|
||||
+ " can't be blocked "
|
||||
+ (filterBlockedBy.getMessage().startsWith("except by") ? "" : "by ")
|
||||
+ filterBlockedBy.getMessage();
|
||||
}
|
||||
|
||||
public CantBeBlockedByAllTargetEffect(final CantBeBlockedByAllTargetEffect effect) {
|
||||
super(effect);
|
||||
this.filterBlockedBy = effect.filterBlockedBy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
return getTargetPointer().getTargets(game, source).contains(permanent.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
|
||||
return !filterBlockedBy.match(blocker, source.getSourceId(), source.getControllerId(), game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CantBeBlockedByAllTargetEffect copy() {
|
||||
return new CantBeBlockedByAllTargetEffect(this);
|
||||
}
|
||||
}
|
|
@ -25,7 +25,6 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
@ -42,7 +41,7 @@ import mage.game.permanent.Permanent;
|
|||
* @author nantuko
|
||||
*/
|
||||
public class AddCardSubTypeTargetEffect extends ContinuousEffectImpl {
|
||||
|
||||
|
||||
private final String addedSubType;
|
||||
|
||||
public AddCardSubTypeTargetEffect(String addedSubType, Duration duration) {
|
||||
|
|
|
@ -36,7 +36,6 @@ import mage.abilities.mana.BlueManaAbility;
|
|||
import mage.abilities.mana.GreenManaAbility;
|
||||
import mage.abilities.mana.RedManaAbility;
|
||||
import mage.abilities.mana.WhiteManaAbility;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
|
@ -46,6 +45,24 @@ import mage.game.permanent.Permanent;
|
|||
|
||||
public class BecomesBasicLandEnchantedEffect extends ContinuousEffectImpl {
|
||||
|
||||
protected final static ArrayList<String> allLandTypes = new ArrayList<>();
|
||||
|
||||
static { // 205.3i
|
||||
allLandTypes.add("Forest");
|
||||
allLandTypes.add("Swamp");
|
||||
allLandTypes.add("Plains");
|
||||
allLandTypes.add("Mountains");
|
||||
allLandTypes.add("Island");
|
||||
allLandTypes.add("Urza's");
|
||||
allLandTypes.add("Mine");
|
||||
allLandTypes.add("Power-Plant");
|
||||
allLandTypes.add("Tower");
|
||||
allLandTypes.add("Desert");
|
||||
allLandTypes.add("Gate");
|
||||
allLandTypes.add("Lair");
|
||||
allLandTypes.add("Locus");
|
||||
}
|
||||
|
||||
protected ArrayList<String> landTypes = new ArrayList<>();
|
||||
|
||||
public BecomesBasicLandEnchantedEffect(String... landNames) {
|
||||
|
@ -76,13 +93,6 @@ public class BecomesBasicLandEnchantedEffect extends ContinuousEffectImpl {
|
|||
Permanent permanent = game.getPermanent(enchantment.getAttachedTo());
|
||||
if (permanent != null) {
|
||||
switch (layer) {
|
||||
case ColorChangingEffects_5:
|
||||
permanent.getColor(game).setWhite(false);
|
||||
permanent.getColor(game).setGreen(false);
|
||||
permanent.getColor(game).setBlack(false);
|
||||
permanent.getColor(game).setBlue(false);
|
||||
permanent.getColor(game).setRed(false);
|
||||
break;
|
||||
case AbilityAddingRemovingEffects_6:
|
||||
permanent.removeAllAbilities(source.getSourceId(), game);
|
||||
for (String landType : landTypes) {
|
||||
|
@ -106,9 +116,8 @@ public class BecomesBasicLandEnchantedEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
break;
|
||||
case TypeChangingEffects_4:
|
||||
permanent.getCardType().clear();
|
||||
permanent.getCardType().add(CardType.LAND);
|
||||
permanent.getSubtype().clear();
|
||||
// subtypes are all removed by changing the subtype to a land type.
|
||||
permanent.getSubtype().removeAll(allLandTypes);
|
||||
permanent.getSubtype().addAll(landTypes);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -44,14 +44,14 @@ import mage.target.targetpointer.FixedTarget;
|
|||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class BecomesColorOrColorsTargetEffect extends OneShotEffect {
|
||||
|
||||
Duration duration;
|
||||
|
||||
/**
|
||||
* This effect let the controller choose one or more colors the target will
|
||||
* become to.
|
||||
* Use effect.setText() if case you use a targetPointer, otherwise the rule text will be empty.
|
||||
* become to. Use effect.setText() if case you use a targetPointer,
|
||||
* otherwise the rule text will be empty.
|
||||
*
|
||||
* @param duration
|
||||
*/
|
||||
|
@ -81,8 +81,9 @@ public class BecomesColorOrColorsTargetEffect extends OneShotEffect {
|
|||
if (!controller.canRespond()) {
|
||||
return false;
|
||||
}
|
||||
if (!game.isSimulation())
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(target.getName() + ": " + controller.getLogName() + " has chosen " + choiceColor.getChoice());
|
||||
}
|
||||
if (choiceColor.getColor().isBlack()) {
|
||||
sb.append("B");
|
||||
} else if (choiceColor.getColor().isBlue()) {
|
||||
|
@ -119,7 +120,7 @@ public class BecomesColorOrColorsTargetEffect extends OneShotEffect {
|
|||
StringBuilder sb = new StringBuilder();
|
||||
if (mode.getTargets().size() > 0) {
|
||||
sb.append("target ");
|
||||
sb.append(mode.getTargets().get(0).getMessage());
|
||||
sb.append(mode.getTargets().get(0).getFilter().getMessage());
|
||||
sb.append(" becomes the color or colors of your choice");
|
||||
if (duration.toString().length() > 0) {
|
||||
sb.append(" ").append(duration.toString());
|
||||
|
|
|
@ -108,6 +108,12 @@ public class CommanderReplacementEffect extends ReplacementEffectImpl {
|
|||
}
|
||||
case GRAVEYARD:
|
||||
case EXILED:
|
||||
if (((ZoneChangeEvent) event).getFromZone().equals(Zone.STACK)) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell != null && commanderId.equals(spell.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (commanderId.equals(event.getTargetId())) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
|
@ -20,7 +20,7 @@
|
|||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
|
@ -88,12 +88,17 @@ public class GainAbilitySourceEffect extends ContinuousEffectImpl implements Sou
|
|||
public GainAbilitySourceEffect copy() {
|
||||
return new GainAbilitySourceEffect(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
if (affectedObjectsSet) {
|
||||
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game));
|
||||
Permanent permanent = game.getPermanentEntering(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game.getState().getZoneChangeCounter(source.getSourceId()) + 1, game));
|
||||
} else {
|
||||
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,36 +17,36 @@ import mage.game.permanent.Permanent;
|
|||
* @author Noahsark
|
||||
*/
|
||||
public class LoseAbilitySourceEffect extends ContinuousEffectImpl{
|
||||
|
||||
|
||||
protected Ability ability;
|
||||
|
||||
|
||||
public LoseAbilitySourceEffect(Ability ability){
|
||||
this(ability, Duration.WhileOnBattlefield);
|
||||
}
|
||||
|
||||
|
||||
public LoseAbilitySourceEffect(Ability ability, Duration duration){
|
||||
super(duration, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.LoseAbility);
|
||||
this.ability = ability;
|
||||
staticText = "{this} loses " + ability.getRule() + duration.toString();
|
||||
staticText = "{this} loses " + ability.getRule() + " " + duration.toString();
|
||||
}
|
||||
|
||||
|
||||
public LoseAbilitySourceEffect(final LoseAbilitySourceEffect effect){
|
||||
super(effect);
|
||||
this.ability = effect.ability.copy();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public LoseAbilitySourceEffect copy(){
|
||||
return new LoseAbilitySourceEffect(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source){
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null){
|
||||
// 112.10
|
||||
while (permanent.getAbilities().remove(ability)) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
|
@ -20,12 +20,11 @@
|
|||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.MageObject;
|
||||
|
@ -37,7 +36,6 @@ import mage.constants.Layer;
|
|||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -76,17 +74,18 @@ public class SetPowerToughnessSourceEffect extends ContinuousEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
MageObject mageObject = game.getObject(source.getSourceId());
|
||||
MageObject mageObject = game.getPermanentEntering(source.getSourceId());
|
||||
if (mageObject == null) {
|
||||
if (duration.equals(Duration.Custom)) {
|
||||
discard();
|
||||
}
|
||||
return false;
|
||||
} else if (isTemporary()) { // it's somehow w
|
||||
if (!(mageObject instanceof Permanent)) {
|
||||
return false;
|
||||
if (duration.equals(Duration.Custom) || isTemporary()) {
|
||||
mageObject = game.getPermanent(source.getSourceId());
|
||||
} else {
|
||||
mageObject = game.getObject(source.getSourceId());
|
||||
}
|
||||
}
|
||||
if (mageObject == null) {
|
||||
discard();
|
||||
return true;
|
||||
}
|
||||
if (amount != null) {
|
||||
int value = amount.calculate(game, source, this);
|
||||
mageObject.getPower().setValue(value);
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
|
@ -20,20 +20,20 @@
|
|||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects.common.counter;
|
||||
|
||||
import mage.constants.Outcome;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.counters.Counter;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
@ -63,11 +63,12 @@ public class AddCountersSourceEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param counter
|
||||
* @param amount this amount will be added to the counter instances
|
||||
* @param informPlayers
|
||||
* @param putOnCard - counters have to be put on a card instead of a permanent
|
||||
* @param putOnCard - counters have to be put on a card instead of a
|
||||
* permanent
|
||||
*/
|
||||
public AddCountersSourceEffect(Counter counter, DynamicValue amount, boolean informPlayers, boolean putOnCard) {
|
||||
super(Outcome.Benefit);
|
||||
|
@ -106,7 +107,7 @@ public class AddCountersSourceEffect extends OneShotEffect {
|
|||
if (informPlayers && !game.isSimulation()) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
game.informPlayers(new StringBuilder(player.getLogName()).append(" puts ").append(newCounter.getCount()).append(" ").append(newCounter.getName().toLowerCase()).append(" counter on ").append(card.getLogName()).toString());
|
||||
game.informPlayers(player.getLogName() + " puts " + newCounter.getCount() + " " + newCounter.getName().toLowerCase() + " counter on " + card.getLogName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -114,6 +115,9 @@ public class AddCountersSourceEffect extends OneShotEffect {
|
|||
}
|
||||
} else {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent == null && source.getAbilityType().equals(AbilityType.STATIC)) {
|
||||
permanent = game.getPermanentEntering(source.getSourceId());
|
||||
}
|
||||
if (permanent != null) {
|
||||
if (counter != null) {
|
||||
Counter newCounter = counter.copy();
|
||||
|
@ -129,7 +133,7 @@ public class AddCountersSourceEffect extends OneShotEffect {
|
|||
int amountAdded = permanent.getCounters().getCount(newCounter.getName()) - before;
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
game.informPlayers(player.getLogName()+" puts "+amountAdded+" "+newCounter.getName().toLowerCase()+" counter on "+permanent.getLogName());
|
||||
game.informPlayers(player.getLogName() + " puts " + amountAdded + " " + newCounter.getName().toLowerCase() + " counter on " + permanent.getLogName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -165,5 +169,4 @@ public class AddCountersSourceEffect extends OneShotEffect {
|
|||
return new AddCountersSourceEffect(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,38 +1,37 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.effects.common.search;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.SearchEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
|
@ -90,12 +89,8 @@ public class SearchLibraryPutInPlayEffect extends SearchEffect {
|
|||
}
|
||||
if (player.searchLibrary(target, game)) {
|
||||
if (target.getTargets().size() > 0) {
|
||||
for (UUID cardId: target.getTargets()) {
|
||||
Card card = player.getLibrary().getCard(cardId, game);
|
||||
if (card != null) {
|
||||
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), tapped);
|
||||
}
|
||||
}
|
||||
player.moveCards(new CardsImpl(target.getTargets()).getCards(game),
|
||||
Zone.BATTLEFIELD, source, game, tapped, false, false, null);
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
return true;
|
||||
|
@ -110,15 +105,13 @@ public class SearchLibraryPutInPlayEffect extends SearchEffect {
|
|||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("search your library for ");
|
||||
if (target.getNumberOfTargets() == 0 && target.getMaxNumberOfTargets() > 0) {
|
||||
if ( target.getMaxNumberOfTargets() == Integer.MAX_VALUE ) {
|
||||
if (target.getMaxNumberOfTargets() == Integer.MAX_VALUE) {
|
||||
sb.append("any number of ").append(" ");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sb.append("up to ").append(target.getMaxNumberOfTargets()).append(" ");
|
||||
}
|
||||
sb.append(target.getTargetName()).append(" and put them onto the battlefield");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sb.append("a ").append(target.getTargetName()).append(" and put it onto the battlefield");
|
||||
}
|
||||
if (tapped) {
|
||||
|
@ -126,8 +119,7 @@ public class SearchLibraryPutInPlayEffect extends SearchEffect {
|
|||
}
|
||||
if (forceShuffle) {
|
||||
sb.append(". Then shuffle your library");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sb.append(". If you do, shuffle your library");
|
||||
}
|
||||
staticText = sb.toString();
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.util.List;
|
|||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.SearchEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
|
@ -20,11 +20,11 @@ import mage.target.common.TargetCardInLibrary;
|
|||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class SearchLibraryPutInPlayTargetPlayerEffect extends SearchEffect {
|
||||
|
||||
protected boolean tapped;
|
||||
protected boolean forceShuffle;
|
||||
protected boolean ownerIsController;
|
||||
|
||||
public SearchLibraryPutInPlayTargetPlayerEffect(TargetCardInLibrary target) {
|
||||
this(target, false, true, Outcome.PutCardInPlay);
|
||||
|
@ -43,9 +43,14 @@ public class SearchLibraryPutInPlayTargetPlayerEffect extends SearchEffect {
|
|||
}
|
||||
|
||||
public SearchLibraryPutInPlayTargetPlayerEffect(TargetCardInLibrary target, boolean tapped, boolean forceShuffle, Outcome outcome) {
|
||||
this(target, tapped, forceShuffle, outcome, false);
|
||||
}
|
||||
|
||||
public SearchLibraryPutInPlayTargetPlayerEffect(TargetCardInLibrary target, boolean tapped, boolean forceShuffle, Outcome outcome, boolean ownerIsController) {
|
||||
super(target, outcome);
|
||||
this.tapped = tapped;
|
||||
this.forceShuffle = forceShuffle;
|
||||
this.ownerIsController = ownerIsController;
|
||||
setText();
|
||||
}
|
||||
|
||||
|
@ -53,6 +58,7 @@ public class SearchLibraryPutInPlayTargetPlayerEffect extends SearchEffect {
|
|||
super(effect);
|
||||
this.tapped = effect.tapped;
|
||||
this.forceShuffle = effect.forceShuffle;
|
||||
this.ownerIsController = effect.ownerIsController;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -62,26 +68,22 @@ public class SearchLibraryPutInPlayTargetPlayerEffect extends SearchEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
|
||||
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
|
||||
if (player != null) {
|
||||
if (player.searchLibrary(target, game)) {
|
||||
if (target.getTargets().size() > 0) {
|
||||
for (UUID cardId: target.getTargets()) {
|
||||
Card card = player.getLibrary().getCard(cardId, game);
|
||||
if (card != null) {
|
||||
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), tapped);
|
||||
}
|
||||
}
|
||||
player.moveCards(new CardsImpl(target.getTargets()).getCards(game),
|
||||
Zone.BATTLEFIELD, source, game, tapped, false, ownerIsController, null);
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (forceShuffle) {
|
||||
player.shuffleLibrary(game);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -89,15 +91,13 @@ public class SearchLibraryPutInPlayTargetPlayerEffect extends SearchEffect {
|
|||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("target player searches his or her library for ");
|
||||
if (target.getNumberOfTargets() == 0 && target.getMaxNumberOfTargets() > 0) {
|
||||
if ( target.getMaxNumberOfTargets() == Integer.MAX_VALUE ) {
|
||||
if (target.getMaxNumberOfTargets() == Integer.MAX_VALUE) {
|
||||
sb.append("any number of ").append(" ");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sb.append("up to ").append(target.getMaxNumberOfTargets()).append(" ");
|
||||
}
|
||||
sb.append(target.getTargetName()).append(" and put them onto the battlefield");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sb.append("a ").append(target.getTargetName()).append(" and put it onto the battlefield");
|
||||
}
|
||||
if (tapped) {
|
||||
|
@ -105,8 +105,7 @@ public class SearchLibraryPutInPlayTargetPlayerEffect extends SearchEffect {
|
|||
}
|
||||
if (forceShuffle) {
|
||||
sb.append(". Then that player shuffles his or her library");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sb.append(". If that player does, he or she shuffles his or her library");
|
||||
}
|
||||
staticText = sb.toString();
|
||||
|
|
|
@ -27,12 +27,10 @@
|
|||
*/
|
||||
package mage.abilities.effects.common.search;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.Outcome;
|
||||
|
@ -98,14 +96,7 @@ public abstract class SearchTargetGraveyardHandLibraryForCardNameAndExileEffect
|
|||
filter.setMessage("card named " + cardName + " in the graveyard of " + targetPlayer.getLogName());
|
||||
TargetCard target = new TargetCard((graveyardExileOptional ? 0 : cardsCount), cardsCount, Zone.GRAVEYARD, filter);
|
||||
if (controller.choose(Outcome.Exile, targetPlayer.getGraveyard(), target, game)) {
|
||||
List<UUID> targets = target.getTargets();
|
||||
for (UUID targetId : targets) {
|
||||
Card targetCard = targetPlayer.getGraveyard().get(targetId, game);
|
||||
if (targetCard != null) {
|
||||
targetPlayer.getGraveyard().remove(targetCard);
|
||||
controller.moveCardToExileWithInfo(targetCard, null, null, source.getSourceId(), game, Zone.GRAVEYARD, true);
|
||||
}
|
||||
}
|
||||
controller.moveCards(new CardsImpl(target.getTargets()), Zone.EXILED, source, game);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,14 +105,7 @@ public abstract class SearchTargetGraveyardHandLibraryForCardNameAndExileEffect
|
|||
filter.setMessage("card named " + cardName + " in the hand of " + targetPlayer.getLogName());
|
||||
TargetCard target = new TargetCard(0, cardsCount, Zone.HAND, filter);
|
||||
if (controller.choose(Outcome.Exile, targetPlayer.getHand(), target, game)) {
|
||||
List<UUID> targets = target.getTargets();
|
||||
for (UUID targetId : targets) {
|
||||
Card targetCard = targetPlayer.getHand().get(targetId, game);
|
||||
if (targetCard != null) {
|
||||
targetPlayer.getHand().remove(targetCard);
|
||||
controller.moveCardToExileWithInfo(targetCard, null, null, source.getSourceId(), game, Zone.HAND, true);
|
||||
}
|
||||
}
|
||||
controller.moveCards(new CardsImpl(target.getTargets()), Zone.EXILED, source, game);
|
||||
}
|
||||
|
||||
// cards in Library
|
||||
|
@ -131,15 +115,8 @@ public abstract class SearchTargetGraveyardHandLibraryForCardNameAndExileEffect
|
|||
filter.setMessage("card named " + cardName + " in the library of " + targetPlayer.getLogName());
|
||||
TargetCardInLibrary targetLib = new TargetCardInLibrary(0, cardsCount, filter);
|
||||
if (controller.choose(Outcome.Exile, cardsInLibrary, targetLib, game)) {
|
||||
List<UUID> targets = targetLib.getTargets();
|
||||
for (UUID targetId : targets) {
|
||||
Card targetCard = targetPlayer.getLibrary().remove(targetId, game);
|
||||
if (targetCard != null) {
|
||||
controller.moveCardToExileWithInfo(targetCard, null, null, source.getSourceId(), game, Zone.LIBRARY, true);
|
||||
}
|
||||
}
|
||||
controller.moveCards(new CardsImpl(targetLib.getTargets()), Zone.EXILED, source, game);
|
||||
}
|
||||
|
||||
targetPlayer.shuffleLibrary(game);
|
||||
}
|
||||
|
||||
|
|
|
@ -86,13 +86,15 @@ public class ManifestEffect extends OneShotEffect {
|
|||
}
|
||||
MageObjectReference objectReference = new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) + 1, game);
|
||||
game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource);
|
||||
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, newSource.getSourceId(), false, true);
|
||||
|
||||
}
|
||||
controller.moveCards(cards, Zone.BATTLEFIELD, source, game, false, true, false, null);
|
||||
for (Card card : cards) {
|
||||
Permanent permanent = game.getPermanent(card.getId());
|
||||
if (permanent != null) {
|
||||
permanent.setManifested(true);
|
||||
}
|
||||
}
|
||||
game.applyEffects(); // to apply before ETB triggered or replace Effects are executed
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -89,7 +89,9 @@ public class ManifestTargetPlayerEffect extends OneShotEffect {
|
|||
}
|
||||
MageObjectReference objectReference = new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) + 1, game);
|
||||
game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource);
|
||||
targetPlayer.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, newSource.getSourceId(), false, true);
|
||||
}
|
||||
targetPlayer.moveCards(cards, Zone.BATTLEFIELD, source, game, false, true, false, null);
|
||||
for (Card card : cards) {
|
||||
Permanent permanent = game.getPermanent(card.getId());
|
||||
if (permanent != null) {
|
||||
permanent.setManifested(true);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue