mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
- The etbCounter keyword is now parsed when needed (and is now visible for the AI).
This commit is contained in:
@@ -2452,23 +2452,40 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
final StringBuilder sbMana = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < keyword.size(); i++) {
|
||||
if (!keyword.get(i).toString().contains("Permanents don't untap during their controllers' untap steps")
|
||||
&& !keyword.get(i).toString().contains("PreventAllDamageBy")
|
||||
&& !keyword.get(i).toString().contains("CantBlock")
|
||||
&& !keyword.get(i).toString().contains("CantBeBlockedBy")) {
|
||||
if (keyword.get(i).toString().contains("CostChange")) {
|
||||
if (!keyword.get(i).toString().startsWith("Permanents don't untap during their controllers' untap steps")
|
||||
&& !keyword.get(i).toString().startsWith("PreventAllDamageBy")
|
||||
&& !keyword.get(i).toString().startsWith("CantBlock")
|
||||
&& !keyword.get(i).toString().startsWith("CantBeBlockedBy")) {
|
||||
if (keyword.get(i).toString().startsWith("CostChange")) {
|
||||
final String[] k = keyword.get(i).split(":");
|
||||
if (k[k.length - 1].toString().startsWith("Desc|")) {
|
||||
final String[] kk = k[k.length - 1].split("\\|");
|
||||
sbLong.append(kk[1]).append("\r\n");
|
||||
}
|
||||
} else if (keyword.get(i).toString().contains("StaticEffect")) {
|
||||
final String[] k = keyword.get(i).split(":");
|
||||
sbLong.append(k[5]).append("\r\n");
|
||||
} else if (keyword.get(i).toString().contains("Protection:")) {
|
||||
} else if (keyword.get(i).toString().startsWith("etbCounter")) {
|
||||
final String[] p = keyword.get(i).split(":");
|
||||
final StringBuilder s = new StringBuilder();
|
||||
if (p.length > 4) {
|
||||
s.append(p[4]);
|
||||
} else {
|
||||
final Counters counter = Counters.valueOf(p[1]);
|
||||
final String numCounters = p[2];
|
||||
s.append(this.getName());
|
||||
s.append(" enters the battlefield with ");
|
||||
s.append(numCounters);
|
||||
s.append(" ");
|
||||
s.append(counter.getName());
|
||||
s.append(" counter");
|
||||
if ("1" != numCounters) {
|
||||
s.append("s");
|
||||
}
|
||||
s.append(" on it.");
|
||||
}
|
||||
sbLong.append(s).append("\r\n");;
|
||||
} else if (keyword.get(i).toString().startsWith("Protection:")) {
|
||||
final String[] k = keyword.get(i).split(":");
|
||||
sbLong.append(k[2]).append("\r\n");
|
||||
} else if (keyword.get(i).toString().contains("Creatures can't attack unless their controller pays")) {
|
||||
} else if (keyword.get(i).toString().startsWith("Creatures can't attack unless their controller pays")) {
|
||||
final String[] k = keyword.get(i).split(":");
|
||||
if (!k[3].equals("no text")) {
|
||||
sbLong.append(k[3]).append("\r\n");
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forge.Constant.Zone;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.spellability.Ability;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.staticability.StaticAbility;
|
||||
@@ -107,8 +108,6 @@ public class PlayerZoneComesIntoPlay extends DefaultPlayerZone {
|
||||
eachPlayer = true;
|
||||
addMax = 1;
|
||||
}
|
||||
// 7/13: fastbond code removed, fastbond should be unlimited and will be
|
||||
// handled elsewhere.
|
||||
|
||||
if (adjustLandPlays) {
|
||||
if (eachPlayer) {
|
||||
@@ -122,6 +121,24 @@ public class PlayerZoneComesIntoPlay extends DefaultPlayerZone {
|
||||
if (this.trigger) {
|
||||
c.setSickness(true); // summoning sickness
|
||||
c.comesIntoPlay();
|
||||
for (String keyword : c.getKeyword()) {
|
||||
if (keyword.startsWith("etbCounter")) {
|
||||
final String[] p = keyword.split(":");
|
||||
final Counters counter = Counters.valueOf(p[1]);
|
||||
final String numCounters = p[2];
|
||||
final String condition = p.length > 3 ? p[3] : "";
|
||||
if (GameActionUtil.specialConditionsMet(c, condition)) {
|
||||
int toAdd = 0;
|
||||
if (numCounters.equals("X")) {
|
||||
toAdd = CardFactoryUtil.xCount(c, c.getSVar("X"));
|
||||
} else {
|
||||
toAdd = Integer.parseInt(numCounters);
|
||||
}
|
||||
|
||||
c.addCounter(counter, toAdd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (c.isLand()) {
|
||||
CardList list = player.getCardsIn(Zone.Battlefield);
|
||||
@@ -129,9 +146,7 @@ public class PlayerZoneComesIntoPlay extends DefaultPlayerZone {
|
||||
list = list.filter(new CardListFilter() {
|
||||
@Override
|
||||
public boolean addCard(final Card c) {
|
||||
return c.hasKeyword("Landfall")
|
||||
|| c.hasKeyword("Landfall - Whenever a land enters the battlefield under your control, "
|
||||
+ "CARDNAME gets +2/+2 until end of turn.");
|
||||
return c.hasKeyword("Landfall");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -158,7 +173,6 @@ public class PlayerZoneComesIntoPlay extends DefaultPlayerZone {
|
||||
sb.append(source).append(" - tap all lands ");
|
||||
sb.append(tisLand.getController()).append(" controls.");
|
||||
ability.setStackDescription(sb.toString());
|
||||
|
||||
AllZone.getStack().addSimultaneousStackEntry(ability);
|
||||
|
||||
}
|
||||
@@ -185,10 +199,8 @@ public class PlayerZoneComesIntoPlay extends DefaultPlayerZone {
|
||||
// ability is before it is in play
|
||||
if (oLands.size() <= (pLands.size() - 1)) {
|
||||
AllZone.getStack().addSimultaneousStackEntry(ability);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} // isLand()
|
||||
}
|
||||
|
||||
@@ -198,49 +210,6 @@ public class PlayerZoneComesIntoPlay extends DefaultPlayerZone {
|
||||
AllZone.getStaticEffects().addStateBasedEffect(effect);
|
||||
}
|
||||
}
|
||||
|
||||
/*final CardList meek = player.getCardsIn(Zone.Graveyard, "Sword of the Meek");
|
||||
|
||||
if ((meek.size() > 0) && c.isCreature() && (c.getNetAttack() == 1) && (c.getNetDefense() == 1)) {
|
||||
for (int i = 0; i < meek.size(); i++) {
|
||||
final Card crd = meek.get(i);
|
||||
|
||||
final Ability ability = new Ability(meek.get(i), "0") {
|
||||
@Override
|
||||
public void resolve() {
|
||||
if (crd.getController().isHuman()) {
|
||||
if (GameActionUtil.showYesNoDialog(crd, "Attach " + crd + " to " + c + "?")) {
|
||||
if (player.getZone(Zone.Graveyard).contains(crd) && AllZoneUtil.isCardInPlay(c)
|
||||
&& c.isCreature() && (c.getNetAttack() == 1) && (c.getNetDefense() == 1)) {
|
||||
AllZone.getGameAction().moveToPlay(crd);
|
||||
|
||||
crd.equipCard(c);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (player.getZone(Zone.Graveyard).contains(crd) && AllZoneUtil.isCardInPlay(c)
|
||||
&& c.isCreature() && (c.getNetAttack() == 1) && (c.getNetDefense() == 1)) {
|
||||
AllZone.getGameAction().moveToPlay(crd);
|
||||
|
||||
crd.equipCard(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(crd);
|
||||
sb.append(" - Whenever a 1/1 creature enters the battlefield under your control, you may ");
|
||||
sb.append("return Sword of the Meek from your graveyard to the battlefield, ");
|
||||
sb.append("then attach it to that creature.");
|
||||
ability.setStackDescription(sb.toString());
|
||||
|
||||
AllZone.getStack().addSimultaneousStackEntry(ability);
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
} // end add()
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@@ -270,8 +239,6 @@ public class PlayerZoneComesIntoPlay extends DefaultPlayerZone {
|
||||
eachPlayer = true;
|
||||
addMax = -1;
|
||||
}
|
||||
// 7/12: fastbond code removed, fastbond should be unlimited and will be
|
||||
// handled elsewhere.
|
||||
|
||||
if (adjustLandPlays) {
|
||||
if (eachPlayer) {
|
||||
@@ -296,14 +263,12 @@ public class PlayerZoneComesIntoPlay extends DefaultPlayerZone {
|
||||
final Command comm = GameActionUtil.getCommands().get(tempEffect);
|
||||
comm.execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (final String effect : AllZone.getStaticEffects().getStateBasedMap().keySet()) {
|
||||
final Command com = GameActionUtil.getCommands().get(effect);
|
||||
com.execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5188,14 +5188,7 @@ public class CardFactoryUtil {
|
||||
|
||||
final int m = Integer.parseInt(parse.substring(8));
|
||||
|
||||
card.addComesIntoPlayCommand(new Command() {
|
||||
private static final long serialVersionUID = 339412525059881775L;
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
card.addCounter(Counters.P1P1, m);
|
||||
}
|
||||
});
|
||||
card.addIntrinsicKeyword("etbCounter:P1P1:" + m);
|
||||
|
||||
final SpellAbility ability = new Ability(card, "0") {
|
||||
@Override
|
||||
@@ -5234,19 +5227,16 @@ public class CardFactoryUtil {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
} // Modular
|
||||
|
||||
/*
|
||||
* WARNING: must keep this keyword processing before etbCounter keyword
|
||||
* processing.
|
||||
*/
|
||||
if (CardFactoryUtil.hasKeyword(card, "Graft") != -1) {
|
||||
final int n = CardFactoryUtil.hasKeyword(card, "Graft");
|
||||
if (n != -1) {
|
||||
final String parse = card.getKeyword().get(n).toString();
|
||||
final int graft = CardFactoryUtil.hasKeyword(card, "Graft");
|
||||
if (graft != -1) {
|
||||
final String parse = card.getKeyword().get(graft).toString();
|
||||
|
||||
final int m = Integer.parseInt(parse.substring(6));
|
||||
final String abStr = "AB$ MoveCounter | Cost$ 0 | Source$ Self | "
|
||||
@@ -5265,9 +5255,7 @@ public class CardFactoryUtil {
|
||||
card.addIntrinsicKeyword("etbCounter:P1P1:" + m);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
final int etbCounter = CardFactoryUtil.hasKeyword(card, "etbCounter");
|
||||
/*final int etbCounter = CardFactoryUtil.hasKeyword(card, "etbCounter");
|
||||
// etbCounter:CounterType:CounterAmount:Condition:Description
|
||||
// enters the battlefield with CounterAmount of CounterType
|
||||
if (etbCounter != -1) {
|
||||
@@ -5318,7 +5306,7 @@ public class CardFactoryUtil {
|
||||
|
||||
}
|
||||
}); // ComesIntoPlayCommand
|
||||
} // if etbCounter
|
||||
} // if etbCounter*/
|
||||
|
||||
final int bloodthirst = CardFactoryUtil.hasKeyword(card, "Bloodthirst");
|
||||
if (bloodthirst != -1) {
|
||||
|
||||
Reference in New Issue
Block a user