mirror of
https://github.com/correl/mage.git
synced 2025-01-11 19:13:02 +00:00
AdjustTargets method for dynamic targets
This commit is contained in:
parent
ab9db5a60a
commit
a5d846f970
8 changed files with 72 additions and 13 deletions
|
@ -28,6 +28,7 @@ public interface MageObject extends MageItem, Serializable {
|
|||
public MageInt getToughness();
|
||||
|
||||
public void adjustCosts(Ability ability, Game game);
|
||||
public void adjustTargets(Ability ability, Game game);
|
||||
|
||||
public MageObject copy();
|
||||
|
||||
|
|
|
@ -146,6 +146,9 @@ public abstract class MageObjectImpl<T extends MageObjectImpl<T>> implements Mag
|
|||
@Override
|
||||
public void adjustCosts(Ability ability, Game game) {}
|
||||
|
||||
@Override
|
||||
public void adjustTargets(Ability ability, Game game) {}
|
||||
|
||||
@Override
|
||||
public boolean hasSubtype(String value) {
|
||||
if (value == null) {
|
||||
|
|
|
@ -162,6 +162,10 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
|||
logger.debug("activate failed - choice");
|
||||
return false;
|
||||
}
|
||||
Card card = game.getCard(sourceId);
|
||||
if (card != null) {
|
||||
card.adjustTargets(this, game);
|
||||
}
|
||||
//20100716 - 601.2b
|
||||
if (getTargets().size() > 0 && getTargets().chooseTargets(getEffects().get(0).getOutcome(), this.controllerId, this, game) == false) {
|
||||
logger.debug("activate failed - target");
|
||||
|
@ -182,7 +186,6 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
|||
}
|
||||
}
|
||||
//20100716 - 601.2e
|
||||
Card card = game.getCard(sourceId);
|
||||
if (card != null) {
|
||||
card.adjustCosts(this, game);
|
||||
for (Ability ability : card.getAbilities()) {
|
||||
|
|
51
Mage/src/mage/abilities/costs/common/DiscardCardCost.java
Normal file
51
Mage/src/mage/abilities/costs/common/DiscardCardCost.java
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* 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 mage.target.common.TargetCardInHand;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author magenoxx_at_googlemail.com
|
||||
*/
|
||||
public class DiscardCardCost extends DiscardTargetCost {
|
||||
|
||||
public DiscardCardCost() {
|
||||
super(new TargetCardInHand());
|
||||
}
|
||||
|
||||
public DiscardCardCost(DiscardCardCost cost) {
|
||||
super(cost);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiscardCardCost copy() {
|
||||
return new DiscardCardCost(this);
|
||||
}
|
||||
|
||||
}
|
|
@ -42,6 +42,7 @@ import mage.game.events.ZoneChangeEvent;
|
|||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author nantuko
|
||||
*/
|
||||
public class FlashbackAbility extends ActivatedAbilityImpl<FlashbackAbility> {
|
||||
|
@ -53,16 +54,6 @@ public class FlashbackAbility extends ActivatedAbilityImpl<FlashbackAbility> {
|
|||
this.addEffect(new CreateDelayedTriggeredAbilityEffect(new FlashbackTriggeredAbility()));
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean activate(Game game, boolean noMana) {
|
||||
// Card card = game.getCard(sourceId);
|
||||
// if (card != null) {
|
||||
// getEffects().get(0).setTargetPointer(new FixedTarget(card.getId()));
|
||||
// return super.activate(game, noMana);
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
|
||||
public FlashbackAbility(final FlashbackAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
@ -75,11 +66,13 @@ public class FlashbackAbility extends ActivatedAbilityImpl<FlashbackAbility> {
|
|||
@Override
|
||||
public String getRule() {
|
||||
StringBuilder sbRule = new StringBuilder("Flashback ");
|
||||
boolean first = true;
|
||||
if (manaCosts.size() > 0) {
|
||||
sbRule.append(manaCosts.getText());
|
||||
first = false;
|
||||
}
|
||||
if (costs.size() > 0) {
|
||||
if (sbRule.length() > 0) {
|
||||
if (first) {
|
||||
sbRule.append(",");
|
||||
}
|
||||
sbRule.append(costs.getText());
|
||||
|
|
|
@ -148,6 +148,9 @@ public class Emblem implements CommandObject {
|
|||
@Override
|
||||
public void adjustCosts(Ability ability, Game game) {}
|
||||
|
||||
@Override
|
||||
public void adjustTargets(Ability ability, Game game) {}
|
||||
|
||||
@Override
|
||||
public UUID getId() {
|
||||
return this.id;
|
||||
|
|
|
@ -379,6 +379,9 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
|||
@Override
|
||||
public void adjustCosts(Ability ability, Game game) {}
|
||||
|
||||
@Override
|
||||
public void adjustTargets(Ability ability, Game game) {}
|
||||
|
||||
@Override
|
||||
public boolean moveToZone(Zone zone, UUID sourceId, Game game, boolean flag) {
|
||||
throw new UnsupportedOperationException("Unsupported operation");
|
||||
|
@ -474,4 +477,3 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
|||
@Override
|
||||
public void build() {}
|
||||
}
|
||||
|
||||
|
|
|
@ -295,6 +295,9 @@ public class StackAbility implements StackObject, Ability {
|
|||
@Override
|
||||
public void adjustCosts(Ability ability, Game game) {}
|
||||
|
||||
@Override
|
||||
public void adjustTargets(Ability ability, Game game) {}
|
||||
|
||||
@Override
|
||||
public Costs<Cost> getOptionalCosts() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
|
|
Loading…
Reference in a new issue