mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
* Entwine - Fixed that for spells cast without mana costs entwine could wrongly be used for free.
This commit is contained in:
parent
6beb23dbb3
commit
227143aacf
4 changed files with 38 additions and 14 deletions
|
@ -30,7 +30,6 @@ package mage.abilities;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.MageObjectReference;
|
import mage.MageObjectReference;
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
|
@ -39,6 +38,7 @@ import mage.abilities.costs.AlternativeSourceCosts;
|
||||||
import mage.abilities.costs.Cost;
|
import mage.abilities.costs.Cost;
|
||||||
import mage.abilities.costs.Costs;
|
import mage.abilities.costs.Costs;
|
||||||
import mage.abilities.costs.CostsImpl;
|
import mage.abilities.costs.CostsImpl;
|
||||||
|
import mage.abilities.costs.OptionalAdditionalModeSourceCosts;
|
||||||
import mage.abilities.costs.OptionalAdditionalSourceCosts;
|
import mage.abilities.costs.OptionalAdditionalSourceCosts;
|
||||||
import mage.abilities.costs.VariableCost;
|
import mage.abilities.costs.VariableCost;
|
||||||
import mage.abilities.costs.common.TapSourceCost;
|
import mage.abilities.costs.common.TapSourceCost;
|
||||||
|
@ -284,6 +284,9 @@ public abstract class AbilityImpl implements Ability {
|
||||||
this.getManaCostsToPay().clear();
|
this.getManaCostsToPay().clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (modes.getAdditionalCost() != null) {
|
||||||
|
((OptionalAdditionalModeSourceCosts) modes.getAdditionalCost()).addOptionalAdditionalModeCosts(this, game);
|
||||||
|
}
|
||||||
// 20130201 - 601.2b
|
// 20130201 - 601.2b
|
||||||
// If the spell has alternative or additional costs that will be paid as it's being cast such
|
// If the spell has alternative or additional costs that will be paid as it's being cast such
|
||||||
// as buyback, kicker, or convoke costs (see rules 117.8 and 117.9), the player announces his
|
// as buyback, kicker, or convoke costs (see rules 117.8 and 117.9), the player announces his
|
||||||
|
|
|
@ -56,6 +56,7 @@ public class Modes extends LinkedHashMap<UUID, Mode> {
|
||||||
private boolean eachModeMoreThanOnce; // each mode can be selected multiple times during one choice
|
private boolean eachModeMoreThanOnce; // each mode can be selected multiple times during one choice
|
||||||
private boolean eachModeOnlyOnce; // state if each mode can be chosen only once as long as the source object exists
|
private boolean eachModeOnlyOnce; // state if each mode can be chosen only once as long as the source object exists
|
||||||
private final LinkedHashMap<UUID, Mode> duplicateModes = new LinkedHashMap<>();
|
private final LinkedHashMap<UUID, Mode> duplicateModes = new LinkedHashMap<>();
|
||||||
|
private OptionalAdditionalModeSourceCosts optionalAdditionalModeSourceCosts = null; // only set if costs have to be paid
|
||||||
|
|
||||||
public Modes() {
|
public Modes() {
|
||||||
this.currentMode = new Mode();
|
this.currentMode = new Mode();
|
||||||
|
@ -87,6 +88,7 @@ public class Modes extends LinkedHashMap<UUID, Mode> {
|
||||||
this.modeChooser = modes.modeChooser;
|
this.modeChooser = modes.modeChooser;
|
||||||
this.eachModeOnlyOnce = modes.eachModeOnlyOnce;
|
this.eachModeOnlyOnce = modes.eachModeOnlyOnce;
|
||||||
this.eachModeMoreThanOnce = modes.eachModeMoreThanOnce;
|
this.eachModeMoreThanOnce = modes.eachModeMoreThanOnce;
|
||||||
|
this.optionalAdditionalModeSourceCosts = modes.optionalAdditionalModeSourceCosts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Modes copy() {
|
public Modes copy() {
|
||||||
|
@ -186,7 +188,7 @@ public class Modes extends LinkedHashMap<UUID, Mode> {
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
for (Ability modeModifyingAbility : card.getAbilities()) {
|
for (Ability modeModifyingAbility : card.getAbilities()) {
|
||||||
if (modeModifyingAbility instanceof OptionalAdditionalModeSourceCosts) {
|
if (modeModifyingAbility instanceof OptionalAdditionalModeSourceCosts) {
|
||||||
((OptionalAdditionalModeSourceCosts) modeModifyingAbility).addOptionalAdditionalModeCosts(source, game);
|
((OptionalAdditionalModeSourceCosts) modeModifyingAbility).changeModes(source, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -385,4 +387,12 @@ public class Modes extends LinkedHashMap<UUID, Mode> {
|
||||||
this.eachModeMoreThanOnce = eachModeMoreThanOnce;
|
this.eachModeMoreThanOnce = eachModeMoreThanOnce;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OptionalAdditionalModeSourceCosts getAdditionalCost() {
|
||||||
|
return optionalAdditionalModeSourceCosts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdditionalCost(OptionalAdditionalModeSourceCosts optionalAdditionalModeSourceCosts) {
|
||||||
|
this.optionalAdditionalModeSourceCosts = optionalAdditionalModeSourceCosts;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,9 +34,11 @@ import mage.game.Game;
|
||||||
*
|
*
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
public interface OptionalAdditionalModeSourceCosts {
|
public interface OptionalAdditionalModeSourceCosts {
|
||||||
|
|
||||||
void addOptionalAdditionalModeCosts(Ability ability, Game game);
|
void addOptionalAdditionalModeCosts(Ability ability, Game game);
|
||||||
|
|
||||||
|
void changeModes(Ability ability, Game game);
|
||||||
|
|
||||||
String getCastMessageSuffix();
|
String getCastMessageSuffix();
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,22 +105,17 @@ public class EntwineAbility extends StaticAbility implements OptionalAdditionalM
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addOptionalAdditionalModeCosts(Ability ability, Game game) {
|
public void changeModes(Ability ability, Game game) {
|
||||||
if (ability instanceof SpellAbility) {
|
if (ability instanceof SpellAbility) {
|
||||||
Player player = game.getPlayer(controllerId);
|
Player player = game.getPlayer(controllerId);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
this.resetCosts();
|
this.resetCosts();
|
||||||
if (additionalCost != null) {
|
if (additionalCost != null) {
|
||||||
if (player.chooseUse(Outcome.Benefit, "Pay " + additionalCost.getText(false) + " ?", ability, game)) {
|
if (additionalCost.canPay(ability, ability.getSourceId(), ability.getControllerId(), game)
|
||||||
|
&& player.chooseUse(Outcome.Benefit, "Pay " + additionalCost.getText(false) + " ?", ability, game)) {
|
||||||
|
|
||||||
additionalCost.activate();
|
additionalCost.activate();
|
||||||
for (Iterator it = ((Costs) additionalCost).iterator(); it.hasNext();) {
|
ability.getModes().setAdditionalCost(this);
|
||||||
Cost cost = (Cost) it.next();
|
|
||||||
if (cost instanceof ManaCostsImpl) {
|
|
||||||
ability.getManaCostsToPay().add((ManaCostsImpl) cost.copy());
|
|
||||||
} else {
|
|
||||||
ability.getCosts().add(cost.copy());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ability.getModes().setMinModes(2);
|
ability.getModes().setMinModes(2);
|
||||||
ability.getModes().setMaxModes(2);
|
ability.getModes().setMaxModes(2);
|
||||||
}
|
}
|
||||||
|
@ -129,6 +124,20 @@ public class EntwineAbility extends StaticAbility implements OptionalAdditionalM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addOptionalAdditionalModeCosts(Ability ability, Game game) {
|
||||||
|
if (additionalCost.isActivated()) {
|
||||||
|
for (Iterator it = ((Costs) additionalCost).iterator(); it.hasNext();) {
|
||||||
|
Cost cost = (Cost) it.next();
|
||||||
|
if (cost instanceof ManaCostsImpl) {
|
||||||
|
ability.getManaCostsToPay().add((ManaCostsImpl) cost.copy());
|
||||||
|
} else {
|
||||||
|
ability.getCosts().add(cost.copy());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRule() {
|
public String getRule() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
Loading…
Reference in a new issue