- Added Crackleburr

- Added untapYType<amount/valid/description> cost type
This commit is contained in:
moomarc
2012-09-08 08:32:12 +00:00
parent 671728e4b1
commit 3bc1f0e390
6 changed files with 395 additions and 6 deletions

2
.gitattributes vendored
View File

@@ -1840,6 +1840,7 @@ res/cardsfolder/c/crab_umbra.txt svneol=native#text/plain
res/cardsfolder/c/crabapple_cohort.txt svneol=native#text/plain res/cardsfolder/c/crabapple_cohort.txt svneol=native#text/plain
res/cardsfolder/c/crack_the_earth.txt svneol=native#text/plain res/cardsfolder/c/crack_the_earth.txt svneol=native#text/plain
res/cardsfolder/c/crackdown.txt svneol=native#text/plain res/cardsfolder/c/crackdown.txt svneol=native#text/plain
res/cardsfolder/c/crackleburr.txt -text
res/cardsfolder/c/crackling_club.txt svneol=native#text/plain res/cardsfolder/c/crackling_club.txt svneol=native#text/plain
res/cardsfolder/c/cradle_guard.txt svneol=native#text/plain res/cardsfolder/c/cradle_guard.txt svneol=native#text/plain
res/cardsfolder/c/cradle_of_vitality.txt svneol=native#text/plain res/cardsfolder/c/cradle_of_vitality.txt svneol=native#text/plain
@@ -12030,6 +12031,7 @@ src/main/java/forge/card/cost/CostSacrifice.java -text
src/main/java/forge/card/cost/CostTap.java -text src/main/java/forge/card/cost/CostTap.java -text
src/main/java/forge/card/cost/CostTapType.java -text src/main/java/forge/card/cost/CostTapType.java -text
src/main/java/forge/card/cost/CostUntap.java -text src/main/java/forge/card/cost/CostUntap.java -text
src/main/java/forge/card/cost/CostUntapType.java -text
src/main/java/forge/card/cost/CostUtil.java -text src/main/java/forge/card/cost/CostUtil.java -text
src/main/java/forge/card/cost/package-info.java svneol=native#text/plain src/main/java/forge/card/cost/package-info.java svneol=native#text/plain
src/main/java/forge/card/mana/IParserManaCost.java -text src/main/java/forge/card/mana/IParserManaCost.java -text

View File

@@ -0,0 +1,12 @@
Name:Crackleburr
ManaCost:1 UR UR
Types:Creature Elemental
Text:no text
PT:2/2
A:AB$ DealDamage | Cost$ UR UR T tapXType<2/Creature.Red/red creature> | Tgt$ TgtCP | NumDmg$ 3 | SpellDescription$ CARDNAME deals 3 damage to target creature or player.
A:AB$ ChangeZone | Cost$ UR UR Q untapYType<2/Creature.Blue/blue creature> | ValidTgts$ Creature | TgtPrompt$ Select target creature | Origin$ Battlefield | Destination$ Hand | SpellDescription$ Return target creature to its owner's hand.
SVar:Rarity:Rare
SVar:Picture:http://www.wizards.com/global/images/magic/general/crackleburr.jpg
SetInfo:EVE|Rare|http://magiccards.info/scans/en/eve/100.jpg
Oracle:{U/R}{U/R}, {T}, Tap two untapped red creatures you control: Crackleburr deals 3 damage to target creature or player.\n{U/R}{U/R}, {Q}, Untap two tapped blue creatures you control: Return target creature to its owner's hand. ({Q} is the untap symbol.)
End

View File

@@ -75,6 +75,19 @@ public class Cost {
return this.tapCost; return this.tapCost;
} }
private boolean untapCost = false;
/**
* <p>
* getUntap.
* </p>
*
* @return a boolean.
*/
public final boolean getUntap() {
return this.untapCost;
}
/** /**
* <p> * <p>
* hasNoManaCost. * hasNoManaCost.
@@ -136,6 +149,7 @@ public class Cost {
// Parsing Strings // Parsing Strings
private static final String TAP_X_STR = "tapXType<"; private static final String TAP_X_STR = "tapXType<";
private static final String UNTAP_Y_STR = "untapYType<";
private static final String SUB_STR = "SubCounter<"; private static final String SUB_STR = "SubCounter<";
private static final String ADD_STR = "AddCounter<"; private static final String ADD_STR = "AddCounter<";
private static final String LIFE_STR = "PayLife<"; private static final String LIFE_STR = "PayLife<";
@@ -179,6 +193,14 @@ public class Cost {
this.costParts.add(new CostTapType(splitStr[0], splitStr[1], description)); this.costParts.add(new CostTapType(splitStr[0], splitStr[1], description));
} }
while (parse.contains(Cost.UNTAP_Y_STR)) {
final String[] splitStr = this.abCostParse(parse, Cost.UNTAP_Y_STR, 3);
parse = this.abUpdateParse(parse, Cost.UNTAP_Y_STR);
final String description = splitStr.length > 2 ? splitStr[2] : null;
this.costParts.add(new CostUntapType(splitStr[0], splitStr[1], description));
}
while (parse.contains(Cost.SUB_STR)) { while (parse.contains(Cost.SUB_STR)) {
// SubCounter<NumCounters/CounterType> // SubCounter<NumCounters/CounterType>
final String[] splitStr = this.abCostParse(parse, Cost.SUB_STR, 5); final String[] splitStr = this.abCostParse(parse, Cost.SUB_STR, 5);

View File

@@ -0,0 +1,292 @@
/*
* Forge: Play Magic: the Gathering.
* Copyright (C) 2011 Forge Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package forge.card.cost;
import forge.Card;
import forge.CardList;
import forge.CardListFilter;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.spellability.SpellAbility;
import forge.control.input.Input;
import forge.game.player.ComputerUtil;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.match.CMatchUI;
import forge.view.ButtonUtil;
/**
* The Class CostUntapType.
*/
public class CostUntapType extends CostPartWithList {
/**
* Instantiates a new cost untap type.
*
* @param amount
* the amount
* @param type
* the type
* @param description
* the description
*/
public CostUntapType(final String amount, final String type, final String description) {
super(amount, type, description);
this.setReusable(true);
}
/**
* Gets the description.
*
* @return the description
*/
public final String getDescription() {
return this.getTypeDescription() == null ? this.getType() : this.getTypeDescription();
}
/*
* (non-Javadoc)
*
* @see forge.card.cost.CostPart#toString()
*/
@Override
public final String toString() {
final StringBuilder sb = new StringBuilder();
sb.append("Untap ");
final Integer i = this.convertAmount();
final String desc = this.getDescription();
sb.append(Cost.convertAmountTypeToWords(i, this.getAmount(), " tapped " + desc));
sb.append(" you control");
return sb.toString();
}
/**
* Adds the card to untapped list.
*
* @param c
* the card
*/
public final void addToUntappedList(final Card c) {
this.getList().add(c);
}
/*
* (non-Javadoc)
*
* @see forge.card.cost.CostPart#refund(forge.Card)
*/
@Override
public final void refund(final Card source) {
for (final Card c : this.getList()) {
c.setTapped(true);
}
this.getList().clear();
}
/*
* (non-Javadoc)
*
* @see
* forge.card.cost.CostPart#canPay(forge.card.spellability.SpellAbility,
* forge.Card, forge.Player, forge.card.cost.Cost)
*/
@Override
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost) {
CardList typeList = activator.getCardsIn(ZoneType.Battlefield);
typeList = typeList.getValidCards(this.getType().split(";"), activator, source);
if (cost.getUntap()) {
typeList.remove(source);
}
typeList = typeList.filter(CardListFilter.TAPPED);
final Integer amount = this.convertAmount();
if ((typeList.size() == 0) || ((amount != null) && (typeList.size() < amount))) {
return false;
}
return true;
}
/*
* (non-Javadoc)
*
* @see forge.card.cost.CostPart#payAI(forge.card.spellability.SpellAbility,
* forge.Card, forge.card.cost.Cost_Payment)
*/
@Override
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
for (final Card c : this.getList()) {
c.untap();
}
}
/*
* (non-Javadoc)
*
* @see
* forge.card.cost.CostPart#payHuman(forge.card.spellability.SpellAbility,
* forge.Card, forge.card.cost.Cost_Payment)
*/
@Override
public final boolean payHuman(final SpellAbility ability, final Card source, final CostPayment payment) {
CardList typeList = ability.getActivatingPlayer().getCardsIn(ZoneType.Battlefield);
typeList = typeList.getValidCards(this.getType().split(";"), ability.getActivatingPlayer(),
ability.getSourceCard());
typeList = typeList.filter(CardListFilter.TAPPED);
final String amount = this.getAmount();
Integer c = this.convertAmount();
if (c == null) {
final String sVar = ability.getSVar(amount);
// Generalize this
if (sVar.equals("XChoice")) {
c = CostUtil.chooseXValue(source, ability, typeList.size());
} else {
c = AbilityFactory.calculateAmount(source, amount, ability);
}
}
CostUtil.setInput(CostUntapType.inputUntapXCost(this, typeList, ability, payment, c));
return false;
}
/*
* (non-Javadoc)
*
* @see
* forge.card.cost.CostPart#decideAIPayment(forge.card.spellability.SpellAbility
* , forge.Card, forge.card.cost.Cost_Payment)
*/
@Override
public final boolean decideAIPayment(final SpellAbility ability, final Card source, final CostPayment payment) {
final boolean untap = payment.getCost().getUntap();
final String amount = this.getAmount();
Integer c = this.convertAmount();
if (c == null) {
final String sVar = ability.getSVar(amount);
if (sVar.equals("XChoice")) {
CardList typeList = ability.getActivatingPlayer().getCardsIn(ZoneType.Battlefield);
typeList = typeList.getValidCards(this.getType().split(";"), ability.getActivatingPlayer(),
ability.getSourceCard());
if (untap) {
typeList.remove(source);
}
typeList = typeList.filter(CardListFilter.TAPPED);
c = typeList.size();
source.setSVar("ChosenX", "Number$" + Integer.toString(c));
}
}
this.setList(ComputerUtil.chooseUntapType(this.getType(), source, untap, c));
if (this.getList() == null) {
System.out.println("Couldn't find a valid card to untap for: " + source.getName());
return false;
}
return true;
}
// Inputs
/**
* <p>
* input_untapXCost.
* </p>
*
* @param untapType
* the untap type
* @param cardList
* a {@link forge.CardList} object.
* @param sa
* a {@link forge.card.spellability.SpellAbility} object.
* @param payment
* a {@link forge.card.cost.CostPayment} object.
* @param nCards
* a int.
* @return a {@link forge.control.input.Input} object.
*/
public static Input inputUntapXCost(final CostUntapType untapType, final CardList cardList, final SpellAbility sa,
final CostPayment payment, final int nCards) {
final Input target = new Input() {
private static final long serialVersionUID = -7151144318287088542L;
private int nUntapped = 0;
@Override
public void showMessage() {
if (nCards == 0) {
this.done();
}
if (cardList.size() == 0) {
this.stop();
}
final int left = nCards - this.nUntapped;
CMatchUI.SINGLETON_INSTANCE
.showMessage("Select a " + untapType.getDescription() + " to untap (" + left + " left)");
ButtonUtil.enableOnlyCancel();
}
@Override
public void selectButtonCancel() {
this.cancel();
}
@Override
public void selectCard(final Card card, final PlayerZone zone) {
if (zone.is(ZoneType.Battlefield) && cardList.contains(card) && card.isTapped()) {
// send in CardList for Typing
card.untap();
untapType.addToList(card);
cardList.remove(card);
this.nUntapped++;
if (this.nUntapped == nCards) {
this.done();
} else if (cardList.size() == 0) {
this.cancel();
} else {
this.showMessage();
}
}
}
public void cancel() {
this.stop();
payment.cancelCost();
}
public void done() {
this.stop();
untapType.addListToHash(sa, "Untapped");
payment.paidCost(untapType);
}
};
return target;
} // input_untapXCost()
}

View File

@@ -288,7 +288,7 @@ public class CostUtil {
} }
return false; return false;
} }
/** /**
* hasTapCost. * hasTapCost.
* *
@@ -310,6 +310,27 @@ public class CostUtil {
return false; return false;
} }
/**
* hasUntapCost.
*
* @param cost
* the cost
* @param source
* the source
* @return true, if successful
*/
public static boolean hasUntapCost(final Cost cost, final Card source) {
if (cost == null) {
return true;
}
for (final CostPart part : cost.getCostParts()) {
if (part instanceof CostUntapType) {
return true;
}
}
return false;
}
/** /**
* Determine amount. * Determine amount.
* *

View File

@@ -1650,6 +1650,46 @@ public class ComputerUtil {
return tapList; return tapList;
} }
/**
* <p>
* chooseUntapType.
* </p>
*
* @param type
* a {@link java.lang.String} object.
* @param activate
* a {@link forge.Card} object.
* @param untap
* a boolean.
* @param amount
* a int.
* @return a {@link forge.CardList} object.
*/
public static CardList chooseUntapType(final String type, final Card activate, final boolean untap, final int amount) {
CardList typeList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield);
typeList = typeList.getValidCards(type.split(","), activate.getController(), activate);
// is this needed?
typeList = typeList.filter(CardListFilter.TAPPED);
if (untap) {
typeList.remove(activate);
}
if (typeList.size() < amount) {
return null;
}
CardListUtil.sortAttack(typeList);
final CardList untapList = new CardList();
for (int i = 0; i < amount; i++) {
untapList.add(typeList.get(i));
}
return untapList;
}
/** /**
* <p> * <p>
* chooseReturnType. * chooseReturnType.
@@ -1752,7 +1792,7 @@ public class ComputerUtil {
public int compare(final SpellAbility a, final SpellAbility b) { public int compare(final SpellAbility a, final SpellAbility b) {
int a1 = CardUtil.getConvertedManaCost(a); int a1 = CardUtil.getConvertedManaCost(a);
int b1 = CardUtil.getConvertedManaCost(b); int b1 = CardUtil.getConvertedManaCost(b);
a1 += getSpellAbilityPriority(a); a1 += getSpellAbilityPriority(a);
b1 += getSpellAbilityPriority(b); b1 += getSpellAbilityPriority(b);
@@ -1761,7 +1801,7 @@ public class ComputerUtil {
}; // Comparator }; // Comparator
Arrays.sort(sa, c); Arrays.sort(sa, c);
} // sortSpellAbilityByCost() } // sortSpellAbilityByCost()
public static int getSpellAbilityPriority(SpellAbility sa) { public static int getSpellAbilityPriority(SpellAbility sa) {
int p = 0; int p = 0;
// puts creatures in front of spells // puts creatures in front of spells
@@ -1783,7 +1823,7 @@ public class ComputerUtil {
if ("DestroyAll".equals(mode)) { if ("DestroyAll".equals(mode)) {
p += 4; p += 4;
} }
return p; return p;
} }
@@ -2062,7 +2102,7 @@ public class ComputerUtil {
} }
return ret; return ret;
} }
/** /**
* Is this discard probably worse than a random draw? * Is this discard probably worse than a random draw?
* @param discard Card to discard * @param discard Card to discard
@@ -2078,7 +2118,7 @@ public class ComputerUtil {
final int highestCMC = Math.max(6, nonLandsInHand.getHighestConvertedManaCost()); final int highestCMC = Math.max(6, nonLandsInHand.getHighestConvertedManaCost());
final int discardCMC = discard.getCMC(); final int discardCMC = discard.getCMC();
if (discard.isLand()) { if (discard.isLand()) {
if (landsInPlay.size() >= highestCMC if (landsInPlay.size() >= highestCMC
|| (landsInPlay.size() + landsInHand.size() > 6 && landsInHand.size() > 1) || (landsInPlay.size() + landsInHand.size() > 6 && landsInHand.size() > 1)
|| (landsInPlay.size() > 3 && nonLandsInHand.size() == 0)) { || (landsInPlay.size() > 3 && nonLandsInHand.size() == 0)) {
// Don't need more land. // Don't need more land.