diff --git a/Mage/src/mage/abilities/effects/common/GetEmblemEffect.java b/Mage/src/mage/abilities/effects/common/GetEmblemEffect.java new file mode 100644 index 00000000000..62dcd2b8787 --- /dev/null +++ b/Mage/src/mage/abilities/effects/common/GetEmblemEffect.java @@ -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.Constants.Outcome; +import mage.abilities.Ability; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.dynamicvalue.common.StaticValue; +import mage.abilities.effects.OneShotEffect; +import mage.game.Game; +import mage.game.command.Emblem; +import mage.game.permanent.token.Token; + +/** + * + * @author nantuko + */ +public class GetEmblemEffect extends OneShotEffect { + + private Emblem emblem; + + public GetEmblemEffect(Emblem emblem) { + super(Outcome.Benefit); + this.emblem = emblem; + this.staticText = "You get an emblem with \"" + emblem.getAbilities().getRules(null) + "\""; + } + + public GetEmblemEffect(final GetEmblemEffect effect) { + super(effect); + this.emblem = effect.emblem; + } + + @Override + public GetEmblemEffect copy() { + return new GetEmblemEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Emblem newEmblem = this.emblem.copy(); + newEmblem.setSourceId(source.getSourceId()); + newEmblem.setControllerId(source.getControllerId()); + game.getState().getCommand().add(newEmblem); + return true; + } + +} diff --git a/Mage/src/mage/game/GameState.java b/Mage/src/mage/game/GameState.java index 0cc755dfe29..66dfd888f62 100644 --- a/Mage/src/mage/game/GameState.java +++ b/Mage/src/mage/game/GameState.java @@ -212,6 +212,10 @@ public class GameState implements Serializable, Copyable { return exile; } + public Command getCommand() { + return command; + } + public Revealed getRevealed() { return revealed; } diff --git a/Mage/src/mage/game/command/CommandObject.java b/Mage/src/mage/game/command/CommandObject.java index c0d422ebeec..fbc9d7d6912 100644 --- a/Mage/src/mage/game/command/CommandObject.java +++ b/Mage/src/mage/game/command/CommandObject.java @@ -28,6 +28,7 @@ package mage.game.command; +import mage.abilities.Ability; import mage.game.*; import java.util.UUID; import mage.MageObject; @@ -35,9 +36,8 @@ import mage.game.events.GameEvent; /** * -* @author Viserion +* @author Viserion, nantuko */ - public interface CommandObject extends MageObject { public UUID getSourceId(); diff --git a/Mage/src/mage/game/command/Emblem.java b/Mage/src/mage/game/command/Emblem.java new file mode 100644 index 00000000000..1b13c13248d --- /dev/null +++ b/Mage/src/mage/game/command/Emblem.java @@ -0,0 +1,165 @@ +/* +* 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.game.command; + +import mage.Constants; +import mage.MageInt; +import mage.ObjectColor; +import mage.abilities.Abilities; +import mage.abilities.AbilitiesImpl; +import mage.abilities.Ability; +import mage.abilities.TriggeredAbility; +import mage.abilities.costs.Costs; +import mage.abilities.costs.CostsImpl; +import mage.abilities.costs.mana.ManaCost; +import mage.abilities.costs.mana.ManaCosts; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.game.Game; +import mage.game.events.GameEvent; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +/** + * @author nantuko + */ +public class Emblem implements CommandObject { + + private static List emptyList = new ArrayList(); + private static ObjectColor emptyColor = new ObjectColor(); + private static ManaCosts emptyCost = new ManaCostsImpl(); + + + private UUID id; + private UUID controllerId; + private UUID sourceId; + private Abilities abilites = new AbilitiesImpl(); + + public Emblem() { + this.id = UUID.randomUUID(); + } + + public Emblem(Emblem emblem) { + this.id = emblem.id; + this.controllerId = emblem.controllerId; + this.sourceId = emblem.sourceId; + this.abilites = emblem.abilites.copy(); + } + + @Override + public UUID getSourceId() { + return this.sourceId; + } + + @Override + public UUID getControllerId() { + return this.controllerId; + } + + public void setControllerId(UUID controllerId) { + this.controllerId = controllerId; + } + + public void setSourceId(UUID sourceId) { + this.sourceId = sourceId; + } + + @Override + public void checkTriggers(GameEvent event, Game game) { + // we have to use Zone.BATTLEFIELD to use the same predefined abilities (like SpellCastTriggeredAbility) + // and not create duplicates + for (TriggeredAbility ability: getAbilities().getTriggeredAbilities(Constants.Zone.BATTLEFIELD)) { + ability.setControllerId(getControllerId()); + ability.setSourceId(getSourceId()); + if (ability.checkTrigger(event, game)) { + ability.trigger(game, getControllerId()); + } + } + } + + @Override + public String getName() { + return ""; + } + + @Override + public void setName(String name) {} + + @Override + public List getCardType() { + return emptyList; + } + + @Override + public List getSubtype() { + return emptyList; + } + + @Override + public List getSupertype() { + return emptyList; + } + + @Override + public Abilities getAbilities() { + return abilites; + } + + @Override + public ObjectColor getColor() { + return emptyColor; + } + + @Override + public ManaCosts getManaCost() { + return emptyCost; + } + + @Override + public MageInt getPower() { + return MageInt.EmptyMageInt; + } + + @Override + public MageInt getToughness() { + return MageInt.EmptyMageInt; + } + + @Override + public void adjustCosts(Ability ability, Game game) {} + + @Override + public UUID getId() { + return this.id; + } + + public Emblem copy() { + return new Emblem(this); + } +}