mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
- Added Crackleburr
- Added untapYType<amount/valid/description> cost type
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -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/crack_the_earth.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/cradle_guard.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/CostTapType.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/package-info.java svneol=native#text/plain
|
||||
src/main/java/forge/card/mana/IParserManaCost.java -text
|
||||
|
||||
12
res/cardsfolder/c/crackleburr.txt
Normal file
12
res/cardsfolder/c/crackleburr.txt
Normal 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
|
||||
@@ -75,6 +75,19 @@ public class Cost {
|
||||
return this.tapCost;
|
||||
}
|
||||
|
||||
private boolean untapCost = false;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getUntap.
|
||||
* </p>
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean getUntap() {
|
||||
return this.untapCost;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* hasNoManaCost.
|
||||
@@ -136,6 +149,7 @@ public class Cost {
|
||||
|
||||
// Parsing Strings
|
||||
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 ADD_STR = "AddCounter<";
|
||||
private static final String LIFE_STR = "PayLife<";
|
||||
@@ -179,6 +193,14 @@ public class Cost {
|
||||
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)) {
|
||||
// SubCounter<NumCounters/CounterType>
|
||||
final String[] splitStr = this.abCostParse(parse, Cost.SUB_STR, 5);
|
||||
|
||||
292
src/main/java/forge/card/cost/CostUntapType.java
Normal file
292
src/main/java/forge/card/cost/CostUntapType.java
Normal 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()
|
||||
}
|
||||
@@ -310,6 +310,27 @@ public class CostUtil {
|
||||
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.
|
||||
*
|
||||
|
||||
@@ -1650,6 +1650,46 @@ public class ComputerUtil {
|
||||
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>
|
||||
* chooseReturnType.
|
||||
|
||||
Reference in New Issue
Block a user