Emblems. GetEmblemEffect.

This commit is contained in:
magenoxx 2011-08-03 19:16:39 +04:00
parent 9f7720b69e
commit 1751a588a0
4 changed files with 244 additions and 2 deletions

View file

@ -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<GetEmblemEffect> {
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;
}
}

View file

@ -212,6 +212,10 @@ public class GameState implements Serializable, Copyable<GameState> {
return exile;
}
public Command getCommand() {
return command;
}
public Revealed getRevealed() {
return revealed;
}

View file

@ -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();

View file

@ -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<Ability> abilites = new AbilitiesImpl<Ability>();
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<Constants.CardType> getCardType() {
return emptyList;
}
@Override
public List<String> getSubtype() {
return emptyList;
}
@Override
public List<String> getSupertype() {
return emptyList;
}
@Override
public Abilities<Ability> getAbilities() {
return abilites;
}
@Override
public ObjectColor getColor() {
return emptyColor;
}
@Override
public ManaCosts<ManaCost> 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);
}
}