mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Initial checkin of CostReveal
Some preparation for actual Payment occurring after all Costs have been completed. Add Living Destiny
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -4380,6 +4380,7 @@ res/cardsfolder/l/living_airship.txt svneol=native#text/plain
|
|||||||
res/cardsfolder/l/living_armor.txt svneol=native#text/plain
|
res/cardsfolder/l/living_armor.txt svneol=native#text/plain
|
||||||
res/cardsfolder/l/living_artifact.txt svneol=native#text/plain
|
res/cardsfolder/l/living_artifact.txt svneol=native#text/plain
|
||||||
res/cardsfolder/l/living_death.txt svneol=native#text/plain
|
res/cardsfolder/l/living_death.txt svneol=native#text/plain
|
||||||
|
res/cardsfolder/l/living_destiny.txt -text
|
||||||
res/cardsfolder/l/living_hive.txt svneol=native#text/plain
|
res/cardsfolder/l/living_hive.txt svneol=native#text/plain
|
||||||
res/cardsfolder/l/living_lands.txt svneol=native#text/plain
|
res/cardsfolder/l/living_lands.txt svneol=native#text/plain
|
||||||
res/cardsfolder/l/living_plane.txt svneol=native#text/plain
|
res/cardsfolder/l/living_plane.txt svneol=native#text/plain
|
||||||
@@ -9611,6 +9612,7 @@ src/main/java/forge/card/cost/CostPayLife.java -text
|
|||||||
src/main/java/forge/card/cost/CostPutCounter.java -text
|
src/main/java/forge/card/cost/CostPutCounter.java -text
|
||||||
src/main/java/forge/card/cost/CostRemoveCounter.java -text
|
src/main/java/forge/card/cost/CostRemoveCounter.java -text
|
||||||
src/main/java/forge/card/cost/CostReturn.java -text
|
src/main/java/forge/card/cost/CostReturn.java -text
|
||||||
|
src/main/java/forge/card/cost/CostReveal.java -text
|
||||||
src/main/java/forge/card/cost/CostSacrifice.java -text
|
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
|
||||||
|
|||||||
10
res/cardsfolder/l/living_destiny.txt
Normal file
10
res/cardsfolder/l/living_destiny.txt
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
Name:Living Destiny
|
||||||
|
ManaCost:3 G
|
||||||
|
Types:Instant
|
||||||
|
Text:no text
|
||||||
|
A:SP$ GainLife | Cost$ 3 G Reveal<1/Creature> | LifeAmount$ X | SpellDescription$ You gain life equal to the revealed card's converted mana cost.
|
||||||
|
SVar:X:Revealed$CardManaCost
|
||||||
|
SVar:RemAIDeck:True
|
||||||
|
SVar:Rarity:Common
|
||||||
|
SVar:Picture:http://www.wizards.com/global/images/magic/general/living_destiny.jpg
|
||||||
|
End
|
||||||
@@ -490,15 +490,17 @@ public class GameAction {
|
|||||||
CardList hand = AllZoneUtil.getPlayerHand(AllZone.getComputerPlayer());
|
CardList hand = AllZoneUtil.getPlayerHand(AllZone.getComputerPlayer());
|
||||||
hand = hand.getValidCards(uTypes, sa.getActivatingPlayer(), sa.getSourceCard());
|
hand = hand.getValidCards(uTypes, sa.getActivatingPlayer(), sa.getSourceCard());
|
||||||
|
|
||||||
if (hand.size() < numDiscard)
|
if (hand.size() < numDiscard){
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
CardList discard = new CardList();
|
CardList discard = new CardList();
|
||||||
|
|
||||||
CardListUtil.sortCMC(hand);
|
CardListUtil.sortCMC(hand);
|
||||||
hand.reverse();
|
hand.reverse();
|
||||||
for (int i = 0; i < numDiscard; i++)
|
for (int i = 0; i < numDiscard; i++){
|
||||||
discard.add(hand.get(i));
|
discard.add(hand.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
return discard;
|
return discard;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1105,13 +1105,19 @@ public abstract class Player extends MyObservable {
|
|||||||
*
|
*
|
||||||
* @param num a int.
|
* @param num a int.
|
||||||
* @param sa a {@link forge.card.spellability.SpellAbility} object.
|
* @param sa a {@link forge.card.spellability.SpellAbility} object.
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public void discardRandom(final int num, final SpellAbility sa) {
|
public CardList discardRandom(final int num, final SpellAbility sa) {
|
||||||
|
CardList discarded = new CardList();
|
||||||
for (int i = 0; i < num; i++) {
|
for (int i = 0; i < num; i++) {
|
||||||
CardList list = AllZoneUtil.getPlayerHand(this);
|
CardList list = AllZoneUtil.getPlayerHand(this);
|
||||||
if (list.size() != 0)
|
if (list.size() != 0){
|
||||||
doDiscard(CardUtil.getRandom(list.toArray()), sa);
|
Card disc = CardUtil.getRandom(list.toArray());
|
||||||
|
discarded.add(disc);
|
||||||
|
doDiscard(disc, sa);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return discarded;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1077,16 +1077,16 @@ public class AbilityFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CardList list = new CardList();
|
CardList list = new CardList();
|
||||||
if (calcX[0].startsWith("Sacrificed"))
|
if (calcX[0].startsWith("Sacrificed")) {
|
||||||
list = findRootAbility(ability).getPaidList("Sacrificed");
|
list = findRootAbility(ability).getPaidList("Sacrificed");
|
||||||
|
} else if (calcX[0].startsWith("Discarded")){
|
||||||
else if (calcX[0].startsWith("Discarded"))
|
|
||||||
list = findRootAbility(ability).getPaidList("Discarded");
|
list = findRootAbility(ability).getPaidList("Discarded");
|
||||||
|
} else if (calcX[0].startsWith("Exiled")) {
|
||||||
else if (calcX[0].startsWith("Exiled")) {
|
|
||||||
list = findRootAbility(ability).getPaidList("Exiled");
|
list = findRootAbility(ability).getPaidList("Exiled");
|
||||||
} else if (calcX[0].startsWith("Tapped")) {
|
} else if (calcX[0].startsWith("Tapped")) {
|
||||||
list = findRootAbility(ability).getPaidList("Tapped");
|
list = findRootAbility(ability).getPaidList("Tapped");
|
||||||
|
} else if (calcX[0].startsWith("Revealed")) {
|
||||||
|
list = findRootAbility(ability).getPaidList("Revealed");
|
||||||
} else if (calcX[0].startsWith("Targeted")) {
|
} else if (calcX[0].startsWith("Targeted")) {
|
||||||
Target t = ability.getTarget();
|
Target t = ability.getTarget();
|
||||||
if (null != t) {
|
if (null != t) {
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ public class Cost {
|
|||||||
private final static String exileFromGraveStr = "ExileFromGrave<";
|
private final static String exileFromGraveStr = "ExileFromGrave<";
|
||||||
private final static String exileFromTopStr = "ExileFromTop<";
|
private final static String exileFromTopStr = "ExileFromTop<";
|
||||||
private final static String returnStr = "Return<";
|
private final static String returnStr = "Return<";
|
||||||
|
private final static String revealStr = "Reveal<";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Constructor for Cost.</p>
|
* <p>Constructor for Cost.</p>
|
||||||
@@ -124,7 +125,7 @@ public class Cost {
|
|||||||
String[] splitStr = abCostParse(parse, subStr, 4);
|
String[] splitStr = abCostParse(parse, subStr, 4);
|
||||||
parse = abUpdateParse(parse, subStr);
|
parse = abUpdateParse(parse, subStr);
|
||||||
|
|
||||||
String type = splitStr.length > 2 ? splitStr[2] : null;
|
String type = splitStr.length > 2 ? splitStr[2] : "CARDNAME";
|
||||||
String description = splitStr.length > 3 ? splitStr[3] : null;
|
String description = splitStr.length > 3 ? splitStr[3] : null;
|
||||||
|
|
||||||
costParts.add(new CostRemoveCounter(splitStr[0], Counters.valueOf(splitStr[1]), type, description));
|
costParts.add(new CostRemoveCounter(splitStr[0], Counters.valueOf(splitStr[1]), type, description));
|
||||||
@@ -212,6 +213,14 @@ public class Cost {
|
|||||||
String description = splitStr.length > 2 ? splitStr[2] : null;
|
String description = splitStr.length > 2 ? splitStr[2] : null;
|
||||||
costParts.add(new CostReturn(splitStr[0], splitStr[1], description));
|
costParts.add(new CostReturn(splitStr[0], splitStr[1], description));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (parse.contains(revealStr)) {
|
||||||
|
String[] splitStr = abCostParse(parse, revealStr, 3);
|
||||||
|
parse = abUpdateParse(parse, revealStr);
|
||||||
|
|
||||||
|
String description = splitStr.length > 2 ? splitStr[2] : null;
|
||||||
|
costParts.add(new CostReveal(splitStr[0], splitStr[1], description));
|
||||||
|
}
|
||||||
|
|
||||||
// These won't show up with multiples
|
// These won't show up with multiples
|
||||||
if (parse.contains("Untap")) {
|
if (parse.contains("Untap")) {
|
||||||
|
|||||||
@@ -17,9 +17,7 @@ public class CostDiscard extends CostPartWithList {
|
|||||||
// Discard<Num/Type{/TypeDescription}>
|
// Discard<Num/Type{/TypeDescription}>
|
||||||
|
|
||||||
public CostDiscard(String amount, String type, String description){
|
public CostDiscard(String amount, String type, String description){
|
||||||
this.amount = amount;
|
super(amount, type, description);
|
||||||
this.type = type;
|
|
||||||
this.typeDescription = description;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -101,18 +99,27 @@ public class CostDiscard extends CostPartWithList {
|
|||||||
CardList handList = AllZoneUtil.getPlayerHand(activator);
|
CardList handList = AllZoneUtil.getPlayerHand(activator);
|
||||||
String discType = getType();
|
String discType = getType();
|
||||||
String amount = getAmount();
|
String amount = getAmount();
|
||||||
|
resetList();
|
||||||
|
|
||||||
if (getThis()) {
|
if (getThis()) {
|
||||||
|
if (!handList.contains(source)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
activator.discard(source, ability);
|
activator.discard(source, ability);
|
||||||
payment.setPaidManaPart(this, true);
|
payment.setPaidManaPart(this, true);
|
||||||
|
addToList(source);
|
||||||
} else if (discType.equals("Hand")) {
|
} else if (discType.equals("Hand")) {
|
||||||
|
list = handList;
|
||||||
activator.discardHand(ability);
|
activator.discardHand(ability);
|
||||||
payment.setPaidManaPart(this, true);
|
payment.setPaidManaPart(this, true);
|
||||||
} else if (discType.equals("LastDrawn")) {
|
} else if (discType.equals("LastDrawn")) {
|
||||||
if (handList.contains(activator.getLastDrawnCard())) {
|
Card lastDrawn = activator.getLastDrawnCard();
|
||||||
activator.discard(activator.getLastDrawnCard(), ability);
|
addToList(lastDrawn);
|
||||||
payment.setPaidManaPart(this, true);
|
if (!handList.contains(lastDrawn)) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
activator.discard(lastDrawn, ability);
|
||||||
|
payment.setPaidManaPart(this, true);
|
||||||
} else {
|
} else {
|
||||||
Integer c = convertAmount();
|
Integer c = convertAmount();
|
||||||
|
|
||||||
@@ -128,7 +135,7 @@ public class CostDiscard extends CostPartWithList {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
activator.discardRandom(c, ability);
|
list = activator.discardRandom(c, ability);
|
||||||
payment.setPaidManaPart(this, true);
|
payment.setPaidManaPart(this, true);
|
||||||
} else {
|
} else {
|
||||||
String validType[] = discType.split(";");
|
String validType[] = discType.split(";");
|
||||||
@@ -149,6 +156,7 @@ public class CostDiscard extends CostPartWithList {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
addListToHash(ability, "Discarded");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,14 +169,14 @@ public class CostDiscard extends CostPartWithList {
|
|||||||
if (type.equals("LastDrawn")){
|
if (type.equals("LastDrawn")){
|
||||||
if (!hand.contains(activator.getLastDrawnCard()))
|
if (!hand.contains(activator.getLastDrawnCard()))
|
||||||
return false;
|
return false;
|
||||||
list.add(activator.getLastDrawnCard());
|
addToList(activator.getLastDrawnCard());
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (getThis()){
|
else if (getThis()){
|
||||||
if (!hand.contains(source))
|
if (!hand.contains(source))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
list.add(source);
|
addToList(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (type.equals("Hand")){
|
else if (type.equals("Hand")){
|
||||||
@@ -208,7 +216,7 @@ public class CostDiscard extends CostPartWithList {
|
|||||||
*
|
*
|
||||||
* @return a {@link forge.gui.input.Input} object.
|
* @return a {@link forge.gui.input.Input} object.
|
||||||
*/
|
*/
|
||||||
public static Input input_discardCost(final String discType, final CardList handList, SpellAbility sa, final Cost_Payment payment, final CostPart part, final int nNeeded) {
|
public static Input input_discardCost(final String discType, final CardList handList, SpellAbility sa, final Cost_Payment payment, final CostDiscard part, final int nNeeded) {
|
||||||
final SpellAbility sp = sa;
|
final SpellAbility sp = sa;
|
||||||
Input target = new Input() {
|
Input target = new Input() {
|
||||||
private static final long serialVersionUID = -329993322080934435L;
|
private static final long serialVersionUID = -329993322080934435L;
|
||||||
@@ -217,20 +225,15 @@ public class CostDiscard extends CostPartWithList {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showMessage() {
|
public void showMessage() {
|
||||||
boolean any = discType.equals("Any") ? true : false;
|
|
||||||
if (AllZone.getHumanHand().size() == 0) stop();
|
if (AllZone.getHumanHand().size() == 0) stop();
|
||||||
StringBuilder type = new StringBuilder("");
|
StringBuilder type = new StringBuilder("");
|
||||||
if (any || !discType.equals("Card")) {
|
if (!discType.equals("Card")) {
|
||||||
type.append(" ").append(discType);
|
type.append(" ").append(discType);
|
||||||
}
|
}
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("Select ");
|
sb.append("Select a");
|
||||||
if (any) {
|
sb.append(part.getDescriptiveType());
|
||||||
sb.append("any ");
|
sb.append(" to discard.");
|
||||||
} else {
|
|
||||||
sb.append("a ").append(type.toString()).append(" ");
|
|
||||||
}
|
|
||||||
sb.append("card to discard.");
|
|
||||||
if (nNeeded > 1) {
|
if (nNeeded > 1) {
|
||||||
sb.append(" You have ");
|
sb.append(" You have ");
|
||||||
sb.append(nNeeded - nDiscard);
|
sb.append(nNeeded - nDiscard);
|
||||||
@@ -250,6 +253,7 @@ public class CostDiscard extends CostPartWithList {
|
|||||||
if (zone.is(Constant.Zone.Hand) && handList.contains(card)) {
|
if (zone.is(Constant.Zone.Hand) && handList.contains(card)) {
|
||||||
// send in CardList for Typing
|
// send in CardList for Typing
|
||||||
card.getController().discard(card, sp);
|
card.getController().discard(card, sp);
|
||||||
|
part.addToList(card);
|
||||||
handList.remove(card);
|
handList.remove(card);
|
||||||
nDiscard++;
|
nDiscard++;
|
||||||
|
|
||||||
@@ -270,6 +274,7 @@ public class CostDiscard extends CostPartWithList {
|
|||||||
|
|
||||||
public void done() {
|
public void done() {
|
||||||
stop();
|
stop();
|
||||||
|
part.addListToHash(sp, "Discarded");
|
||||||
payment.paidCost(part);
|
payment.paidCost(part);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,9 +32,7 @@ public class CostExile extends CostPartWithList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CostExile(String amount, String type, String description, String from){
|
public CostExile(String amount, String type, String description, String from){
|
||||||
this.amount = amount;
|
super(amount, type, description);
|
||||||
this.type = type;
|
|
||||||
this.typeDescription = description;
|
|
||||||
if (from != null)
|
if (from != null)
|
||||||
this.from = from;
|
this.from = from;
|
||||||
}
|
}
|
||||||
@@ -173,9 +171,10 @@ public class CostExile extends CostPartWithList {
|
|||||||
Iterator<Card> itr = list.iterator();
|
Iterator<Card> itr = list.iterator();
|
||||||
while(itr.hasNext()){
|
while(itr.hasNext()){
|
||||||
Card c = (Card)itr.next();
|
Card c = (Card)itr.next();
|
||||||
payment.getAbility().addCostToHashList(c, "Exiled");
|
part.addToList(c);
|
||||||
AllZone.getGameAction().exile(c);
|
AllZone.getGameAction().exile(c);
|
||||||
}
|
}
|
||||||
|
part.addListToHash(sa, "Exiled");
|
||||||
payment.paidCost(part);
|
payment.paidCost(part);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@@ -202,7 +201,7 @@ public class CostExile extends CostPartWithList {
|
|||||||
if (o != null) {
|
if (o != null) {
|
||||||
Card c = (Card) o;
|
Card c = (Card) o;
|
||||||
typeList.remove(c);
|
typeList.remove(c);
|
||||||
payment.getAbility().addCostToHashList(c, "Exiled");
|
part.addToList(c);
|
||||||
AllZone.getGameAction().exile(c);
|
AllZone.getGameAction().exile(c);
|
||||||
if (i == nNeeded - 1) done();
|
if (i == nNeeded - 1) done();
|
||||||
}
|
}
|
||||||
@@ -220,6 +219,7 @@ public class CostExile extends CostPartWithList {
|
|||||||
|
|
||||||
public void done() {
|
public void done() {
|
||||||
stop();
|
stop();
|
||||||
|
part.addListToHash(sa, "Exiled");
|
||||||
payment.paidCost(part);
|
payment.paidCost(part);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,7 +275,7 @@ public class CostExile extends CostPartWithList {
|
|||||||
public void selectCard(Card card, PlayerZone zone) {
|
public void selectCard(Card card, PlayerZone zone) {
|
||||||
if (typeList.contains(card)) {
|
if (typeList.contains(card)) {
|
||||||
nExiles++;
|
nExiles++;
|
||||||
payment.getAbility().addCostToHashList(card, "Exiled");
|
part.addToList(card);
|
||||||
AllZone.getGameAction().exile(card);
|
AllZone.getGameAction().exile(card);
|
||||||
typeList.remove(card);
|
typeList.remove(card);
|
||||||
//in case nothing else to exile
|
//in case nothing else to exile
|
||||||
@@ -290,6 +290,7 @@ public class CostExile extends CostPartWithList {
|
|||||||
|
|
||||||
public void done() {
|
public void done() {
|
||||||
stop();
|
stop();
|
||||||
|
part.addListToHash(sa, "Exiled");
|
||||||
payment.paidCost(part);
|
payment.paidCost(part);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,7 +329,9 @@ public class CostExile extends CostPartWithList {
|
|||||||
if (choice.equals(0)) {
|
if (choice.equals(0)) {
|
||||||
payment.getAbility().addCostToHashList(card, "Exiled");
|
payment.getAbility().addCostToHashList(card, "Exiled");
|
||||||
AllZone.getGameAction().exile(card);
|
AllZone.getGameAction().exile(card);
|
||||||
|
part.addToList(card);
|
||||||
stop();
|
stop();
|
||||||
|
part.addListToHash(sa, "Exiled");
|
||||||
payment.paidCost(part);
|
payment.paidCost(part);
|
||||||
} else {
|
} else {
|
||||||
stop();
|
stop();
|
||||||
|
|||||||
@@ -13,6 +13,14 @@ public abstract class CostPart {
|
|||||||
protected String type = "Card";
|
protected String type = "Card";
|
||||||
protected String typeDescription = null;
|
protected String typeDescription = null;
|
||||||
|
|
||||||
|
public CostPart(){}
|
||||||
|
|
||||||
|
public CostPart(String amount, String type, String description){
|
||||||
|
this.amount = amount;
|
||||||
|
this.type = type;
|
||||||
|
this.typeDescription = description;
|
||||||
|
}
|
||||||
|
|
||||||
public String getAmount() {
|
public String getAmount() {
|
||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package forge.card.cost;
|
|||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardList;
|
import forge.CardList;
|
||||||
|
import forge.card.spellability.SpellAbility;
|
||||||
|
|
||||||
public abstract class CostPartWithList extends CostPart {
|
public abstract class CostPartWithList extends CostPart {
|
||||||
protected CardList list = null;
|
protected CardList list = null;
|
||||||
@@ -9,4 +10,17 @@ public abstract class CostPartWithList extends CostPart {
|
|||||||
public void setList(CardList setList) { list = setList; }
|
public void setList(CardList setList) { list = setList; }
|
||||||
public void resetList() { list = new CardList(); }
|
public void resetList() { list = new CardList(); }
|
||||||
public void addToList(Card c) { list.add(c); }
|
public void addToList(Card c) { list.add(c); }
|
||||||
|
|
||||||
|
public void addListToHash(SpellAbility sa, String hash){
|
||||||
|
for(Card card : list){
|
||||||
|
sa.addCostToHashList(card, hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CostPartWithList(){}
|
||||||
|
|
||||||
|
public CostPartWithList(String amount, String type, String description){
|
||||||
|
super(amount, type, description);
|
||||||
|
resetList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,16 +21,10 @@ public class CostRemoveCounter extends CostPart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CostRemoveCounter(String amount, Counters counter, String type, String description){
|
public CostRemoveCounter(String amount, Counters counter, String type, String description){
|
||||||
|
super(amount, type, description);
|
||||||
isReusable = true;
|
isReusable = true;
|
||||||
this.amount = amount;
|
|
||||||
this.counter = counter;
|
|
||||||
|
|
||||||
if (type != null)
|
|
||||||
this.type = type;
|
|
||||||
else
|
|
||||||
this.type = "CARDNAME";
|
|
||||||
|
|
||||||
this.typeDescription = description;
|
this.counter = counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -18,9 +18,7 @@ public class CostReturn extends CostPartWithList {
|
|||||||
// Return<Num/Type{/TypeDescription}>
|
// Return<Num/Type{/TypeDescription}>
|
||||||
|
|
||||||
public CostReturn(String amount, String type, String description){
|
public CostReturn(String amount, String type, String description){
|
||||||
this.amount = amount;
|
super(amount, type, description);
|
||||||
this.type = type;
|
|
||||||
this.typeDescription = description;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -127,7 +125,7 @@ public class CostReturn extends CostPartWithList {
|
|||||||
* @param part TODO
|
* @param part TODO
|
||||||
* @return a {@link forge.gui.input.Input} object.
|
* @return a {@link forge.gui.input.Input} object.
|
||||||
*/
|
*/
|
||||||
public static Input returnType(final SpellAbility sa, final String type, final Cost_Payment payment, final CostPart part, final int nNeeded) {
|
public static Input returnType(final SpellAbility sa, final String type, final Cost_Payment payment, final CostReturn part, final int nNeeded) {
|
||||||
Input target = new Input() {
|
Input target = new Input() {
|
||||||
private static final long serialVersionUID = 2685832214519141903L;
|
private static final long serialVersionUID = 2685832214519141903L;
|
||||||
private CardList typeList;
|
private CardList typeList;
|
||||||
@@ -158,6 +156,7 @@ public class CostReturn extends CostPartWithList {
|
|||||||
public void selectCard(Card card, PlayerZone zone) {
|
public void selectCard(Card card, PlayerZone zone) {
|
||||||
if (typeList.contains(card)) {
|
if (typeList.contains(card)) {
|
||||||
nReturns++;
|
nReturns++;
|
||||||
|
part.addToList(card);
|
||||||
AllZone.getGameAction().moveToHand(card);
|
AllZone.getGameAction().moveToHand(card);
|
||||||
typeList.remove(card);
|
typeList.remove(card);
|
||||||
//in case nothing else to return
|
//in case nothing else to return
|
||||||
@@ -177,6 +176,7 @@ public class CostReturn extends CostPartWithList {
|
|||||||
|
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
stop();
|
stop();
|
||||||
|
part.addListToHash(sa, "Returned");
|
||||||
payment.cancelCost();
|
payment.cancelCost();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -192,7 +192,7 @@ public class CostReturn extends CostPartWithList {
|
|||||||
* @param part TODO
|
* @param part TODO
|
||||||
* @return a {@link forge.gui.input.Input} object.
|
* @return a {@link forge.gui.input.Input} object.
|
||||||
*/
|
*/
|
||||||
public static Input returnThis(final SpellAbility sa, final Cost_Payment payment, final CostPart part) {
|
public static Input returnThis(final SpellAbility sa, final Cost_Payment payment, final CostReturn part) {
|
||||||
Input target = new Input() {
|
Input target = new Input() {
|
||||||
private static final long serialVersionUID = 2685832214519141903L;
|
private static final long serialVersionUID = 2685832214519141903L;
|
||||||
|
|
||||||
@@ -208,8 +208,10 @@ public class CostReturn extends CostPartWithList {
|
|||||||
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
|
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
|
||||||
null, possibleValues, possibleValues[0]);
|
null, possibleValues, possibleValues[0]);
|
||||||
if (choice.equals(0)) {
|
if (choice.equals(0)) {
|
||||||
|
part.addToList(card);
|
||||||
AllZone.getGameAction().moveToHand(card);
|
AllZone.getGameAction().moveToHand(card);
|
||||||
stop();
|
stop();
|
||||||
|
part.addListToHash(sa, "Returned");
|
||||||
payment.paidCost(part);
|
payment.paidCost(part);
|
||||||
} else {
|
} else {
|
||||||
stop();
|
stop();
|
||||||
|
|||||||
215
src/main/java/forge/card/cost/CostReveal.java
Normal file
215
src/main/java/forge/card/cost/CostReveal.java
Normal file
@@ -0,0 +1,215 @@
|
|||||||
|
package forge.card.cost;
|
||||||
|
|
||||||
|
import forge.AllZone;
|
||||||
|
import forge.AllZoneUtil;
|
||||||
|
import forge.ButtonUtil;
|
||||||
|
import forge.Card;
|
||||||
|
import forge.CardList;
|
||||||
|
import forge.Constant;
|
||||||
|
import forge.Player;
|
||||||
|
import forge.card.abilityFactory.AbilityFactory;
|
||||||
|
import forge.card.spellability.SpellAbility;
|
||||||
|
import forge.gui.GuiUtils;
|
||||||
|
import forge.gui.input.Input;
|
||||||
|
import forge.PlayerZone;
|
||||||
|
|
||||||
|
public class CostReveal extends CostPartWithList {
|
||||||
|
//Reveal<Num/Type/TypeDescription>
|
||||||
|
|
||||||
|
public CostReveal(String amount, String type, String description){
|
||||||
|
super(amount, type, description);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canPay(SpellAbility ability, Card source, Player activator, Cost cost) {
|
||||||
|
CardList handList = AllZoneUtil.getPlayerHand(activator);
|
||||||
|
String type = getType();
|
||||||
|
Integer amount = convertAmount();
|
||||||
|
|
||||||
|
if (getThis()) {
|
||||||
|
if (!AllZone.getZone(source).is(Constant.Zone.Hand))
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
handList = handList.getValidCards(type.split(";"), activator, source);
|
||||||
|
if (amount != null && amount > handList.size()) {
|
||||||
|
// not enough cards in hand to pay
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean decideAIPayment(SpellAbility ability, Card source, Cost_Payment payment) {
|
||||||
|
String type = getType();
|
||||||
|
Player activator = ability.getActivatingPlayer();
|
||||||
|
CardList hand = AllZoneUtil.getPlayerHand(activator);
|
||||||
|
resetList();
|
||||||
|
|
||||||
|
if (getThis()){
|
||||||
|
if (!hand.contains(source))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
list.add(source);
|
||||||
|
} else{
|
||||||
|
hand = hand.getValidCards(type.split(";"), activator, source);
|
||||||
|
Integer c = convertAmount();
|
||||||
|
if (c == null){
|
||||||
|
String sVar = source.getSVar(amount);
|
||||||
|
if (sVar.equals("XChoice")){
|
||||||
|
c = hand.size();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
c = AbilityFactory.calculateAmount(source, amount, ability);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
list = AllZone.getGameAction().AI_discardNumType(c, type.split(";"), ability);
|
||||||
|
}
|
||||||
|
return list != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void payAI(SpellAbility ability, Card source, Cost_Payment payment) {
|
||||||
|
GuiUtils.getChoiceOptional("Revealed cards:", list.toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean payHuman(SpellAbility ability, Card source, Cost_Payment payment) {
|
||||||
|
Player activator = ability.getActivatingPlayer();
|
||||||
|
String amount = getAmount();
|
||||||
|
resetList();
|
||||||
|
|
||||||
|
if (getThis()) {
|
||||||
|
addToList(source);
|
||||||
|
payment.setPaidManaPart(this, true);
|
||||||
|
} else {
|
||||||
|
Integer c = convertAmount();
|
||||||
|
|
||||||
|
CardList handList = AllZoneUtil.getPlayerHand(activator);
|
||||||
|
handList = handList.getValidCards(type.split(";"), activator, ability.getSourceCard());
|
||||||
|
|
||||||
|
if (c == null){
|
||||||
|
String sVar = source.getSVar(amount);
|
||||||
|
if (sVar.equals("XChoice")){
|
||||||
|
c = CostUtil.chooseXValue(source, handList.size());
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
c = AbilityFactory.calculateAmount(source, amount, ability);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CostUtil.setInput(input_revealCost(type, handList, payment, this, ability, c));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
addListToHash(ability, "Revealed");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("Reveal ");
|
||||||
|
|
||||||
|
Integer i = convertAmount();
|
||||||
|
|
||||||
|
if (getThis()) {
|
||||||
|
sb.append(type);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
StringBuilder desc = new StringBuilder();
|
||||||
|
|
||||||
|
if (type.equals("Card"))
|
||||||
|
desc.append("Card");
|
||||||
|
else
|
||||||
|
desc.append(typeDescription == null ? type : typeDescription).append(" card");
|
||||||
|
|
||||||
|
sb.append(Cost.convertAmountTypeToWords(i, amount, desc.toString()));
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refund(Card source) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inputs
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>input_discardCost.</p>
|
||||||
|
* @param discType a {@link java.lang.String} object.
|
||||||
|
* @param handList a {@link forge.CardList} object.
|
||||||
|
* @param payment a {@link forge.card.cost.Cost_Payment} object.
|
||||||
|
* @param part TODO
|
||||||
|
* @param sa TODO
|
||||||
|
* @param nNeeded a int.
|
||||||
|
* @return a {@link forge.gui.input.Input} object.
|
||||||
|
*/
|
||||||
|
public static Input input_revealCost(final String discType, final CardList handList, final Cost_Payment payment, final CostReveal part, final SpellAbility sa, final int nNeeded) {
|
||||||
|
Input target = new Input() {
|
||||||
|
private static final long serialVersionUID = -329993322080934435L;
|
||||||
|
|
||||||
|
int nReveal = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showMessage() {
|
||||||
|
if (AllZone.getHumanHand().size() < nNeeded) stop();
|
||||||
|
StringBuilder type = new StringBuilder("");
|
||||||
|
if (!discType.equals("Card")) {
|
||||||
|
type.append(" ").append(discType);
|
||||||
|
}
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("Select a");
|
||||||
|
sb.append(part.getDescriptiveType());
|
||||||
|
sb.append(" to reveal.");
|
||||||
|
if (nNeeded > 1) {
|
||||||
|
sb.append(" You have ");
|
||||||
|
sb.append(nNeeded - nReveal);
|
||||||
|
sb.append(" remaining.");
|
||||||
|
}
|
||||||
|
AllZone.getDisplay().showMessage(sb.toString());
|
||||||
|
ButtonUtil.enableOnlyCancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void selectButtonCancel() {
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void selectCard(Card card, PlayerZone zone) {
|
||||||
|
if (zone.is(Constant.Zone.Hand) && handList.contains(card)) {
|
||||||
|
// send in CardList for Typing
|
||||||
|
handList.remove(card);
|
||||||
|
part.addToList(card);
|
||||||
|
nReveal++;
|
||||||
|
|
||||||
|
//in case no more cards in hand
|
||||||
|
if (nReveal == nNeeded)
|
||||||
|
done();
|
||||||
|
else if (AllZone.getHumanHand().size() == 0) // this really shouldn't happen
|
||||||
|
cancel();
|
||||||
|
else
|
||||||
|
showMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancel() {
|
||||||
|
stop();
|
||||||
|
payment.cancelCost();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void done() {
|
||||||
|
stop();
|
||||||
|
// "Inform" AI of the revealed cards
|
||||||
|
part.addListToHash(sa, "Revealed");
|
||||||
|
payment.paidCost(part);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}//input_discard()
|
||||||
|
|
||||||
|
}
|
||||||
@@ -17,9 +17,7 @@ import forge.gui.input.Input;
|
|||||||
public class CostSacrifice extends CostPartWithList {
|
public class CostSacrifice extends CostPartWithList {
|
||||||
|
|
||||||
public CostSacrifice(String amount, String type, String description){
|
public CostSacrifice(String amount, String type, String description){
|
||||||
this.amount = amount;
|
super(amount, type, description);
|
||||||
this.type = type;
|
|
||||||
this.typeDescription = description;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -85,7 +83,9 @@ public class CostSacrifice extends CostPartWithList {
|
|||||||
CostUtil.setInput(CostSacrifice.sacrificeThis(ability, payment, this));
|
CostUtil.setInput(CostSacrifice.sacrificeThis(ability, payment, this));
|
||||||
}
|
}
|
||||||
else if (amount.equals("All")){
|
else if (amount.equals("All")){
|
||||||
|
this.list = list;
|
||||||
CostSacrifice.sacrificeAll(ability, payment, this, list);
|
CostSacrifice.sacrificeAll(ability, payment, this, list);
|
||||||
|
addListToHash(ability, "Sacrificed");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@@ -193,7 +193,7 @@ public class CostSacrifice extends CostPartWithList {
|
|||||||
public void selectCard(Card card, PlayerZone zone) {
|
public void selectCard(Card card, PlayerZone zone) {
|
||||||
if (typeList.contains(card)) {
|
if (typeList.contains(card)) {
|
||||||
nSacrifices++;
|
nSacrifices++;
|
||||||
payment.getAbility().addCostToHashList(card, "Sacrificed");
|
part.addToList(card);
|
||||||
AllZone.getGameAction().sacrifice(card);
|
AllZone.getGameAction().sacrifice(card);
|
||||||
typeList.remove(card);
|
typeList.remove(card);
|
||||||
//in case nothing else to sacrifice
|
//in case nothing else to sacrifice
|
||||||
@@ -208,11 +208,13 @@ public class CostSacrifice extends CostPartWithList {
|
|||||||
|
|
||||||
public void done() {
|
public void done() {
|
||||||
stop();
|
stop();
|
||||||
|
part.addListToHash(sa, "Sacrificed");
|
||||||
payment.paidCost(part);
|
payment.paidCost(part);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
payment.cancelCost();
|
payment.cancelCost();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -228,7 +230,7 @@ public class CostSacrifice extends CostPartWithList {
|
|||||||
* @param part TODO
|
* @param part TODO
|
||||||
* @return a {@link forge.gui.input.Input} object.
|
* @return a {@link forge.gui.input.Input} object.
|
||||||
*/
|
*/
|
||||||
public static Input sacrificeThis(final SpellAbility sa, final Cost_Payment payment, final CostPart part) {
|
public static Input sacrificeThis(final SpellAbility sa, final Cost_Payment payment, final CostSacrifice part) {
|
||||||
Input target = new Input() {
|
Input target = new Input() {
|
||||||
private static final long serialVersionUID = 2685832214519141903L;
|
private static final long serialVersionUID = 2685832214519141903L;
|
||||||
|
|
||||||
@@ -244,7 +246,8 @@ public class CostSacrifice extends CostPartWithList {
|
|||||||
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
|
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
|
||||||
null, possibleValues, possibleValues[0]);
|
null, possibleValues, possibleValues[0]);
|
||||||
if (choice.equals(0)) {
|
if (choice.equals(0)) {
|
||||||
payment.getAbility().addCostToHashList(card, "Sacrificed");
|
part.addToList(card);
|
||||||
|
part.addListToHash(sa, "Sacrificed");
|
||||||
AllZone.getGameAction().sacrifice(card);
|
AllZone.getGameAction().sacrifice(card);
|
||||||
stop();
|
stop();
|
||||||
payment.paidCost(part);
|
payment.paidCost(part);
|
||||||
|
|||||||
@@ -15,11 +15,8 @@ import forge.gui.input.Input;
|
|||||||
|
|
||||||
public class CostTapType extends CostPartWithList {
|
public class CostTapType extends CostPartWithList {
|
||||||
public CostTapType(String amount, String type, String description){
|
public CostTapType(String amount, String type, String description){
|
||||||
list = new CardList();
|
super(amount, type, description);
|
||||||
isReusable = true;
|
isReusable = true;
|
||||||
this.amount = amount;
|
|
||||||
this.type = type;
|
|
||||||
this.typeDescription = description;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription(){
|
public String getDescription(){
|
||||||
@@ -128,7 +125,7 @@ public class CostTapType extends CostPartWithList {
|
|||||||
* @param payment a {@link forge.card.cost.Cost_Payment} object.
|
* @param payment a {@link forge.card.cost.Cost_Payment} object.
|
||||||
* @return a {@link forge.gui.input.Input} object.
|
* @return a {@link forge.gui.input.Input} object.
|
||||||
*/
|
*/
|
||||||
public static Input input_tapXCost(final CostTapType tapType, final CardList cardList, SpellAbility sa, final Cost_Payment payment, final int nCards) {
|
public static Input input_tapXCost(final CostTapType tapType, final CardList cardList, final SpellAbility sa, final Cost_Payment payment, final int nCards) {
|
||||||
Input target = new Input() {
|
Input target = new Input() {
|
||||||
|
|
||||||
private static final long serialVersionUID = 6438988130447851042L;
|
private static final long serialVersionUID = 6438988130447851042L;
|
||||||
@@ -155,7 +152,7 @@ public class CostTapType extends CostPartWithList {
|
|||||||
card.tap();
|
card.tap();
|
||||||
tapType.addToList(card);
|
tapType.addToList(card);
|
||||||
cardList.remove(card);
|
cardList.remove(card);
|
||||||
payment.getAbility().addCostToHashList(card, "Tapped");
|
|
||||||
nTapped++;
|
nTapped++;
|
||||||
|
|
||||||
if (nTapped == nCards)
|
if (nTapped == nCards)
|
||||||
@@ -175,6 +172,7 @@ public class CostTapType extends CostPartWithList {
|
|||||||
public void done() {
|
public void done() {
|
||||||
stop();
|
stop();
|
||||||
payment.paidCost(tapType);
|
payment.paidCost(tapType);
|
||||||
|
tapType.addListToHash(sa, "Tapped");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user