mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
Merge branch 'fix+gonti' into 'master'
Fixing Mana types being inappropriately referenced in relation to Matrices See merge request core-developers/forge!883
This commit is contained in:
@@ -913,6 +913,10 @@ public class ComputerUtilMana {
|
|||||||
// Make mana needed to avoid negative effect a mandatory cost for the AI
|
// Make mana needed to avoid negative effect a mandatory cost for the AI
|
||||||
for (String manaPart : card.getSVar("ManaNeededToAvoidNegativeEffect").split(",")) {
|
for (String manaPart : card.getSVar("ManaNeededToAvoidNegativeEffect").split(",")) {
|
||||||
// convert long color strings to short color strings
|
// convert long color strings to short color strings
|
||||||
|
if (manaPart.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
byte mask = ManaAtom.fromName(manaPart);
|
byte mask = ManaAtom.fromName(manaPart);
|
||||||
|
|
||||||
// make mana mandatory for AI
|
// make mana mandatory for AI
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import forge.game.card.CardPredicates.Presets;
|
|||||||
import forge.game.combat.Combat;
|
import forge.game.combat.Combat;
|
||||||
import forge.game.cost.*;
|
import forge.game.cost.*;
|
||||||
import forge.game.mana.Mana;
|
import forge.game.mana.Mana;
|
||||||
|
import forge.game.mana.ManaConversionMatrix;
|
||||||
import forge.game.mana.ManaCostBeingPaid;
|
import forge.game.mana.ManaCostBeingPaid;
|
||||||
import forge.game.phase.PhaseHandler;
|
import forge.game.phase.PhaseHandler;
|
||||||
import forge.game.phase.PhaseType;
|
import forge.game.phase.PhaseType;
|
||||||
@@ -921,7 +922,7 @@ public class PlayerControllerAi extends PlayerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean payManaCost(ManaCost toPay, CostPartMana costPartMana, SpellAbility sa, String prompt /* ai needs hints as well */, boolean isActivatedSa) {
|
public boolean payManaCost(ManaCost toPay, CostPartMana costPartMana, SpellAbility sa, String prompt /* ai needs hints as well */, ManaConversionMatrix matrix, boolean isActivatedSa) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
ManaCostBeingPaid cost = isActivatedSa ? ComputerUtilMana.calculateManaCost(sa, false, 0) : new ManaCostBeingPaid(toPay);
|
ManaCostBeingPaid cost = isActivatedSa ? ComputerUtilMana.calculateManaCost(sa, false, 0) : new ManaCostBeingPaid(toPay);
|
||||||
return ComputerUtilMana.payManaCost(cost, sa, player);
|
return ComputerUtilMana.payManaCost(cost, sa, player);
|
||||||
|
|||||||
@@ -103,15 +103,6 @@ public final class MagicColor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getIndexOfFirstColor(final byte color){
|
|
||||||
for (int i = 0; i < NUMBER_OR_COLORS; i++) {
|
|
||||||
if ((color & WUBRG[i]) != 0) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1; // colorless
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Interface Color.
|
* The Interface Color.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ public abstract class ManaAtom {
|
|||||||
public static final byte[] MANACOLORS = new byte[] { WHITE, BLUE, BLACK, RED, GREEN };
|
public static final byte[] MANACOLORS = new byte[] { WHITE, BLUE, BLACK, RED, GREEN };
|
||||||
public static final byte[] MANATYPES = new byte[] { WHITE, BLUE, BLACK, RED, GREEN, COLORLESS };
|
public static final byte[] MANATYPES = new byte[] { WHITE, BLUE, BLACK, RED, GREEN, COLORLESS };
|
||||||
|
|
||||||
|
public static final byte ALL_MANA_COLORS = WHITE | BLUE | BLACK | RED | GREEN;
|
||||||
|
public static final byte ALL_MANA_TYPES = ALL_MANA_COLORS | COLORLESS;
|
||||||
|
|
||||||
public static final int GENERIC = 1 << 6;
|
public static final int GENERIC = 1 << 6;
|
||||||
|
|
||||||
// Below here skip due to byte conversion shenanigans
|
// Below here skip due to byte conversion shenanigans
|
||||||
@@ -62,6 +65,6 @@ public abstract class ManaAtom {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1; // colorless
|
return -1; // somehow the mana is not colored or colorless?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -786,7 +786,9 @@ public class GameAction {
|
|||||||
game.getReplacementHandler().cleanUpTemporaryReplacements();
|
game.getReplacementHandler().cleanUpTemporaryReplacements();
|
||||||
|
|
||||||
for (final Player p : game.getPlayers()) {
|
for (final Player p : game.getPlayers()) {
|
||||||
|
if (!game.getStack().isFrozen()) {
|
||||||
p.getManaPool().restoreColorReplacements();
|
p.getManaPool().restoreColorReplacements();
|
||||||
|
}
|
||||||
p.clearStaticAbilities();
|
p.clearStaticAbilities();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import forge.game.ability.AbilityFactory.AbilityRecordType;
|
|||||||
import forge.game.card.*;
|
import forge.game.card.*;
|
||||||
import forge.game.cost.Cost;
|
import forge.game.cost.Cost;
|
||||||
import forge.game.keyword.KeywordInterface;
|
import forge.game.keyword.KeywordInterface;
|
||||||
|
import forge.game.mana.ManaConversionMatrix;
|
||||||
import forge.game.mana.ManaCostBeingPaid;
|
import forge.game.mana.ManaCostBeingPaid;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.player.PlayerCollection;
|
import forge.game.player.PlayerCollection;
|
||||||
@@ -1642,7 +1643,7 @@ public class AbilityUtils {
|
|||||||
return CardFactoryUtil.xCount(c, s2);
|
return CardFactoryUtil.xCount(c, s2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final void applyManaColorConversion(final Player p, final Map<String, String> params) {
|
public static final void applyManaColorConversion(ManaConversionMatrix matrix, final Map<String, String> params) {
|
||||||
String conversionType = params.get("ManaColorConversion");
|
String conversionType = params.get("ManaColorConversion");
|
||||||
|
|
||||||
// Choices are Additives(OR) or Restrictive(AND)
|
// Choices are Additives(OR) or Restrictive(AND)
|
||||||
@@ -1655,14 +1656,15 @@ public class AbilityUtils {
|
|||||||
String convertTo = params.get(key);
|
String convertTo = params.get(key);
|
||||||
byte convertByte = 0;
|
byte convertByte = 0;
|
||||||
if ("All".equals(convertTo)) {
|
if ("All".equals(convertTo)) {
|
||||||
convertByte = ColorSet.ALL_COLORS.getColor();
|
// IMPORTANT! We need to use Mana Color here not Card Color.
|
||||||
|
convertByte = ManaAtom.ALL_MANA_TYPES;
|
||||||
} else {
|
} else {
|
||||||
for (final String convertColor : convertTo.split(",")) {
|
for (final String convertColor : convertTo.split(",")) {
|
||||||
convertByte |= ManaAtom.fromName(convertColor);
|
convertByte |= ManaAtom.fromName(convertColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// AdjustColorReplacement has two different matrices handling final mana conversion under the covers
|
// AdjustColorReplacement has two different matrices handling final mana conversion under the covers
|
||||||
p.getManaPool().adjustColorReplacement(ManaAtom.fromName(c), convertByte, additive);
|
matrix.adjustColorReplacement(ManaAtom.fromName(c), convertByte, additive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,9 @@ package forge.game.cost;
|
|||||||
|
|
||||||
import forge.card.mana.ManaCost;
|
import forge.card.mana.ManaCost;
|
||||||
import forge.card.mana.ManaCostShard;
|
import forge.card.mana.ManaCostShard;
|
||||||
|
import forge.game.mana.ManaConversionMatrix;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
|
import forge.game.spellability.AbilityActivated;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,6 +39,9 @@ public class CostPartMana extends CostPart {
|
|||||||
private boolean isEnchantedCreatureCost = false;
|
private boolean isEnchantedCreatureCost = false;
|
||||||
private final String restriction;
|
private final String restriction;
|
||||||
|
|
||||||
|
private ManaConversionMatrix cardMatrix = null;
|
||||||
|
public void setCardMatrix(ManaConversionMatrix mtrx) { cardMatrix = mtrx; }
|
||||||
|
|
||||||
public int paymentOrder() { return shouldPayLast() ? 200 : 0; }
|
public int paymentOrder() { return shouldPayLast() ? 200 : 0; }
|
||||||
|
|
||||||
public boolean shouldPayLast() {
|
public boolean shouldPayLast() {
|
||||||
@@ -147,8 +152,9 @@ public class CostPartMana extends CostPart {
|
|||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
sa.clearManaPaid();
|
sa.clearManaPaid();
|
||||||
|
|
||||||
|
boolean isActivated = sa instanceof AbilityActivated;
|
||||||
// decision not used here, the whole payment is interactive!
|
// decision not used here, the whole payment is interactive!
|
||||||
return payer.getController().payManaCost(this, sa, null, true);
|
return payer.getController().payManaCost(this, sa, null, cardMatrix, isActivated);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import com.google.common.collect.Lists;
|
|||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import forge.game.Game;
|
import forge.game.Game;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
|
import forge.game.mana.ManaConversionMatrix;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
|
|
||||||
@@ -35,7 +36,7 @@ import java.util.Map;
|
|||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class CostPayment {
|
public class CostPayment extends ManaConversionMatrix {
|
||||||
private final Cost cost;
|
private final Cost cost;
|
||||||
private Cost adjustedCost;
|
private Cost adjustedCost;
|
||||||
private final SpellAbility ability;
|
private final SpellAbility ability;
|
||||||
@@ -70,6 +71,7 @@ public class CostPayment {
|
|||||||
this.cost = cost;
|
this.cost = cost;
|
||||||
this.adjustedCost = cost;
|
this.adjustedCost = cost;
|
||||||
this.ability = abil;
|
this.ability = abil;
|
||||||
|
restoreColorReplacements();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,6 +139,11 @@ public class CostPayment {
|
|||||||
|
|
||||||
PaymentDecision pd = part.accept(decisionMaker);
|
PaymentDecision pd = part.accept(decisionMaker);
|
||||||
|
|
||||||
|
// RIght before we start paying as decided, we need to transfer the CostPayments matrix over?
|
||||||
|
if (part instanceof CostPartMana) {
|
||||||
|
((CostPartMana)part).setCardMatrix(this);
|
||||||
|
}
|
||||||
|
|
||||||
if (pd == null || !part.payAsDecided(decisionMaker.getPlayer(), pd, ability)) {
|
if (pd == null || !part.payAsDecided(decisionMaker.getPlayer(), pd, ability)) {
|
||||||
game.costPaymentStack.pop(); // cost is resolved
|
game.costPaymentStack.pop(); // cost is resolved
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package forge.game.mana;
|
||||||
|
|
||||||
|
import forge.card.mana.ManaAtom;
|
||||||
|
|
||||||
|
public class ManaConversionMatrix {
|
||||||
|
static byte[] identityMatrix = { ManaAtom.WHITE, ManaAtom.BLUE, ManaAtom.BLACK, ManaAtom.RED, ManaAtom.GREEN, ManaAtom.COLORLESS };
|
||||||
|
|
||||||
|
// Conversion matrix ORs byte values to make mana more payable
|
||||||
|
// Restrictive matrix ANDs byte values to make mana less payable
|
||||||
|
byte[] colorConversionMatrix = new byte[ManaAtom.MANATYPES.length];
|
||||||
|
byte[] colorRestrictionMatrix = new byte[ManaAtom.MANATYPES.length];
|
||||||
|
|
||||||
|
public void adjustColorReplacement(byte originalColor, byte replacementColor, boolean additive) {
|
||||||
|
// Fix the index without hardcodes
|
||||||
|
int rowIdx = ManaAtom.getIndexOfFirstManaType(originalColor);
|
||||||
|
rowIdx = rowIdx < 0 ? identityMatrix.length - 1 : rowIdx;
|
||||||
|
if (additive) {
|
||||||
|
colorConversionMatrix[rowIdx] |= replacementColor;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
colorRestrictionMatrix[rowIdx] &= replacementColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void applyCardMatrix(ManaConversionMatrix extraMatrix) {
|
||||||
|
for (int i = 0; i < colorConversionMatrix.length; i++) {
|
||||||
|
colorConversionMatrix[i] |= extraMatrix.colorConversionMatrix[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < colorRestrictionMatrix.length; i++) {
|
||||||
|
colorRestrictionMatrix[i] &= extraMatrix.colorRestrictionMatrix[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void restoreColorReplacements() {
|
||||||
|
// By default each color can only be paid by itself ( {G} -> {G}, {C} -> {C}
|
||||||
|
for (int i = 0; i < colorConversionMatrix.length; i++) {
|
||||||
|
colorConversionMatrix[i] = identityMatrix[i];
|
||||||
|
}
|
||||||
|
// By default all mana types are unrestricted
|
||||||
|
for (int i = 0; i < colorRestrictionMatrix.length; i++) {
|
||||||
|
colorRestrictionMatrix[i] = ManaAtom.ALL_MANA_TYPES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -586,6 +586,7 @@ public class ManaCostBeingPaid {
|
|||||||
// Boolean addX used to add Xs into the returned value
|
// Boolean addX used to add Xs into the returned value
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
// TODO Prepend a line about paying with any type/color if available
|
||||||
if (addX) {
|
if (addX) {
|
||||||
for (int i = 0; i < this.getXcounter(); i++) {
|
for (int i = 0; i < this.getXcounter(); i++) {
|
||||||
sb.append("{X}");
|
sb.append("{X}");
|
||||||
@@ -595,10 +596,11 @@ public class ManaCostBeingPaid {
|
|||||||
int nGeneric = getGenericManaAmount();
|
int nGeneric = getGenericManaAmount();
|
||||||
List<ManaCostShard> shards = new ArrayList<ManaCostShard>(unpaidShards.keySet());
|
List<ManaCostShard> shards = new ArrayList<ManaCostShard>(unpaidShards.keySet());
|
||||||
|
|
||||||
if (pool != null) { //replace shards with generic mana if they can be paid with any color mana
|
// TODO Fix this. Should we really be changing Shards here?
|
||||||
|
if (false && pool != null) { //replace shards with generic mana if they can be paid with any color mana
|
||||||
for (int i = 0; i < shards.size(); i++) {
|
for (int i = 0; i < shards.size(); i++) {
|
||||||
ManaCostShard shard = shards.get(i);
|
ManaCostShard shard = shards.get(i);
|
||||||
if (shard != ManaCostShard.GENERIC && pool.getPossibleColorUses(shard.getColorMask()) == MagicColor.ALL_COLORS) {
|
if (shard != ManaCostShard.GENERIC && pool.getPossibleColorUses(shard.getColorMask()) == ManaAtom.ALL_MANA_TYPES) {
|
||||||
nGeneric += unpaidShards.get(shard).totalCount;
|
nGeneric += unpaidShards.get(shard).totalCount;
|
||||||
shards.remove(i);
|
shards.remove(i);
|
||||||
i--;
|
i--;
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ package forge.game.mana;
|
|||||||
import com.google.common.collect.ArrayListMultimap;
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
|
||||||
import forge.GameCommand;
|
import forge.GameCommand;
|
||||||
import forge.card.ColorSet;
|
|
||||||
import forge.card.MagicColor;
|
import forge.card.MagicColor;
|
||||||
import forge.card.mana.ManaAtom;
|
import forge.card.mana.ManaAtom;
|
||||||
import forge.card.mana.ManaCostShard;
|
import forge.card.mana.ManaCostShard;
|
||||||
@@ -37,14 +35,9 @@ import forge.game.player.Player;
|
|||||||
import forge.game.spellability.AbilityManaPart;
|
import forge.game.spellability.AbilityManaPart;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -54,7 +47,7 @@ import java.util.List;
|
|||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class ManaPool implements Iterable<Mana> {
|
public class ManaPool extends ManaConversionMatrix implements Iterable<Mana> {
|
||||||
private final Player owner;
|
private final Player owner;
|
||||||
private final Multimap<Byte, Mana> floatingMana = ArrayListMultimap.create();
|
private final Multimap<Byte, Mana> floatingMana = ArrayListMultimap.create();
|
||||||
|
|
||||||
@@ -356,36 +349,9 @@ public class ManaPool implements Iterable<Mana> {
|
|||||||
p.getGame().fireEvent(new GameEventZone(ZoneType.Battlefield, p, EventValueChangeType.ComplexUpdate, null));
|
p.getGame().fireEvent(new GameEventZone(ZoneType.Battlefield, p, EventValueChangeType.ComplexUpdate, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Conversion matrix ORs byte values to make mana more payable
|
|
||||||
// Restrictive matrix ANDs byte values to make mana less payable
|
|
||||||
private final byte[] colorConversionMatrix = new byte[ManaAtom.MANATYPES.length];
|
|
||||||
private final byte[] colorRestrictionMatrix = new byte[ManaAtom.MANATYPES.length];
|
|
||||||
private static final byte[] identityMatrix = { ManaAtom.WHITE, ManaAtom.BLUE, ManaAtom.BLACK, ManaAtom.RED, ManaAtom.GREEN, ManaAtom.COLORLESS };
|
|
||||||
|
|
||||||
public void adjustColorReplacement(byte originalColor, byte replacementColor, boolean additive) {
|
|
||||||
// Fix the index without hardcodes
|
|
||||||
int rowIdx = MagicColor.getIndexOfFirstColor(originalColor);
|
|
||||||
rowIdx = rowIdx < 0 ? identityMatrix.length - 1 : rowIdx;
|
|
||||||
if (additive) {
|
|
||||||
colorConversionMatrix[rowIdx] |= replacementColor;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
colorRestrictionMatrix[rowIdx] &= replacementColor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void restoreColorReplacements() {
|
|
||||||
for (int i = 0; i < colorConversionMatrix.length; i++) {
|
|
||||||
colorConversionMatrix[i] = identityMatrix[i];
|
|
||||||
}
|
|
||||||
for (int i = 0; i < colorRestrictionMatrix.length; i++) {
|
|
||||||
colorRestrictionMatrix[i] = ColorSet.ALL_COLORS.getColor();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte getPossibleColorUses(byte color) {
|
public byte getPossibleColorUses(byte color) {
|
||||||
// Take the current conversion value, AND with restrictions to get mana usage
|
// Take the current conversion value, AND with restrictions to get mana usage
|
||||||
int rowIdx = MagicColor.getIndexOfFirstColor(color);
|
int rowIdx = ManaAtom.getIndexOfFirstManaType(color);
|
||||||
int matrixIdx = rowIdx < 0 ? identityMatrix.length - 1 : rowIdx;
|
int matrixIdx = rowIdx < 0 ? identityMatrix.length - 1 : rowIdx;
|
||||||
|
|
||||||
byte colorUse = colorConversionMatrix[matrixIdx];
|
byte colorUse = colorConversionMatrix[matrixIdx];
|
||||||
@@ -394,14 +360,16 @@ public class ManaPool implements Iterable<Mana> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canPayForShardWithColor(ManaCostShard shard, byte color) {
|
public boolean canPayForShardWithColor(ManaCostShard shard, byte color) {
|
||||||
|
// TODO Debug this for Paying Gonti,
|
||||||
byte line = getPossibleColorUses(color);
|
byte line = getPossibleColorUses(color);
|
||||||
for (int i = 0; i < MagicColor.NUMBER_OR_COLORS; i++) {
|
|
||||||
byte outColor = MagicColor.WUBRG[i];
|
for(byte outColor : ManaAtom.MANATYPES) {
|
||||||
if ((line & outColor) != 0 && shard.canBePaidWithManaOfColor(outColor)) {
|
if ((line & outColor) != 0 && shard.canBePaidWithManaOfColor(outColor)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO The following may not be needed anymore?
|
||||||
if (((color & (byte) ManaAtom.COLORLESS) != 0) && shard.canBePaidWithManaOfColor((byte) (byte)ManaAtom.COLORLESS)) {
|
if (((color & (byte) ManaAtom.COLORLESS) != 0) && shard.canBePaidWithManaOfColor((byte) (byte)ManaAtom.COLORLESS)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import forge.game.cost.Cost;
|
|||||||
import forge.game.cost.CostPart;
|
import forge.game.cost.CostPart;
|
||||||
import forge.game.cost.CostPartMana;
|
import forge.game.cost.CostPartMana;
|
||||||
import forge.game.mana.Mana;
|
import forge.game.mana.Mana;
|
||||||
|
import forge.game.mana.ManaConversionMatrix;
|
||||||
import forge.game.replacement.ReplacementEffect;
|
import forge.game.replacement.ReplacementEffect;
|
||||||
import forge.game.spellability.*;
|
import forge.game.spellability.*;
|
||||||
import forge.game.trigger.WrappedAbility;
|
import forge.game.trigger.WrappedAbility;
|
||||||
@@ -220,9 +221,13 @@ public abstract class PlayerController {
|
|||||||
public abstract void resetAtEndOfTurn(); // currently used by the AI to perform card memory cleanup
|
public abstract void resetAtEndOfTurn(); // currently used by the AI to perform card memory cleanup
|
||||||
|
|
||||||
public final boolean payManaCost(CostPartMana costPartMana, SpellAbility sa, String prompt, boolean isActivatedAbility) {
|
public final boolean payManaCost(CostPartMana costPartMana, SpellAbility sa, String prompt, boolean isActivatedAbility) {
|
||||||
return payManaCost(costPartMana.getManaCostFor(sa), costPartMana, sa, prompt, isActivatedAbility);
|
return payManaCost(costPartMana, sa, prompt, null, isActivatedAbility);
|
||||||
}
|
}
|
||||||
public abstract boolean payManaCost(ManaCost toPay, CostPartMana costPartMana, SpellAbility sa, String prompt, boolean isActivatedAbility);
|
|
||||||
|
public final boolean payManaCost(CostPartMana costPartMana, SpellAbility sa, String prompt, ManaConversionMatrix matrix, boolean isActivatedAbility) {
|
||||||
|
return payManaCost(costPartMana.getManaCostFor(sa), costPartMana, sa, prompt, matrix, isActivatedAbility);
|
||||||
|
}
|
||||||
|
public abstract boolean payManaCost(ManaCost toPay, CostPartMana costPartMana, SpellAbility sa, String prompt, ManaConversionMatrix matrix, boolean isActivatedAbility);
|
||||||
|
|
||||||
public abstract Map<Card, ManaCostShard> chooseCardsForConvokeOrImprovise(SpellAbility sa, ManaCost manaCost, CardCollectionView untappedCards, boolean improvise);
|
public abstract Map<Card, ManaCostShard> chooseCardsForConvokeOrImprovise(SpellAbility sa, ManaCost manaCost, CardCollectionView untappedCards, boolean improvise);
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ import forge.game.trigger.Trigger;
|
|||||||
import forge.game.trigger.TriggerHandler;
|
import forge.game.trigger.TriggerHandler;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.util.TextUtil;
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -481,7 +480,7 @@ public final class StaticAbilityContinuous {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (params.containsKey("ManaColorConversion")) {
|
if (params.containsKey("ManaColorConversion")) {
|
||||||
AbilityUtils.applyManaColorConversion(p, params);
|
AbilityUtils.applyManaColorConversion(p.getManaPool(), params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import forge.game.cost.Cost;
|
|||||||
import forge.game.cost.CostPart;
|
import forge.game.cost.CostPart;
|
||||||
import forge.game.cost.CostPartMana;
|
import forge.game.cost.CostPartMana;
|
||||||
import forge.game.mana.Mana;
|
import forge.game.mana.Mana;
|
||||||
|
import forge.game.mana.ManaConversionMatrix;
|
||||||
import forge.game.mana.ManaCostBeingPaid;
|
import forge.game.mana.ManaCostBeingPaid;
|
||||||
import forge.game.player.*;
|
import forge.game.player.*;
|
||||||
import forge.game.replacement.ReplacementEffect;
|
import forge.game.replacement.ReplacementEffect;
|
||||||
@@ -591,7 +592,7 @@ public class PlayerControllerForTests extends PlayerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean payManaCost(ManaCost toPay, CostPartMana costPartMana, SpellAbility sa, String prompt /* ai needs hints as well */, boolean isActivatedSa ) {
|
public boolean payManaCost(ManaCost toPay, CostPartMana costPartMana, SpellAbility sa, String prompt /* ai needs hints as well */, ManaConversionMatrix matrix, boolean isActivatedSa) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
ManaCostBeingPaid cost = new ManaCostBeingPaid(toPay);
|
ManaCostBeingPaid cost = new ManaCostBeingPaid(toPay);
|
||||||
return ComputerUtilMana.payManaCost(cost, sa, player);
|
return ComputerUtilMana.payManaCost(cost, sa, player);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package forge.match.input;
|
package forge.match.input;
|
||||||
|
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
|
import forge.game.mana.ManaConversionMatrix;
|
||||||
import forge.game.mana.ManaCostBeingPaid;
|
import forge.game.mana.ManaCostBeingPaid;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
@@ -10,13 +11,16 @@ import forge.properties.ForgePreferences;
|
|||||||
import forge.util.ITriggerEvent;
|
import forge.util.ITriggerEvent;
|
||||||
|
|
||||||
public class InputPayManaOfCostPayment extends InputPayMana {
|
public class InputPayManaOfCostPayment extends InputPayMana {
|
||||||
public InputPayManaOfCostPayment(final PlayerControllerHuman controller, ManaCostBeingPaid cost, SpellAbility spellAbility, Player payer) {
|
public InputPayManaOfCostPayment(final PlayerControllerHuman controller, ManaCostBeingPaid cost, SpellAbility spellAbility, Player payer, ManaConversionMatrix matrix) {
|
||||||
super(controller, spellAbility, payer);
|
super(controller, spellAbility, payer);
|
||||||
manaCost = cost;
|
manaCost = cost;
|
||||||
|
extraMatrix = matrix;
|
||||||
|
applyMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final long serialVersionUID = 3467312982164195091L;
|
private static final long serialVersionUID = 3467312982164195091L;
|
||||||
private int phyLifeToLose = 0;
|
private int phyLifeToLose = 0;
|
||||||
|
private ManaConversionMatrix extraMatrix;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected final void onPlayerSelected(Player selected, final ITriggerEvent triggerEvent) {
|
protected final void onPlayerSelected(Player selected, final ITriggerEvent triggerEvent) {
|
||||||
@@ -47,6 +51,8 @@ public class InputPayManaOfCostPayment extends InputPayMana {
|
|||||||
final String displayMana = manaCost.toString(false, player.getManaPool());
|
final String displayMana = manaCost.toString(false, player.getManaPool());
|
||||||
final StringBuilder msg = new StringBuilder();
|
final StringBuilder msg = new StringBuilder();
|
||||||
|
|
||||||
|
applyMatrix();
|
||||||
|
|
||||||
if (messagePrefix != null) {
|
if (messagePrefix != null) {
|
||||||
msg.append(messagePrefix).append("\n");
|
msg.append(messagePrefix).append("\n");
|
||||||
}
|
}
|
||||||
@@ -71,4 +77,12 @@ public class InputPayManaOfCostPayment extends InputPayMana {
|
|||||||
|
|
||||||
return msg.toString();
|
return msg.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void applyMatrix() {
|
||||||
|
if (extraMatrix == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.getManaPool().applyCardMatrix(extraMatrix);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,8 @@
|
|||||||
package forge.player;
|
package forge.player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import forge.game.cost.*;
|
|
||||||
import forge.game.spellability.LandAbility;
|
|
||||||
import forge.game.spellability.OptionalCostValue;
|
|
||||||
import forge.game.spellability.Spell;
|
|
||||||
import forge.util.TextUtil;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import forge.FThreads;
|
import forge.FThreads;
|
||||||
import forge.card.mana.ManaCost;
|
import forge.card.mana.ManaCost;
|
||||||
import forge.game.Game;
|
import forge.game.Game;
|
||||||
@@ -25,30 +12,31 @@ import forge.game.ability.AbilityUtils;
|
|||||||
import forge.game.ability.ApiType;
|
import forge.game.ability.ApiType;
|
||||||
import forge.game.ability.effects.CharmEffect;
|
import forge.game.ability.effects.CharmEffect;
|
||||||
import forge.game.ability.effects.FlipCoinEffect;
|
import forge.game.ability.effects.FlipCoinEffect;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.*;
|
||||||
import forge.game.card.CardCollection;
|
|
||||||
import forge.game.card.CardCollectionView;
|
|
||||||
import forge.game.card.CardDamageMap;
|
|
||||||
import forge.game.card.CardLists;
|
|
||||||
import forge.game.card.CardPredicates;
|
|
||||||
import forge.game.card.CardPredicates.Presets;
|
import forge.game.card.CardPredicates.Presets;
|
||||||
import forge.game.card.CardView;
|
import forge.game.cost.*;
|
||||||
import forge.game.card.CounterType;
|
import forge.game.mana.ManaConversionMatrix;
|
||||||
import forge.game.mana.ManaCostBeingPaid;
|
import forge.game.mana.ManaCostBeingPaid;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.player.PlayerController;
|
import forge.game.player.PlayerController;
|
||||||
import forge.game.player.PlayerView;
|
import forge.game.player.PlayerView;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.*;
|
||||||
import forge.game.spellability.TargetRestrictions;
|
|
||||||
import forge.game.trigger.TriggerType;
|
import forge.game.trigger.TriggerType;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.match.input.InputPayMana;
|
import forge.match.input.InputPayMana;
|
||||||
import forge.match.input.InputPayManaOfCostPayment;
|
import forge.match.input.InputPayManaOfCostPayment;
|
||||||
import forge.match.input.InputPayManaSimple;
|
import forge.match.input.InputPayManaSimple;
|
||||||
import forge.match.input.InputSelectCardsFromList;
|
import forge.match.input.InputSelectCardsFromList;
|
||||||
import forge.util.collect.FCollectionView;
|
|
||||||
import forge.util.Lang;
|
import forge.util.Lang;
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
import forge.util.collect.FCollectionView;
|
||||||
import forge.util.gui.SGuiChoose;
|
import forge.util.gui.SGuiChoose;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
public class HumanPlay {
|
public class HumanPlay {
|
||||||
@@ -814,7 +802,7 @@ public class HumanPlay {
|
|||||||
return !manaInputCancelled;
|
return !manaInputCancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean payManaCost(final PlayerControllerHuman controller, final ManaCost realCost, final CostPartMana mc, final SpellAbility ability, final Player activator, String prompt, boolean isActivatedSa) {
|
public static boolean payManaCost(final PlayerControllerHuman controller, final ManaCost realCost, final CostPartMana mc, final SpellAbility ability, final Player activator, String prompt, ManaConversionMatrix matrix, boolean isActivatedSa) {
|
||||||
final Card source = ability.getHostCard();
|
final Card source = ability.getHostCard();
|
||||||
ManaCostBeingPaid toPay = new ManaCostBeingPaid(realCost, mc.getRestiction());
|
ManaCostBeingPaid toPay = new ManaCostBeingPaid(realCost, mc.getRestiction());
|
||||||
|
|
||||||
@@ -879,7 +867,7 @@ public class HumanPlay {
|
|||||||
}
|
}
|
||||||
if (!toPay.isPaid()) {
|
if (!toPay.isPaid()) {
|
||||||
// Input is somehow clearing out the offering card?
|
// Input is somehow clearing out the offering card?
|
||||||
inpPayment = new InputPayManaOfCostPayment(controller, toPay, ability, activator);
|
inpPayment = new InputPayManaOfCostPayment(controller, toPay, ability, activator, matrix);
|
||||||
inpPayment.setMessagePrefix(prompt);
|
inpPayment.setMessagePrefix(prompt);
|
||||||
inpPayment.showAndWait();
|
inpPayment.showAndWait();
|
||||||
if (!inpPayment.isPaid()) {
|
if (!inpPayment.isPaid()) {
|
||||||
|
|||||||
@@ -17,14 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
package forge.player;
|
package forge.player;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import forge.card.CardStateName;
|
import forge.card.CardStateName;
|
||||||
import forge.card.CardType;
|
import forge.card.CardType;
|
||||||
import forge.card.MagicColor;
|
import forge.card.MagicColor;
|
||||||
@@ -41,13 +35,13 @@ import forge.game.keyword.KeywordInterface;
|
|||||||
import forge.game.mana.ManaPool;
|
import forge.game.mana.ManaPool;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.player.PlayerController;
|
import forge.game.player.PlayerController;
|
||||||
import forge.game.spellability.AbilityActivated;
|
import forge.game.spellability.*;
|
||||||
import forge.game.spellability.AbilitySub;
|
|
||||||
import forge.game.spellability.Spell;
|
|
||||||
import forge.game.spellability.SpellAbility;
|
|
||||||
import forge.game.spellability.TargetRestrictions;
|
|
||||||
import forge.game.zone.Zone;
|
import forge.game.zone.Zone;
|
||||||
import forge.util.collect.FCollection;
|
import forge.util.collect.FCollection;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -122,13 +116,15 @@ public class HumanPlaySpellAbility {
|
|||||||
ability.resetPaidHash();
|
ability.resetPaidHash();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO Apply this to the SAStackInstance instead of the Player
|
||||||
if (manaTypeConversion) {
|
if (manaTypeConversion) {
|
||||||
AbilityUtils.applyManaColorConversion(human, MagicColor.Constant.ANY_TYPE_CONVERSION);
|
AbilityUtils.applyManaColorConversion(payment, MagicColor.Constant.ANY_TYPE_CONVERSION);
|
||||||
} else if (manaColorConversion) {
|
} else if (manaColorConversion) {
|
||||||
AbilityUtils.applyManaColorConversion(human, MagicColor.Constant.ANY_COLOR_CONVERSION);
|
AbilityUtils.applyManaColorConversion(payment, MagicColor.Constant.ANY_COLOR_CONVERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerManaConversion) {
|
if (playerManaConversion) {
|
||||||
AbilityUtils.applyManaColorConversion(human, MagicColor.Constant.ANY_COLOR_CONVERSION);
|
AbilityUtils.applyManaColorConversion(manapool, MagicColor.Constant.ANY_COLOR_CONVERSION);
|
||||||
human.incNumManaConversion();
|
human.incNumManaConversion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +142,7 @@ public class HumanPlaySpellAbility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (keywordColor) {
|
if (keywordColor) {
|
||||||
AbilityUtils.applyManaColorConversion(human, params);
|
AbilityUtils.applyManaColorConversion(payment, params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,6 +165,7 @@ public class HumanPlaySpellAbility {
|
|||||||
ability.getHostCard().unanimateBestow();
|
ability.getHostCard().unanimateBestow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (manaTypeConversion || manaColorConversion || keywordColor) {
|
if (manaTypeConversion || manaColorConversion || keywordColor) {
|
||||||
manapool.restoreColorReplacements();
|
manapool.restoreColorReplacements();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import forge.game.cost.CostPart;
|
|||||||
import forge.game.cost.CostPartMana;
|
import forge.game.cost.CostPartMana;
|
||||||
import forge.game.keyword.Keyword;
|
import forge.game.keyword.Keyword;
|
||||||
import forge.game.mana.Mana;
|
import forge.game.mana.Mana;
|
||||||
|
import forge.game.mana.ManaConversionMatrix;
|
||||||
import forge.game.player.*;
|
import forge.game.player.*;
|
||||||
import forge.game.replacement.ReplacementEffect;
|
import forge.game.replacement.ReplacementEffect;
|
||||||
import forge.game.replacement.ReplacementLayer;
|
import forge.game.replacement.ReplacementLayer;
|
||||||
@@ -1745,8 +1746,8 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean payManaCost(final ManaCost toPay, final CostPartMana costPartMana, final SpellAbility sa,
|
public boolean payManaCost(final ManaCost toPay, final CostPartMana costPartMana, final SpellAbility sa,
|
||||||
final String prompt, final boolean isActivatedSa) {
|
final String prompt, ManaConversionMatrix matrix, final boolean isActivatedSa) {
|
||||||
return HumanPlay.payManaCost(this, toPay, costPartMana, sa, player, prompt, isActivatedSa);
|
return HumanPlay.payManaCost(this, toPay, costPartMana, sa, player, prompt, matrix, isActivatedSa);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user