Merge branch 'comm_plate' into 'master'

StaticAbility mass keyword building updates for CMR (incl Commander's Plate and Rebbec)

See merge request core-developers/forge!3409
This commit is contained in:
Michael Kamensky
2020-11-18 05:28:35 +00:00
6 changed files with 68 additions and 14 deletions

View File

@@ -1109,12 +1109,7 @@ public class CardFactoryUtil {
} }
if (sq[0].equals("ColorsColorIdentity")) { if (sq[0].equals("ColorsColorIdentity")) {
byte ci = 0; return doXMath(c.getController().getCommanderColorID().countColors(), m, c);
List<Card> commanders = c.getController().getCommanders();
for (final Card comm : commanders) {
ci |= comm.getRules().getColorIdentity().getColor();
}
return doXMath(ColorSet.fromMask(ci).countColors(), m, c);
} }
if (sq[0].contains("CreatureType")) { if (sq[0].contains("CreatureType")) {

View File

@@ -24,6 +24,7 @@ import forge.ImageKeys;
import forge.LobbyPlayer; import forge.LobbyPlayer;
import forge.card.CardStateName; import forge.card.CardStateName;
import forge.card.CardType; import forge.card.CardType;
import forge.card.ColorSet;
import forge.card.MagicColor; import forge.card.MagicColor;
import forge.card.mana.ManaCost; import forge.card.mana.ManaCost;
import forge.card.mana.ManaCostShard; import forge.card.mana.ManaCostShard;
@@ -2760,6 +2761,26 @@ public class Player extends GameEntity implements Comparable<Player> {
return damage == null ? 0 : damage.intValue(); return damage == null ? 0 : damage.intValue();
} }
public ColorSet getCommanderColorID() {
if (commanders.isEmpty()) {
return null;
}
byte ci = 0;
for (final Card c : commanders) {
ci |= c.getRules().getColorIdentity().getColor();
}
ColorSet identity = ColorSet.fromMask(ci);
return identity;
}
public ColorSet getNotCommanderColorID() {
if (commanders.isEmpty()) {
return null;
}
ColorSet identity = getCommanderColorID();
return identity.inverse();
}
public int getCommanderCast(Card commander) { public int getCommanderCast(Card commander) {
Integer cast = commanderCast.get(commander); Integer cast = commanderCast.get(commander);
return cast == null ? 0 : cast.intValue(); return cast == null ? 0 : cast.intValue();

View File

@@ -615,14 +615,8 @@ public class AbilityManaPart implements java.io.Serializable {
if (commanders.isEmpty()) { if (commanders.isEmpty()) {
return ""; return "";
} }
byte ci = 0;
for (final Card c : commanders) {
ci |= c.getRules().getColorIdentity().getColor();
}
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
ColorSet identity = ColorSet.fromMask(ci); ColorSet identity = getSourceCard().getController().getCommanderColorID();
if (identity.hasWhite()) { sb.append("W "); } if (identity.hasWhite()) { sb.append("W "); }
if (identity.hasBlue()) { sb.append("U "); } if (identity.hasBlue()) { sb.append("U "); }
if (identity.hasBlack()) { sb.append("B "); } if (identity.hasBlack()) { sb.append("B "); }

View File

@@ -232,7 +232,20 @@ public final class StaticAbilityContinuous {
} }
return true; return true;
} }
if (input.contains("CommanderColorID")) {
if (!hostCard.getController().getCommanders().isEmpty()) {
if (input.contains("NotCommanderColorID")) {
for (Byte color : hostCard.getController().getNotCommanderColorID()) {
newKeywords.add(input.replace("NotCommanderColorID", MagicColor.toLongString(color)));
}
return true;
} else for (Byte color : hostCard.getController().getCommanderColorID()) {
newKeywords.add(input.replace("CommanderColorID", MagicColor.toLongString(color)));
}
return true;
}
return true;
}
// two variants for Red vs. red in keyword // two variants for Red vs. red in keyword
if (input.contains("ColorsYouCtrl") || input.contains("colorsYouCtrl")) { if (input.contains("ColorsYouCtrl") || input.contains("colorsYouCtrl")) {
for (byte color : colorsYouCtrl) { for (byte color : colorsYouCtrl) {
@@ -243,6 +256,21 @@ public final class StaticAbilityContinuous {
} }
return true; return true;
} }
if (input.contains("EachCMCAmongDefined")) {
String keywordDefined = params.get("KeywordDefined");
CardCollectionView definedCards = game.getCardsIn(ZoneType.Battlefield);
definedCards = CardLists.getValidCards(definedCards, keywordDefined, hostCard.getController(),
hostCard, null);
for (Card c : definedCards) {
final int cmc = c.getCMC();
String y = (input.replace(" from EachCMCAmongDefined", ":Card.cmcEQ"
+ (cmc) + ":Protection from converted mana cost " + (cmc)));
if (!newKeywords.contains(y)) {
newKeywords.add(y);
}
}
return true;
}
return false; return false;
} }
@@ -638,6 +666,7 @@ public final class StaticAbilityContinuous {
} }
return true; return true;
} }
return false; return false;
} }
}); });

View File

@@ -0,0 +1,7 @@
Name:Commander's Plate
ManaCost:1
Types:Artifact Equipment
S:Mode$ Continuous | Affected$ Creature.EquippedBy | AddPower$ 3 | AddToughness$ 3 | AddKeyword$ Protection from NotCommanderColorID | Description$ Equipped creature gets +3/+3 and has protection from each color that's not in your commander's color identity.
K:Equip:3:Creature.IsCommander+YouCtrl:commander
K:Equip:5
Oracle:Equipped creature gets +3/+3 and has protection from each color that's not in your commander's color identity.\nEquip commander {3}\nEquip {5}

View File

@@ -0,0 +1,8 @@
Name:Rebbec, Architect of Ascension
ManaCost:3 W
Types:Legendary Creature Human Artificer
PT:3/4
S:Mode$ Continuous | Affected$ Artifact.YouCtrl | AddKeyword$ Protection from EachCMCAmongDefined | KeywordDefined$ Artifact.YouCtrl | Description$ Artifacts you control have protection from each converted mana cost among artifacts you control.
DeckNeeds:Type$Artifact
K:Partner
Oracle:Artifacts you control have protection from each converted mana cost among artifacts you control.\nPartner (You can have two commanders if both have partner.)