mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
- Initial checkin for Additive Mana Conversion Static Ability (Restrictive Conversions currently not 100% correct)
- Added Mycosynth Lattice - Fixed Sunglasses of Urza
This commit is contained in:
@@ -695,6 +695,10 @@ public class GameAction {
|
||||
game.getTriggerHandler().cleanUpTemporaryTriggers();
|
||||
game.getReplacementHandler().cleanUpTemporaryReplacements();
|
||||
|
||||
for(Player p : game.getPlayers()) {
|
||||
p.getManaPool().restoreColorReplacements();
|
||||
}
|
||||
|
||||
// search for cards with static abilities
|
||||
final List<Card> allCards = game.getCardsInGame();
|
||||
final ArrayList<StaticAbility> staticAbilities = new ArrayList<StaticAbility>();
|
||||
|
||||
@@ -421,9 +421,13 @@ public class ManaPool {
|
||||
private final byte[] colorConversionMatrix = new byte[6];
|
||||
private static final byte[] identityMatrix = { MagicColor.WHITE, MagicColor.BLUE, MagicColor.BLACK, MagicColor.RED, MagicColor.GREEN, 0 };
|
||||
|
||||
public void addColorReplacement(byte originalColor, byte replacementColor) {
|
||||
int rowIdx = MagicColor.getIndexOfFirstColor(originalColor);
|
||||
colorConversionMatrix[rowIdx] |= replacementColor;
|
||||
public void adjustColorReplacement(byte originalColor, byte replacementColor, boolean additive) {
|
||||
// Fix the index based on a 6 length array with colorless in the last slot
|
||||
int rowIdx = (MagicColor.getIndexOfFirstColor(originalColor) + 6) % 6;
|
||||
if (additive)
|
||||
colorConversionMatrix[rowIdx] |= replacementColor;
|
||||
else
|
||||
colorConversionMatrix[rowIdx] &= replacementColor;
|
||||
}
|
||||
|
||||
public void restoreColorReplacements() {
|
||||
|
||||
@@ -23,11 +23,13 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.card.CardType;
|
||||
import forge.card.ColorSet;
|
||||
import forge.card.MagicColor;
|
||||
import forge.card.mana.ManaCostShard;
|
||||
import forge.game.Game;
|
||||
import forge.game.GlobalRuleChange;
|
||||
@@ -40,6 +42,7 @@ import forge.game.card.Card;
|
||||
import forge.game.card.CardFactoryUtil;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardUtil;
|
||||
import forge.game.mana.ManaPool;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.replacement.ReplacementEffect;
|
||||
import forge.game.replacement.ReplacementHandler;
|
||||
@@ -344,6 +347,37 @@ public class StaticAbilityContinuous {
|
||||
int rmax = AbilityUtils.calculateAmount(hostCard, rmhs, null);
|
||||
p.setMaxHandSize(p.getMaxHandSize() + rmax);
|
||||
}
|
||||
|
||||
if (params.containsKey("ManaColorConversion")) {
|
||||
String conversionType = params.get("ManaColorConversion");
|
||||
|
||||
// Choices are Additives(OR) or Restrictive(AND)
|
||||
boolean additive = "Additive".equals(conversionType);
|
||||
ManaPool pool = p.getManaPool();
|
||||
|
||||
for(String c : MagicColor.Constant.COLORS_AND_COLORLESS) {
|
||||
// Use the strings from MagicColor, since that's how the Script will be coming in as
|
||||
String key = WordUtils.capitalize(c) + "Conversion";
|
||||
if (params.containsKey(key)) {
|
||||
String convertTo = params.get(key);
|
||||
byte convertByte = 0;
|
||||
if ("All".equals(convertTo)) {
|
||||
convertByte = MagicColor.ALL_COLORS;
|
||||
} else{
|
||||
for(String convertColor : convertTo.split(",")) {
|
||||
convertByte |= MagicColor.fromName(convertColor);
|
||||
}
|
||||
}
|
||||
|
||||
// Celestial Dawn won't be 100% correct with this implementation
|
||||
// Since all the additives need to happen first
|
||||
// And all the restrictions need to happen second
|
||||
// But this would mostly work unless a conflicting mana conversion card
|
||||
// Is also out in play CD + Mycosynth Lattice depending on timestamps might be incorrect
|
||||
pool.adjustColorReplacement(MagicColor.fromName(c), convertByte, additive);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// start modifying the cards
|
||||
|
||||
Reference in New Issue
Block a user