mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
change of Card.getKeywords() return type into List<String>
cleanup in callers of getKeywords - some were calling toString() of String, others used for with counter to iterate.
This commit is contained in:
@@ -2492,7 +2492,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add Keywords
|
// Add Keywords
|
||||||
final ArrayList<String> kw = this.getKeyword();
|
final List<String> kw = this.getKeyword();
|
||||||
|
|
||||||
// Triggered abilities
|
// Triggered abilities
|
||||||
for (final Trigger trig : this.getCharacteristics().getTriggers()) {
|
for (final Trigger trig : this.getCharacteristics().getTriggers()) {
|
||||||
@@ -4878,7 +4878,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
*
|
*
|
||||||
* @return a {@link java.util.ArrayList} object.
|
* @return a {@link java.util.ArrayList} object.
|
||||||
*/
|
*/
|
||||||
public final ArrayList<String> getKeyword() {
|
public final List<String> getKeyword() {
|
||||||
final ArrayList<String> keywords = this.getUnhiddenKeyword();
|
final ArrayList<String> keywords = this.getUnhiddenKeyword();
|
||||||
keywords.addAll(this.getHiddenExtrinsicKeyword());
|
keywords.addAll(this.getHiddenExtrinsicKeyword());
|
||||||
|
|
||||||
@@ -5978,7 +5978,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public final boolean hasStartOfKeyword(final String keyword) {
|
public final boolean hasStartOfKeyword(final String keyword) {
|
||||||
final ArrayList<String> a = this.getKeyword();
|
final List<String> a = this.getKeyword();
|
||||||
for (int i = 0; i < a.size(); i++) {
|
for (int i = 0; i < a.size(); i++) {
|
||||||
if (a.get(i).toString().startsWith(keyword)) {
|
if (a.get(i).toString().startsWith(keyword)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -6016,7 +6016,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
* @return a int.
|
* @return a int.
|
||||||
*/
|
*/
|
||||||
public final int getKeywordPosition(final String k) {
|
public final int getKeywordPosition(final String k) {
|
||||||
final ArrayList<String> a = this.getKeyword();
|
final List<String> a = this.getKeyword();
|
||||||
for (int i = 0; i < a.size(); i++) {
|
for (int i = 0; i < a.size(); i++) {
|
||||||
if (a.get(i).toString().startsWith(k)) {
|
if (a.get(i).toString().startsWith(k)) {
|
||||||
return i;
|
return i;
|
||||||
@@ -6097,8 +6097,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
*/
|
*/
|
||||||
public final int getKeywordMagnitude(final String k) {
|
public final int getKeywordMagnitude(final String k) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
final ArrayList<String> keywords = this.getKeyword();
|
for (final String kw : this.getKeyword()) {
|
||||||
for (final String kw : keywords) {
|
|
||||||
if (kw.startsWith(k)) {
|
if (kw.startsWith(k)) {
|
||||||
final String[] parse = kw.split(" ");
|
final String[] parse = kw.split(" ");
|
||||||
final String s = parse[1];
|
final String s = parse[1];
|
||||||
@@ -8691,7 +8690,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.getKeyword() != null) {
|
if (this.getKeyword() != null) {
|
||||||
final ArrayList<String> list = this.getKeyword();
|
final List<String> list = this.getKeyword();
|
||||||
|
|
||||||
String kw = "";
|
String kw = "";
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
@@ -8829,12 +8828,9 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.getKeyword() != null) {
|
if (this.getKeyword() != null) {
|
||||||
final ArrayList<String> list = this.getKeyword();
|
|
||||||
final Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
|
|
||||||
String kw = "";
|
for (String kw : this.getKeyword()) {
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
kw = list.get(i);
|
|
||||||
if (kw.equals("Shroud")) {
|
if (kw.equals("Shroud")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -750,89 +750,66 @@ public class CardFactoryCreatures {
|
|||||||
// end of card specific code
|
// end of card specific code
|
||||||
// ***************************************************
|
// ***************************************************
|
||||||
|
|
||||||
if ((CardFactoryCreatures.hasKeyword(card, "Level up") != -1)
|
final int iLvlUp = CardFactoryUtil.hasKeyword(card, "Level up");
|
||||||
&& (CardFactoryCreatures.hasKeyword(card, "maxLevel") != -1)) {
|
final int iLvlMax = CardFactoryUtil.hasKeyword(card, "maxLevel");
|
||||||
final int n = CardFactoryCreatures.hasKeyword(card, "Level up");
|
|
||||||
final int m = CardFactoryCreatures.hasKeyword(card, "maxLevel");
|
if (iLvlUp != -1 && iLvlMax != -1) {
|
||||||
if (n != -1) {
|
final String parse = card.getKeyword().get(iLvlUp);
|
||||||
final String parse = card.getKeyword().get(n).toString();
|
final String parseMax = card.getKeyword().get(iLvlMax);
|
||||||
final String parseMax = card.getKeyword().get(m).toString();
|
card.addSpellAbility(makeLevellerAbility(card, parse, parseMax));
|
||||||
|
card.setLevelUp(true);
|
||||||
card.removeIntrinsicKeyword(parse);
|
|
||||||
card.removeIntrinsicKeyword(parseMax);
|
|
||||||
|
|
||||||
final String[] k = parse.split(":");
|
|
||||||
final String manacost = k[1];
|
|
||||||
|
|
||||||
final String[] l = parseMax.split(":");
|
|
||||||
final int maxLevel = Integer.parseInt(l[1]);
|
|
||||||
|
|
||||||
class LevelUpAbility extends AbilityActivated {
|
|
||||||
public LevelUpAbility(final Card ca, final String s) {
|
|
||||||
super(ca, new Cost(ca, manacost, true), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AbilityActivated getCopy() {
|
|
||||||
AbilityActivated levelUp = new LevelUpAbility(getSourceCard(), getPayCosts().toString());
|
|
||||||
levelUp.getRestrictions().setSorcerySpeed(true);
|
|
||||||
return levelUp;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 3998280279949548652L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void resolve() {
|
|
||||||
card.addCounter(CounterType.LEVEL, 1, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canPlayAI() {
|
|
||||||
// Todo: Improve Level up code
|
|
||||||
return card.getCounters(CounterType.LEVEL) < maxLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription() {
|
|
||||||
final StringBuilder sbDesc = new StringBuilder();
|
|
||||||
sbDesc.append("Level up ").append(manacost).append(" (").append(manacost);
|
|
||||||
sbDesc.append(": Put a level counter on this. Level up only as a sorcery.)");
|
|
||||||
return sbDesc.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final SpellAbility levelUp = new LevelUpAbility(card, manacost);
|
|
||||||
levelUp.getRestrictions().setSorcerySpeed(true);
|
|
||||||
card.addSpellAbility(levelUp);
|
|
||||||
|
|
||||||
final StringBuilder sbStack = new StringBuilder();
|
|
||||||
sbStack.append(card).append(" - put a level counter on this.");
|
|
||||||
levelUp.setStackDescription(sbStack.toString());
|
|
||||||
|
|
||||||
card.setLevelUp(true);
|
|
||||||
|
|
||||||
}
|
|
||||||
} // level up
|
} // level up
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
private static SpellAbility makeLevellerAbility(final Card card, final String strLevelCost, final String strMaxLevel) {
|
||||||
* hasKeyword.
|
card.removeIntrinsicKeyword(strLevelCost);
|
||||||
* </p>
|
card.removeIntrinsicKeyword(strMaxLevel);
|
||||||
*
|
|
||||||
* @param c
|
final String[] k = strLevelCost.split(":");
|
||||||
* a {@link forge.Card} object.
|
final String manacost = k[1];
|
||||||
* @param k
|
|
||||||
* a {@link java.lang.String} object.
|
final String[] l = strMaxLevel.split(":");
|
||||||
* @return a int.
|
final int maxLevel = Integer.parseInt(l[1]);
|
||||||
*/
|
|
||||||
private static int hasKeyword(final Card c, final String k) {
|
class LevelUpAbility extends AbilityActivated {
|
||||||
final ArrayList<String> a = c.getKeyword();
|
public LevelUpAbility(final Card ca, final String s) {
|
||||||
for (int i = 0; i < a.size(); i++) {
|
super(ca, new Cost(ca, manacost, true), null);
|
||||||
if (a.get(i).toString().startsWith(k)) {
|
}
|
||||||
return i;
|
|
||||||
|
@Override
|
||||||
|
public AbilityActivated getCopy() {
|
||||||
|
AbilityActivated levelUp = new LevelUpAbility(getSourceCard(), getPayCosts().toString());
|
||||||
|
levelUp.getRestrictions().setSorcerySpeed(true);
|
||||||
|
return levelUp;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 3998280279949548652L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resolve() {
|
||||||
|
card.addCounter(CounterType.LEVEL, 1, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canPlayAI() {
|
||||||
|
// Todo: Improve Level up code
|
||||||
|
return card.getCounters(CounterType.LEVEL) < maxLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
final StringBuilder sbDesc = new StringBuilder();
|
||||||
|
sbDesc.append("Level up ").append(manacost).append(" (").append(manacost);
|
||||||
|
sbDesc.append(": Put a level counter on this. Level up only as a sorcery.)");
|
||||||
|
return sbDesc.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
final SpellAbility levelUp = new LevelUpAbility(card, manacost);
|
||||||
return -1;
|
levelUp.getRestrictions().setSorcerySpeed(true);
|
||||||
|
final StringBuilder sbStack = new StringBuilder();
|
||||||
|
sbStack.append(card).append(" - put a level counter on this.");
|
||||||
|
levelUp.setStackDescription(sbStack.toString());
|
||||||
|
return levelUp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ import forge.CounterType;
|
|||||||
import forge.GameEntity;
|
import forge.GameEntity;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.CardCharacteristics;
|
import forge.card.CardCharacteristics;
|
||||||
import forge.card.MagicColor;
|
|
||||||
import forge.card.ability.AbilityFactory;
|
import forge.card.ability.AbilityFactory;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.ability.ApiType;
|
import forge.card.ability.ApiType;
|
||||||
@@ -1822,9 +1821,8 @@ public class CardFactoryUtil {
|
|||||||
|
|
||||||
// Count$BushidoPoint
|
// Count$BushidoPoint
|
||||||
if (sq[0].contains("BushidoPoint")) {
|
if (sq[0].contains("BushidoPoint")) {
|
||||||
final ArrayList<String> keywords = c.getKeyword();
|
|
||||||
int magnitude = 0;
|
int magnitude = 0;
|
||||||
for (final String kw : keywords) {
|
for (final String kw : c.getKeyword()) {
|
||||||
if (kw.contains("Bushido")) {
|
if (kw.contains("Bushido")) {
|
||||||
final String[] parse = kw.split(" ");
|
final String[] parse = kw.split(" ");
|
||||||
final String num = parse[1];
|
final String num = parse[1];
|
||||||
@@ -2528,12 +2526,11 @@ public class CardFactoryUtil {
|
|||||||
* @return a {@link java.util.ArrayList} object.
|
* @return a {@link java.util.ArrayList} object.
|
||||||
*/
|
*/
|
||||||
public static ArrayList<Ability> getBushidoEffects(final Card c) {
|
public static ArrayList<Ability> getBushidoEffects(final Card c) {
|
||||||
final ArrayList<String> keywords = c.getKeyword();
|
|
||||||
final ArrayList<Ability> list = new ArrayList<Ability>();
|
final ArrayList<Ability> list = new ArrayList<Ability>();
|
||||||
|
|
||||||
final Card crd = c;
|
final Card crd = c;
|
||||||
|
|
||||||
for (final String kw : keywords) {
|
for (final String kw : c.getKeyword()) {
|
||||||
if (kw.contains("Bushido")) {
|
if (kw.contains("Bushido")) {
|
||||||
final String[] parse = kw.split(" ");
|
final String[] parse = kw.split(" ");
|
||||||
final String s = parse[1];
|
final String s = parse[1];
|
||||||
@@ -2862,11 +2859,9 @@ public class CardFactoryUtil {
|
|||||||
if (CardFactoryUtil.hasKeyword(card, "Transmute") != -1) {
|
if (CardFactoryUtil.hasKeyword(card, "Transmute") != -1) {
|
||||||
final int n = CardFactoryUtil.hasKeyword(card, "Transmute");
|
final int n = CardFactoryUtil.hasKeyword(card, "Transmute");
|
||||||
if (n != -1) {
|
if (n != -1) {
|
||||||
final String parse = card.getKeyword().get(n).toString();
|
final String parse = card.getKeyword().get(n);
|
||||||
card.removeIntrinsicKeyword(parse);
|
card.removeIntrinsicKeyword(parse);
|
||||||
|
final String manacost = parse.split(":")[1];
|
||||||
final String[] k = parse.split(":");
|
|
||||||
final String manacost = k[1];
|
|
||||||
|
|
||||||
card.addSpellAbility(CardFactoryUtil.abilityTransmute(card, manacost));
|
card.addSpellAbility(CardFactoryUtil.abilityTransmute(card, manacost));
|
||||||
}
|
}
|
||||||
@@ -2895,8 +2890,7 @@ public class CardFactoryUtil {
|
|||||||
final int echoPos = CardFactoryUtil.hasKeyword(card, "Echo");
|
final int echoPos = CardFactoryUtil.hasKeyword(card, "Echo");
|
||||||
if (echoPos != -1) {
|
if (echoPos != -1) {
|
||||||
// card.removeIntrinsicKeyword(parse);
|
// card.removeIntrinsicKeyword(parse);
|
||||||
final String parse = card.getKeyword().get(echoPos);
|
final String[] k = card.getKeyword().get(echoPos).split(":");
|
||||||
final String[] k = parse.split(":");
|
|
||||||
final String manacost = k[1];
|
final String manacost = k[1];
|
||||||
|
|
||||||
card.setEchoCost(manacost);
|
card.setEchoCost(manacost);
|
||||||
@@ -2918,7 +2912,7 @@ public class CardFactoryUtil {
|
|||||||
// Suspend:<TimeCounters>:<Cost>
|
// Suspend:<TimeCounters>:<Cost>
|
||||||
final int n = CardFactoryUtil.hasKeyword(card, "Suspend");
|
final int n = CardFactoryUtil.hasKeyword(card, "Suspend");
|
||||||
if (n != -1) {
|
if (n != -1) {
|
||||||
final String parse = card.getKeyword().get(n).toString();
|
final String parse = card.getKeyword().get(n);
|
||||||
card.removeIntrinsicKeyword(parse);
|
card.removeIntrinsicKeyword(parse);
|
||||||
card.setSuspend(true);
|
card.setSuspend(true);
|
||||||
final String[] k = parse.split(":");
|
final String[] k = parse.split(":");
|
||||||
@@ -2939,9 +2933,7 @@ public class CardFactoryUtil {
|
|||||||
if (CardFactoryUtil.hasKeyword(card, "Fading") != -1) {
|
if (CardFactoryUtil.hasKeyword(card, "Fading") != -1) {
|
||||||
final int n = CardFactoryUtil.hasKeyword(card, "Fading");
|
final int n = CardFactoryUtil.hasKeyword(card, "Fading");
|
||||||
if (n != -1) {
|
if (n != -1) {
|
||||||
final String parse = card.getKeyword().get(n).toString();
|
final String[] k = card.getKeyword().get(n).split(":");
|
||||||
|
|
||||||
final String[] k = parse.split(":");
|
|
||||||
final int power = Integer.parseInt(k[1]);
|
final int power = Integer.parseInt(k[1]);
|
||||||
|
|
||||||
card.addComesIntoPlayCommand(CardFactoryUtil.fading(card, power));
|
card.addComesIntoPlayCommand(CardFactoryUtil.fading(card, power));
|
||||||
@@ -2951,9 +2943,7 @@ public class CardFactoryUtil {
|
|||||||
if (CardFactoryUtil.hasKeyword(card, "Vanishing") != -1) {
|
if (CardFactoryUtil.hasKeyword(card, "Vanishing") != -1) {
|
||||||
final int n = CardFactoryUtil.hasKeyword(card, "Vanishing");
|
final int n = CardFactoryUtil.hasKeyword(card, "Vanishing");
|
||||||
if (n != -1) {
|
if (n != -1) {
|
||||||
final String parse = card.getKeyword().get(n).toString();
|
final String[] k = card.getKeyword().get(n).split(":");
|
||||||
|
|
||||||
final String[] k = parse.split(":");
|
|
||||||
final int power = Integer.parseInt(k[1]);
|
final int power = Integer.parseInt(k[1]);
|
||||||
|
|
||||||
card.addComesIntoPlayCommand(CardFactoryUtil.vanishing(card, power));
|
card.addComesIntoPlayCommand(CardFactoryUtil.vanishing(card, power));
|
||||||
@@ -3591,7 +3581,7 @@ public class CardFactoryUtil {
|
|||||||
* @return a int.
|
* @return a int.
|
||||||
*/
|
*/
|
||||||
public static final int hasKeyword(final Card c, final String k) {
|
public static final int hasKeyword(final Card c, final String k) {
|
||||||
final ArrayList<String> a = c.getKeyword();
|
final List<String> a = c.getKeyword();
|
||||||
for (int i = 0; i < a.size(); i++) {
|
for (int i = 0; i < a.size(); i++) {
|
||||||
if (a.get(i).startsWith(k)) {
|
if (a.get(i).startsWith(k)) {
|
||||||
return i;
|
return i;
|
||||||
@@ -3615,7 +3605,7 @@ public class CardFactoryUtil {
|
|||||||
* @return a int.
|
* @return a int.
|
||||||
*/
|
*/
|
||||||
static final int hasKeyword(final Card c, final String k, final int startPos) {
|
static final int hasKeyword(final Card c, final String k, final int startPos) {
|
||||||
final ArrayList<String> a = c.getKeyword();
|
final List<String> a = c.getKeyword();
|
||||||
for (int i = startPos; i < a.size(); i++) {
|
for (int i = startPos; i < a.size(); i++) {
|
||||||
if (a.get(i).startsWith(k)) {
|
if (a.get(i).startsWith(k)) {
|
||||||
return i;
|
return i;
|
||||||
|
|||||||
@@ -121,10 +121,7 @@ public class InputMulligan extends Input {
|
|||||||
|
|
||||||
for (final Card c : openingHand) {
|
for (final Card c : openingHand) {
|
||||||
if (p.isHuman()) {
|
if (p.isHuman()) {
|
||||||
final ArrayList<String> kws = c.getKeyword();
|
for (String kw : c.getKeyword()) {
|
||||||
for (int i = 0; i < kws.size(); i++) {
|
|
||||||
final String kw = kws.get(i);
|
|
||||||
|
|
||||||
if (kw.startsWith("MayEffectFromOpeningHand")) {
|
if (kw.startsWith("MayEffectFromOpeningHand")) {
|
||||||
final String effName = kw.split(":")[1];
|
final String effName = kw.split(":")[1];
|
||||||
|
|
||||||
@@ -143,10 +140,7 @@ public class InputMulligan extends Input {
|
|||||||
}
|
}
|
||||||
} else { // Computer Leylines & Chancellors
|
} else { // Computer Leylines & Chancellors
|
||||||
if (!c.getName().startsWith("Leyline of")) {
|
if (!c.getName().startsWith("Leyline of")) {
|
||||||
final ArrayList<String> kws = c.getKeyword();
|
for (String kw : c.getKeyword()) {
|
||||||
for (int i = 0; i < kws.size(); i++) {
|
|
||||||
final String kw = kws.get(i);
|
|
||||||
|
|
||||||
if (kw.startsWith("MayEffectFromOpeningHand")) {
|
if (kw.startsWith("MayEffectFromOpeningHand")) {
|
||||||
final String effName = kw.split(":")[1];
|
final String effName = kw.split(":")[1];
|
||||||
|
|
||||||
|
|||||||
@@ -333,7 +333,7 @@ public final class GameActionUtil {
|
|||||||
c.addExtrinsicKeyword("Ripple:4");
|
c.addExtrinsicKeyword("Ripple:4");
|
||||||
}
|
}
|
||||||
|
|
||||||
final ArrayList<String> a = c.getKeyword();
|
final List<String> a = c.getKeyword();
|
||||||
for (int x = 0; x < a.size(); x++) {
|
for (int x = 0; x < a.size(); x++) {
|
||||||
if (a.get(x).toString().startsWith("Ripple")) {
|
if (a.get(x).toString().startsWith("Ripple")) {
|
||||||
final String parse = c.getKeyword().get(x).toString();
|
final String parse = c.getKeyword().get(x).toString();
|
||||||
@@ -713,41 +713,38 @@ public final class GameActionUtil {
|
|||||||
* a {@link forge.Card} object.
|
* a {@link forge.Card} object.
|
||||||
*/
|
*/
|
||||||
public static void executeVampiricEffects(final Card c) {
|
public static void executeVampiricEffects(final Card c) {
|
||||||
final ArrayList<String> a = c.getKeyword();
|
if (!c.isInPlay()) return;
|
||||||
for (int i = 0; i < a.size(); i++) {
|
|
||||||
if (c.isInPlay()
|
|
||||||
&& a.get(i)
|
|
||||||
.toString()
|
|
||||||
.startsWith(
|
|
||||||
"Whenever a creature dealt damage by CARDNAME "
|
|
||||||
+ "this turn is put into a graveyard, put")) {
|
|
||||||
final Card thisCard = c;
|
|
||||||
final String kw = a.get(i).toString();
|
|
||||||
final Ability ability2 = new Ability(c, ManaCost.ZERO) {
|
|
||||||
@Override
|
|
||||||
public void resolve() {
|
|
||||||
CounterType counter = CounterType.P1P1;
|
|
||||||
if (kw.contains("+2/+2")) {
|
|
||||||
counter = CounterType.P2P2;
|
|
||||||
}
|
|
||||||
if (thisCard.isInPlay()) {
|
|
||||||
thisCard.addCounter(counter, 1, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}; // ability2
|
|
||||||
|
|
||||||
final StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append(c.getName());
|
|
||||||
if (kw.contains("+2/+2")) {
|
|
||||||
sb.append(" - gets a +2/+2 counter");
|
|
||||||
} else {
|
|
||||||
sb.append(" - gets a +1/+1 counter");
|
|
||||||
}
|
|
||||||
ability2.setStackDescription(sb.toString());
|
|
||||||
|
|
||||||
Singletons.getModel().getGame().getStack().addSimultaneousStackEntry(ability2);
|
|
||||||
|
|
||||||
|
for (final String kw : c.getKeyword()) {
|
||||||
|
if(!kw.startsWith("Whenever a creature dealt damage by CARDNAME this turn is put into a graveyard, put")) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
final Card thisCard = c;
|
||||||
|
|
||||||
|
final Ability ability2 = new Ability(c, ManaCost.ZERO) {
|
||||||
|
@Override
|
||||||
|
public void resolve() {
|
||||||
|
CounterType counter = CounterType.P1P1;
|
||||||
|
if (kw.contains("+2/+2")) {
|
||||||
|
counter = CounterType.P2P2;
|
||||||
|
}
|
||||||
|
if (thisCard.isInPlay()) {
|
||||||
|
thisCard.addCounter(counter, 1, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}; // ability2
|
||||||
|
|
||||||
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(c.getName());
|
||||||
|
if (kw.contains("+2/+2")) {
|
||||||
|
sb.append(" - gets a +2/+2 counter");
|
||||||
|
} else {
|
||||||
|
sb.append(" - gets a +1/+1 counter");
|
||||||
|
}
|
||||||
|
ability2.setStackDescription(sb.toString());
|
||||||
|
|
||||||
|
Singletons.getModel().getGame().getStack().addSimultaneousStackEntry(ability2);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -823,13 +820,11 @@ public final class GameActionUtil {
|
|||||||
sb.append(".");
|
sb.append(".");
|
||||||
|
|
||||||
ability.setStackDescription(sb.toString());
|
ability.setStackDescription(sb.toString());
|
||||||
final ArrayList<String> keywords = c.getKeyword();
|
|
||||||
|
|
||||||
for (int i = 0; i < keywords.size(); i++) {
|
for (String kw : c.getKeyword()) {
|
||||||
if (keywords.get(i).startsWith("Poisonous")) {
|
if (kw.startsWith("Poisonous")) {
|
||||||
Singletons.getModel().getGame().getStack().addSimultaneousStackEntry(ability);
|
Singletons.getModel().getGame().getStack().addSimultaneousStackEntry(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -880,36 +880,32 @@ public class CombatUtil {
|
|||||||
// CARDNAME can't attack if defending player controls an untapped
|
// CARDNAME can't attack if defending player controls an untapped
|
||||||
// creature with power ...
|
// creature with power ...
|
||||||
final int[] powerLimit = { 0 };
|
final int[] powerLimit = { 0 };
|
||||||
int keywordPosition = 0;
|
String cantAttackKw = null;
|
||||||
boolean hasKeyword = false;
|
|
||||||
|
|
||||||
final ArrayList<String> attackerKeywords = c.getKeyword();
|
|
||||||
for (int i = 0; i < attackerKeywords.size(); i++) {
|
for( String kw : c.getKeyword()) {
|
||||||
if (attackerKeywords.get(i).toString()
|
if (kw.startsWith("CARDNAME can't attack if defending player controls an untapped creature with power")) {
|
||||||
.startsWith("CARDNAME can't attack if defending player controls an untapped creature with power")) {
|
cantAttackKw = kw;
|
||||||
hasKeyword = true;
|
|
||||||
keywordPosition = i;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The keyword
|
// The keyword
|
||||||
// "CARDNAME can't attack if defending player controls an untapped creature with power"
|
// "CARDNAME can't attack if defending player controls an untapped creature with power"
|
||||||
// ... is present
|
// ... is present
|
||||||
if (hasKeyword) {
|
if (cantAttackKw != null) {
|
||||||
final String tmpString = c.getKeyword().get(keywordPosition).toString();
|
final String[] asSeparateWords = cantAttackKw.trim().split(" ");
|
||||||
final String[] asSeparateWords = tmpString.trim().split(" ");
|
|
||||||
|
|
||||||
if (asSeparateWords.length >= 15) {
|
if (asSeparateWords.length >= 15) {
|
||||||
if (asSeparateWords[12].matches("[0-9][0-9]?")) {
|
if (StringUtils.isNumeric(asSeparateWords[12])) {
|
||||||
powerLimit[0] = Integer.parseInt((asSeparateWords[12]).trim());
|
powerLimit[0] = Integer.parseInt((asSeparateWords[12]).trim());
|
||||||
|
|
||||||
List<Card> list = defendingPlayer.getCreaturesInPlay();
|
List<Card> list = defendingPlayer.getCreaturesInPlay();
|
||||||
list = CardLists.filter(list, new Predicate<Card>() {
|
list = CardLists.filter(list, new Predicate<Card>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(final Card ct) {
|
public boolean apply(final Card ct) {
|
||||||
return ((ct.isUntapped() && (ct.getNetAttack() >= powerLimit[0]) && asSeparateWords[14]
|
return (ct.isUntapped()
|
||||||
.contains("greater")) || (ct.isUntapped() && (ct.getNetAttack() <= powerLimit[0]) && asSeparateWords[14]
|
&& ((ct.getNetAttack() >= powerLimit[0] && asSeparateWords[14].contains("greater"))
|
||||||
.contains("less")));
|
|| (ct.getNetAttack() <= powerLimit[0] && asSeparateWords[14].contains("less"))));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!list.isEmpty()) {
|
if (!list.isEmpty()) {
|
||||||
@@ -1247,8 +1243,7 @@ public class CombatUtil {
|
|||||||
|
|
||||||
// Annihilator:
|
// Annihilator:
|
||||||
if (!c.getDamageHistory().getCreatureAttackedThisCombat()) {
|
if (!c.getDamageHistory().getCreatureAttackedThisCombat()) {
|
||||||
final ArrayList<String> kws = c.getKeyword();
|
for (final String key : c.getKeyword()) {
|
||||||
for (final String key : kws) {
|
|
||||||
if( !key.startsWith("Annihilator ") ) continue;
|
if( !key.startsWith("Annihilator ") ) continue;
|
||||||
final String[] k = key.split(" ", 2);
|
final String[] k = key.split(" ", 2);
|
||||||
final int a = Integer.valueOf(k[1]);
|
final int a = Integer.valueOf(k[1]);
|
||||||
@@ -1419,7 +1414,7 @@ public class CombatUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Rampage
|
// Rampage
|
||||||
final ArrayList<String> keywords = a.getKeyword();
|
final List<String> keywords = a.getKeyword();
|
||||||
final Pattern p = Pattern.compile("Rampage [0-9]+");
|
final Pattern p = Pattern.compile("Rampage [0-9]+");
|
||||||
Matcher m;
|
Matcher m;
|
||||||
for (final String keyword : keywords) {
|
for (final String keyword : keywords) {
|
||||||
@@ -1437,11 +1432,8 @@ public class CombatUtil {
|
|||||||
|
|
||||||
if (a.hasKeyword("Flanking") && !b.hasKeyword("Flanking")) {
|
if (a.hasKeyword("Flanking") && !b.hasKeyword("Flanking")) {
|
||||||
int flankingMagnitude = 0;
|
int flankingMagnitude = 0;
|
||||||
String kw = "";
|
|
||||||
final ArrayList<String> list = a.getKeyword();
|
|
||||||
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (String kw : a.getKeyword()) {
|
||||||
kw = list.get(i);
|
|
||||||
if (kw.equals("Flanking")) {
|
if (kw.equals("Flanking")) {
|
||||||
flankingMagnitude++;
|
flankingMagnitude++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -268,9 +268,7 @@ public class Upkeep extends Phase {
|
|||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
final Card c = list.get(i);
|
final Card c = list.get(i);
|
||||||
final Player controller = c.getController();
|
final Player controller = c.getController();
|
||||||
final ArrayList<String> a = c.getKeyword();
|
for (String ability : c.getKeyword()) {
|
||||||
for (int j = 0; j < a.size(); j++) {
|
|
||||||
final String ability = a.get(j);
|
|
||||||
|
|
||||||
// destroy
|
// destroy
|
||||||
if (ability.startsWith("At the beginning of your upkeep, destroy CARDNAME")) {
|
if (ability.startsWith("At the beginning of your upkeep, destroy CARDNAME")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user