mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08: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 MageInt getToughness();
|
||||||
|
|
||||||
public void adjustCosts(Ability ability, Game game);
|
public void adjustCosts(Ability ability, Game game);
|
||||||
|
public void adjustTargets(Ability ability, Game game);
|
||||||
|
|
||||||
public MageObject copy();
|
public MageObject copy();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,9 @@ public abstract class MageObjectImpl<T extends MageObjectImpl<T>> implements Mag
|
||||||
@Override
|
@Override
|
||||||
public void adjustCosts(Ability ability, Game game) {}
|
public void adjustCosts(Ability ability, Game game) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void adjustTargets(Ability ability, Game game) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasSubtype(String value) {
|
public boolean hasSubtype(String value) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
|
|
||||||
|
|
@ -162,6 +162,10 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
||||||
logger.debug("activate failed - choice");
|
logger.debug("activate failed - choice");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Card card = game.getCard(sourceId);
|
||||||
|
if (card != null) {
|
||||||
|
card.adjustTargets(this, game);
|
||||||
|
}
|
||||||
//20100716 - 601.2b
|
//20100716 - 601.2b
|
||||||
if (getTargets().size() > 0 && getTargets().chooseTargets(getEffects().get(0).getOutcome(), this.controllerId, this, game) == false) {
|
if (getTargets().size() > 0 && getTargets().chooseTargets(getEffects().get(0).getOutcome(), this.controllerId, this, game) == false) {
|
||||||
logger.debug("activate failed - target");
|
logger.debug("activate failed - target");
|
||||||
|
|
@ -182,7 +186,6 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//20100716 - 601.2e
|
//20100716 - 601.2e
|
||||||
Card card = game.getCard(sourceId);
|
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
card.adjustCosts(this, game);
|
card.adjustCosts(this, game);
|
||||||
for (Ability ability : card.getAbilities()) {
|
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;
|
import mage.players.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @author nantuko
|
* @author nantuko
|
||||||
*/
|
*/
|
||||||
public class FlashbackAbility extends ActivatedAbilityImpl<FlashbackAbility> {
|
public class FlashbackAbility extends ActivatedAbilityImpl<FlashbackAbility> {
|
||||||
|
|
@ -53,16 +54,6 @@ public class FlashbackAbility extends ActivatedAbilityImpl<FlashbackAbility> {
|
||||||
this.addEffect(new CreateDelayedTriggeredAbilityEffect(new FlashbackTriggeredAbility()));
|
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) {
|
public FlashbackAbility(final FlashbackAbility ability) {
|
||||||
super(ability);
|
super(ability);
|
||||||
}
|
}
|
||||||
|
|
@ -75,11 +66,13 @@ public class FlashbackAbility extends ActivatedAbilityImpl<FlashbackAbility> {
|
||||||
@Override
|
@Override
|
||||||
public String getRule() {
|
public String getRule() {
|
||||||
StringBuilder sbRule = new StringBuilder("Flashback ");
|
StringBuilder sbRule = new StringBuilder("Flashback ");
|
||||||
|
boolean first = true;
|
||||||
if (manaCosts.size() > 0) {
|
if (manaCosts.size() > 0) {
|
||||||
sbRule.append(manaCosts.getText());
|
sbRule.append(manaCosts.getText());
|
||||||
|
first = false;
|
||||||
}
|
}
|
||||||
if (costs.size() > 0) {
|
if (costs.size() > 0) {
|
||||||
if (sbRule.length() > 0) {
|
if (first) {
|
||||||
sbRule.append(",");
|
sbRule.append(",");
|
||||||
}
|
}
|
||||||
sbRule.append(costs.getText());
|
sbRule.append(costs.getText());
|
||||||
|
|
|
||||||
|
|
@ -148,6 +148,9 @@ public class Emblem implements CommandObject {
|
||||||
@Override
|
@Override
|
||||||
public void adjustCosts(Ability ability, Game game) {}
|
public void adjustCosts(Ability ability, Game game) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void adjustTargets(Ability ability, Game game) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return this.id;
|
return this.id;
|
||||||
|
|
|
||||||
|
|
@ -379,6 +379,9 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
||||||
@Override
|
@Override
|
||||||
public void adjustCosts(Ability ability, Game game) {}
|
public void adjustCosts(Ability ability, Game game) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void adjustTargets(Ability ability, Game game) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean moveToZone(Zone zone, UUID sourceId, Game game, boolean flag) {
|
public boolean moveToZone(Zone zone, UUID sourceId, Game game, boolean flag) {
|
||||||
throw new UnsupportedOperationException("Unsupported operation");
|
throw new UnsupportedOperationException("Unsupported operation");
|
||||||
|
|
@ -474,4 +477,3 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
||||||
@Override
|
@Override
|
||||||
public void build() {}
|
public void build() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -295,6 +295,9 @@ public class StackAbility implements StackObject, Ability {
|
||||||
@Override
|
@Override
|
||||||
public void adjustCosts(Ability ability, Game game) {}
|
public void adjustCosts(Ability ability, Game game) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void adjustTargets(Ability ability, Game game) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Costs<Cost> getOptionalCosts() {
|
public Costs<Cost> getOptionalCosts() {
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue