mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
Merge branch 'master' of https://github.com/magefree/mage.git
This commit is contained in:
commit
271872cfe5
9 changed files with 530 additions and 6 deletions
|
@ -96,7 +96,7 @@ class MimingSlimeEffect extends OneShotEffect<MimingSlimeEffect> {
|
|||
amount = power;
|
||||
}
|
||||
}
|
||||
MysticGenesisOozeToken oozeToken = new MysticGenesisOozeToken();
|
||||
OozeToken oozeToken = new OozeToken();
|
||||
oozeToken.getPower().setValue(amount);
|
||||
oozeToken.getToughness().setValue(amount);
|
||||
oozeToken.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
||||
|
|
113
Mage.Sets/src/mage/sets/gatecrash/OozeFlux.java
Normal file
113
Mage.Sets/src/mage/sets/gatecrash/OozeFlux.java
Normal file
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* 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.sets.gatecrash;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.common.RemoveVariableCountersTargetCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.token.Token;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class OozeFlux extends CardImpl<OozeFlux> {
|
||||
|
||||
public OozeFlux(UUID ownerId) {
|
||||
super(ownerId, 128, "Ooze Flux", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{G}");
|
||||
this.expansionSetCode = "GTC";
|
||||
|
||||
this.color.setGreen(true);
|
||||
|
||||
// {1}{G}, Remove one or more +1/+1 counters from among creatures you control: Put an X/X green Ooze creature token onto the battlefield, where X is the number of +1/+1 counters removed this way.
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new OozeFluxCreateTokenEffect(new OozeToken()),new ManaCostsImpl("{1}{G}"));
|
||||
ability.addCost(new RemoveVariableCountersTargetCost(
|
||||
new TargetControlledCreaturePermanent(1,Integer.MAX_VALUE,new FilterControlledCreaturePermanent(), true), CounterType.P1P1));
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
public OozeFlux(final OozeFlux card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OozeFlux copy() {
|
||||
return new OozeFlux(this);
|
||||
}
|
||||
}
|
||||
|
||||
class OozeFluxCreateTokenEffect extends OneShotEffect<OozeFluxCreateTokenEffect> {
|
||||
|
||||
private Token token;
|
||||
|
||||
public OozeFluxCreateTokenEffect(Token token) {
|
||||
super(Outcome.PutCreatureInPlay);
|
||||
this.token = token;
|
||||
staticText = "Put an X/X green Ooze creature token onto the battlefield, where X is the number of +1/+1 counters removed this way";
|
||||
}
|
||||
|
||||
public OozeFluxCreateTokenEffect(final OozeFluxCreateTokenEffect effect) {
|
||||
super(effect);
|
||||
this.token = effect.token.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public OozeFluxCreateTokenEffect copy() {
|
||||
return new OozeFluxCreateTokenEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int xValue = 0;
|
||||
for (Cost cost : source.getCosts()) {
|
||||
if (cost instanceof RemoveVariableCountersTargetCost) {
|
||||
xValue = ((RemoveVariableCountersTargetCost) cost).getAmount();
|
||||
break;
|
||||
}
|
||||
}
|
||||
Token tokenCopy = token.copy();
|
||||
tokenCopy.getAbilities().newId();
|
||||
tokenCopy.getPower().setValue(xValue);
|
||||
tokenCopy.getToughness().setValue(xValue);
|
||||
tokenCopy.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
||||
return true;
|
||||
}
|
||||
}
|
138
Mage.Sets/src/mage/sets/gatecrash/SimicManipulator.java
Normal file
138
Mage.Sets/src/mage/sets/gatecrash/SimicManipulator.java
Normal file
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* 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.sets.gatecrash;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Duration;
|
||||
import mage.Constants.Layer;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.SubLayer;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.keyword.EvolveAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
/**
|
||||
* Gatecrash FAQ (01.2013)
|
||||
*
|
||||
* The power of the target creature is checked both as you target it and as the ability
|
||||
* resolves. If the power of the target creature when the ability resolves is greater
|
||||
* than the number of +1/+1 counters removed from Simic Manipulator, the ability will
|
||||
* be countered and none of its effects will happen. You won't gain control of any
|
||||
* creature, but the counters removed as a cost remain removed.
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class SimicManipulator extends CardImpl<SimicManipulator> {
|
||||
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature with power less than or equal to the number of +1/+1 counters removed this way");
|
||||
|
||||
public SimicManipulator(UUID ownerId) {
|
||||
super(ownerId, 50, "Simic Manipulator", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{1}{U}{U}");
|
||||
this.expansionSetCode = "GTC";
|
||||
this.subtype.add("Mutant");
|
||||
this.subtype.add("Wizard");
|
||||
|
||||
this.color.setBlue(true);
|
||||
this.power = new MageInt(0);
|
||||
this.toughness = new MageInt(1);
|
||||
|
||||
// Evolve
|
||||
this.addAbility(new EvolveAbility());
|
||||
|
||||
// {tap}, Remove one or more +1/+1 counters from Simic Manipulator: Gain control of target creature with power less than or equal to the number of +1/+1 counters removed this way.
|
||||
// TODO: Improve targeting, that only valid targets (power <= removed counters) can be choosen
|
||||
// Disadvante now is, that a creature can be targeted that couldn't be targeted by rules.
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new SimicManipulatorGainControlTargetEffect(Duration.WhileOnBattlefield), new TapSourceCost());
|
||||
ability.addTarget(new TargetCreaturePermanent(filter));
|
||||
ability.addCost(new RemoveVariableCountersSourceCost(CounterType.P1P1.createInstance(),1));
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
public SimicManipulator(final SimicManipulator card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimicManipulator copy() {
|
||||
return new SimicManipulator(this);
|
||||
}
|
||||
}
|
||||
|
||||
class SimicManipulatorGainControlTargetEffect extends ContinuousEffectImpl<SimicManipulatorGainControlTargetEffect> {
|
||||
|
||||
public SimicManipulatorGainControlTargetEffect(Duration duration) {
|
||||
super(duration, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl);
|
||||
}
|
||||
|
||||
public SimicManipulatorGainControlTargetEffect(final SimicManipulatorGainControlTargetEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimicManipulatorGainControlTargetEffect copy() {
|
||||
return new SimicManipulatorGainControlTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getFirstTarget());
|
||||
if (permanent != null) {
|
||||
int maxPower = 0;
|
||||
for (Cost cost : source.getCosts()) {
|
||||
if (cost instanceof RemoveVariableCountersSourceCost) {
|
||||
maxPower = ((RemoveVariableCountersSourceCost) cost).getAmount();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (permanent.getPower().getValue() <= maxPower) {
|
||||
return permanent.changeControllerId(source.getControllerId(), game);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
return "Gain control of target " + mode.getTargets().get(0).getTargetName() + " " + duration.toString();
|
||||
}
|
||||
}
|
93
Mage.Sets/src/mage/sets/gatecrash/SoulRansom.java
Normal file
93
Mage.Sets/src/mage/sets/gatecrash/SoulRansom.java
Normal file
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* 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.sets.gatecrash;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.common.DiscardTargetCost;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.effects.common.DrawCardControllerEffect;
|
||||
import mage.abilities.effects.common.SacrificeSourceEffect;
|
||||
import mage.abilities.effects.common.continious.ControlEnchantedEffect;
|
||||
import mage.abilities.keyword.EnchantAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetCardInHand;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class SoulRansom extends CardImpl<SoulRansom> {
|
||||
|
||||
public SoulRansom(UUID ownerId) {
|
||||
super(ownerId, 198, "Soul Ransom", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}{B}");
|
||||
this.expansionSetCode = "GTC";
|
||||
this.subtype.add("Aura");
|
||||
|
||||
this.color.setBlue(true);
|
||||
this.color.setBlack(true);
|
||||
|
||||
// Enchant creature
|
||||
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
||||
this.getSpellAbility().addTarget(auraTarget);
|
||||
this.getSpellAbility().addEffect(new AttachEffect(Constants.Outcome.AddAbility));
|
||||
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
||||
this.addAbility(ability);
|
||||
// You control enchanted creature.
|
||||
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new ControlEnchantedEffect()));
|
||||
|
||||
// Discard two cards: Soul Ransom's controller sacrifices it, then draws two cards. Only any opponent may activate this ability.
|
||||
Effect effect = new SacrificeSourceEffect();
|
||||
effect.setText("{this}'s controller sacrifices it.");
|
||||
SimpleActivatedAbility ability2 = new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, effect , new DiscardTargetCost(new TargetCardInHand(2,2, new FilterCard("two cards"))));
|
||||
effect = new DrawCardControllerEffect(2);
|
||||
effect.setText("Then draws two cards. Only any opponent may activate this ability");
|
||||
ability2.addEffect(effect);
|
||||
ability2.setOnlyOpponentCanActivate(true);
|
||||
this.addAbility(ability2);
|
||||
|
||||
}
|
||||
|
||||
public SoulRansom(final SoulRansom card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoulRansom copy() {
|
||||
return new SoulRansom(this);
|
||||
}
|
||||
}
|
|
@ -196,6 +196,7 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
|||
// 20121001 - 601.2b
|
||||
// If the spell has a variable cost that will be paid as it's being cast (such as an {X} in
|
||||
// its mana cost; see rule 107.3), the player announces the value of that variable.
|
||||
// TODO: Handle announcing other variable costs here like: RemoveVariableCountersSourceCost
|
||||
if (game.getPlayer(this.controllerId).isHuman()) {
|
||||
// AI can't handle this yet. Uses old way of playXMana
|
||||
VariableManaCost variableManaCost = null;
|
||||
|
@ -276,7 +277,11 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
|||
}
|
||||
|
||||
//20100716 - 601.2g
|
||||
if (!costs.pay(this, game, sourceId, controllerId, noMana)) {
|
||||
UUID activatorId = controllerId;
|
||||
if (this instanceof ActivatedAbilityImpl) {
|
||||
activatorId = ((ActivatedAbilityImpl)this).getActivatorId();
|
||||
}
|
||||
if (!costs.pay(this, game, sourceId, activatorId, noMana)) {
|
||||
logger.debug("activate failed - non mana costs");
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -54,6 +54,8 @@ import mage.target.Target;
|
|||
public abstract class ActivatedAbilityImpl<T extends ActivatedAbilityImpl<T>> extends AbilityImpl<T> implements ActivatedAbility {
|
||||
|
||||
protected TimingRule timing = TimingRule.INSTANT;
|
||||
protected boolean onlyOpponentCanActivate = false;
|
||||
protected UUID activatorId;
|
||||
|
||||
protected ActivatedAbilityImpl(AbilityType abilityType, Zone zone) {
|
||||
super(abilityType, zone);
|
||||
|
@ -62,6 +64,8 @@ public abstract class ActivatedAbilityImpl<T extends ActivatedAbilityImpl<T>> ex
|
|||
public ActivatedAbilityImpl(ActivatedAbilityImpl ability) {
|
||||
super(ability);
|
||||
timing = ability.timing;
|
||||
onlyOpponentCanActivate = ability.onlyOpponentCanActivate;
|
||||
activatorId = ability.activatorId;
|
||||
}
|
||||
|
||||
public ActivatedAbilityImpl(Zone zone) {
|
||||
|
@ -152,12 +156,14 @@ public abstract class ActivatedAbilityImpl<T extends ActivatedAbilityImpl<T>> ex
|
|||
@Override
|
||||
public boolean canActivate(UUID playerId, Game game) {
|
||||
//20091005 - 602.2
|
||||
if (!controlsAbility(playerId, game)) {
|
||||
if ((!onlyOpponentCanActivate && !controlsAbility(playerId, game)) ||
|
||||
(onlyOpponentCanActivate && !game.getOpponents(controllerId).contains(playerId))) {
|
||||
return false;
|
||||
}
|
||||
//20091005 - 602.5d/602.5e
|
||||
if (timing == TimingRule.INSTANT || game.canPlaySorcery(playerId)) {
|
||||
if (costs.canPay(sourceId, controllerId, game) && canChooseTarget(game)) {
|
||||
this.activatorId = playerId;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -230,4 +236,12 @@ public abstract class ActivatedAbilityImpl<T extends ActivatedAbilityImpl<T>> ex
|
|||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public void setOnlyOpponentCanActivate(boolean onlyOpponentCanActivate) {
|
||||
this.onlyOpponentCanActivate = onlyOpponentCanActivate;
|
||||
}
|
||||
|
||||
public UUID getActivatorId() {
|
||||
return this.activatorId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,6 @@ import mage.target.TargetPermanent;
|
|||
public class RemoveCounterCost extends CostImpl<RemoveCounterCost> {
|
||||
|
||||
private TargetPermanent target;
|
||||
private int amount;
|
||||
private String name;
|
||||
private CounterType counterTypeToRemove;
|
||||
|
||||
|
@ -68,7 +67,6 @@ public class RemoveCounterCost extends CostImpl<RemoveCounterCost> {
|
|||
public RemoveCounterCost(final RemoveCounterCost cost) {
|
||||
super(cost);
|
||||
this.target = cost.target.copy();
|
||||
this.amount = cost.amount;
|
||||
this.name = cost.name;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,163 @@
|
|||
/*
|
||||
* 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.common;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.CostImpl;
|
||||
import mage.abilities.costs.VariableCost;
|
||||
import mage.choices.Choice;
|
||||
import mage.choices.ChoiceImpl;
|
||||
import mage.counters.Counter;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.FilterMana;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX
|
||||
*/
|
||||
public class RemoveVariableCountersTargetCost extends CostImpl<RemoveVariableCountersTargetCost> implements VariableCost {
|
||||
|
||||
protected int amountPaid = 0;
|
||||
protected TargetPermanent target;
|
||||
protected String name;
|
||||
protected CounterType counterTypeToRemove;
|
||||
|
||||
public RemoveVariableCountersTargetCost(TargetPermanent target) {
|
||||
this(target, null);
|
||||
}
|
||||
|
||||
public RemoveVariableCountersTargetCost(TargetPermanent target, CounterType counterTypeToRemove) {
|
||||
this.target = target;
|
||||
this.counterTypeToRemove = counterTypeToRemove;
|
||||
text = setText();
|
||||
}
|
||||
|
||||
public RemoveVariableCountersTargetCost(final RemoveVariableCountersTargetCost cost) {
|
||||
super(cost);
|
||||
this.target = cost.target.copy();
|
||||
this.name = cost.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
|
||||
paid = false;
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (target.choose(Outcome.UnboostCreature, controllerId, sourceId, game)) {
|
||||
for (UUID targetId: (List<UUID>)target.getTargets()) {
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent != null) {
|
||||
if (permanent.getCounters().size() > 0 && (counterTypeToRemove == null || permanent.getCounters().containsKey(counterTypeToRemove))) {
|
||||
String counterName = null;
|
||||
if (counterTypeToRemove != null) {
|
||||
counterName = counterTypeToRemove.getName();
|
||||
} else {
|
||||
if (permanent.getCounters().size() > 1 && counterTypeToRemove == null) {
|
||||
Choice choice = new ChoiceImpl(true);
|
||||
Set<String> choices = new HashSet<String>();
|
||||
for (Counter counter : permanent.getCounters().values()) {
|
||||
if (permanent.getCounters().getCount(counter.getName()) > 0) {
|
||||
choices.add(counter.getName());
|
||||
}
|
||||
}
|
||||
choice.setChoices(choices);
|
||||
choice.setMessage("Choose a counter to remove from " + permanent.getName());
|
||||
controller.choose(Outcome.UnboostCreature, choice, game);
|
||||
counterName = choice.getChoice();
|
||||
} else {
|
||||
for (Counter counter : permanent.getCounters().values()) {
|
||||
if (counter.getCount() > 0) {
|
||||
counterName = counter.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (counterName != null) {
|
||||
int countersToRemove = 1;
|
||||
if (permanent.getCounters().getCount(counterName) > 1) {
|
||||
countersToRemove = controller.getAmount(1, permanent.getCounters().getCount(counterName),"Remove how many counters from " + permanent.getName(), game);
|
||||
}
|
||||
permanent.removeCounters(counterName, countersToRemove, game);
|
||||
if (permanent.getCounters().getCount(counterName) == 0 ){
|
||||
permanent.getCounters().removeCounter(counterName);
|
||||
}
|
||||
this.amountPaid += countersToRemove;
|
||||
this.paid = true;
|
||||
game.informPlayers(new StringBuilder(controller.getName()).append(" removes ").append(countersToRemove).append(" ").append(counterName).append(" counter from ").append(permanent.getName()).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
target.clearChosen();
|
||||
return paid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAmount() {
|
||||
return amountPaid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAmount(int amount) {
|
||||
amountPaid = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFilter(FilterMana filter) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(UUID sourceId, UUID controllerId, Game game) {
|
||||
return target.canChoose(controllerId, game);
|
||||
}
|
||||
|
||||
private String setText() {
|
||||
// Remove one or more +1/+1 counters from among creatures you control
|
||||
StringBuilder sb = new StringBuilder("Remove one or more ");
|
||||
if (counterTypeToRemove != null) {
|
||||
sb.append(counterTypeToRemove.getName()).append(" ");
|
||||
}
|
||||
sb.append("counter from among ").append(target.getTargetName());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RemoveVariableCountersTargetCost copy() {
|
||||
return new RemoveVariableCountersTargetCost(this);
|
||||
}
|
||||
}
|
|
@ -12,7 +12,7 @@ import mage.game.permanent.Permanent;
|
|||
public class ControlEnchantedEffect extends ContinuousEffectImpl<ControlEnchantedEffect> {
|
||||
|
||||
public ControlEnchantedEffect() {
|
||||
super(Constants.Duration.WhileOnBattlefield, Constants.Outcome.Detriment);
|
||||
super(Constants.Duration.WhileOnBattlefield, Constants.Outcome.GainControl);
|
||||
staticText = "You control enchanted creature";
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue