Dig: reveal optional remembers if you've chosen to reveal the card.

uses playerController to decide whether to reveal or not
This commit is contained in:
Maxmtg
2013-05-20 12:04:00 +00:00
parent 82e0969cd4
commit 96694641b9
6 changed files with 46 additions and 43 deletions

View File

@@ -1,5 +1,6 @@
package forge.card.ability.effects;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -37,31 +38,33 @@ public class ChooseTypeEffect extends SpellAbilityEffect {
validTypes.addAll(Arrays.asList(sa.getParam("ValidTypes").split(",")));
}
if (type.equals("Card")) {
if (validTypes.isEmpty()) validTypes.addAll(Constant.CardTypes.CARD_TYPES);
} else if (type.equals("Creature")) {
if (validTypes.isEmpty()) validTypes.addAll(CardType.getCreatureTypes());
} else if (type.equals("Basic Land")) {
if (validTypes.isEmpty()) validTypes.addAll(CardType.getBasicTypes());
} else if (type.equals("Land")) {
if (validTypes.isEmpty()) validTypes.addAll(CardType.getLandTypes());
} // end if-else if
for (final String s : invalidTypes) {
validTypes.remove(s);
}
final Target tgt = sa.getTarget();
final List<Player> tgtPlayers = getTargetPlayers(sa);
for (final Player p : tgtPlayers) {
if ((tgt == null) || p.canBeTargetedBy(sa)) {
if (type.equals("Card")) {
if (validTypes.isEmpty()) validTypes.addAll(Constant.CardTypes.CARD_TYPES);
} else if (type.equals("Creature")) {
if (validTypes.isEmpty()) validTypes.addAll(CardType.getCreatureTypes());
} else if (type.equals("Basic Land")) {
if (validTypes.isEmpty()) validTypes.addAll(CardType.getBasicTypes());
} else if (type.equals("Land")) {
if (validTypes.isEmpty()) validTypes.addAll(CardType.getLandTypes());
} // end if-else if
if( !validTypes.isEmpty()) {
for (final String s : invalidTypes) {
validTypes.remove(s);
}
if( !validTypes.isEmpty()) {
for (final Player p : tgtPlayers) {
if ((tgt == null) || p.canBeTargetedBy(sa)) {
String choice = p.getController().chooseSomeType(type, sa.getParam("AILogic"), validTypes, invalidTypes);
card.setChosenType(choice);
}
}
}
} else
throw new InvalidParameterException(sa.getSourceCard() + "'s ability resulted in no types to choose from");
}
}

View File

@@ -19,7 +19,7 @@ import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.GuiChoose;
import forge.gui.GuiDialog;
import forge.util.Lang;
import forge.util.MyRandom;
public class DigEffect extends SpellAbilityEffect {
@@ -116,21 +116,18 @@ public class DigEffect extends SpellAbilityEffect {
final Card dummy = new Card();
dummy.setName("[No valid cards]");
boolean hasRevealed = true;
if (sa.hasParam("Reveal")) {
GuiChoose.one("Revealing cards from library", top);
// Singletons.getModel().getGameAction().revealToCopmuter(top.toArray());
// - for when it exists
} else if (sa.hasParam("RevealOptional")) {
String question = "Reveal: ";
for (final Card c : top) {
question += c + " ";
}
if (p.isHuman() && GuiDialog.confirm(host, question)) {
GuiChoose.one(host + "Revealing cards from library", top);
// Singletons.getModel().getGameAction().revealToCopmuter(top.toArray());
} else if (p.isComputer() && (top.get(0).isInstant() || top.get(0).isSorcery())) {
GuiChoose.one(host + "Revealing cards from library", top);
}
String question = "Reveal: " + Lang.joinHomogenous(top) +"?";
hasRevealed = p.getController().confirmAction(sa, null, question);
if ( hasRevealed )
p.getGame().getAction().reveal(top, p);
} else if (sa.hasParam("RevealValid")) {
final String revealValid = sa.getParam("RevealValid");
final List<Card> toReveal = CardLists.getValidCards(top, revealValid, host.getController(), host);
@@ -149,7 +146,7 @@ public class DigEffect extends SpellAbilityEffect {
choser.getController().reveal("Looking at cards from library", top, library.getZoneType(), library.getPlayer());
}
if ((sa.hasParam("RememberRevealed")) && !sa.hasParam("RevealValid")) {
if ((sa.hasParam("RememberRevealed")) && !sa.hasParam("RevealValid") && hasRevealed) {
for (final Card one : top) {
host.addRemembered(one);
}
@@ -317,14 +314,15 @@ public class DigEffect extends SpellAbilityEffect {
// now, move the rest to destZone2
if (destZone2.equals(ZoneType.Library)) {
if (choser.isHuman()) {
String prompt = "Put the rest on top of the library in any order";
if (libraryPosition2 == -1) {
prompt = "Put the rest on the bottom of the library in any order";
}
// put them in any order
while (rest.size() > 0) {
Card chosen;
if (!skipReorder && rest.size() > 1) {
String prompt = "Put the rest on top of the library in any order";
if (libraryPosition2 == -1) {
prompt = "Put the rest on the bottom of the library in any order";
}
chosen = GuiChoose.one(prompt, rest);
} else {
chosen = rest.get(0);

View File

@@ -18,7 +18,6 @@
package forge.card.cost;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import forge.Card;
import forge.CardUtil;
@@ -99,7 +98,7 @@ public abstract class CostPartWithList extends CostPart {
}
// always returns true, made this to inline with return
public final boolean executePayment(SpellAbility ability, Collection<Card> targetCards) {
public final boolean executePayment(SpellAbility ability, List<Card> targetCards) {
if(canPayListAtOnce()) { // This is used by reveal. Without it when opponent would reveal hand, you'll get N message boxes.
this.list.addAll(targetCards);
doListPayment(ability, targetCards);
@@ -113,7 +112,7 @@ public abstract class CostPartWithList extends CostPart {
protected abstract void doPayment(SpellAbility ability, Card targetCard);
// Overload these two only together, set to true and perform payment on list
protected boolean canPayListAtOnce() { return false; }
protected void doListPayment(SpellAbility ability, Collection<Card> targetCards) { };
protected void doListPayment(SpellAbility ability, List<Card> targetCards) { };
/**
* TODO: Write javadoc for this method.

View File

@@ -18,7 +18,6 @@
package forge.card.cost;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.google.common.collect.Lists;
@@ -222,7 +221,7 @@ public class CostReveal extends CostPartWithList {
@Override protected boolean canPayListAtOnce() { return true; }
@Override
protected void doListPayment(SpellAbility ability, Collection<Card> targetCards) {
protected void doListPayment(SpellAbility ability, List<Card> targetCards) {
ability.getActivatingPlayer().getGame().getAction().reveal(targetCards, ability.getActivatingPlayer());
}

View File

@@ -18,7 +18,6 @@
package forge.game;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
@@ -1404,10 +1403,11 @@ public class GameAction {
* @param targetCard
* @param activatingPlayer
*/
public void reveal(Collection<Card> cards, Player cardOwner) {
public void reveal(List<Card> cards, Player cardOwner) {
ZoneType zt = cards.isEmpty() ? ZoneType.Hand : game.getZoneOf(cards.get(0)).getZoneType();
for(Player p : game.getPlayers()) {
if ( cardOwner == p) continue;
p.getController().reveal(cardOwner + " reveals card", cards, ZoneType.Hand, cardOwner);
if (cardOwner == p /*&& zt.isKnown()*/) continue;
p.getController().reveal(cardOwner + " reveals card from " + zt, cards, zt, cardOwner);
}
}

View File

@@ -720,6 +720,10 @@ public class AiController {
case Encode:
return true;
case Dig:
Card topc = player.getZone(ZoneType.Library).get(0);
return topc.isInstant() || topc.isSorcery();
default:
}
String exMsg = String.format("AI confirmAction does not know what to decide about %s API with %s mode.", api, mode);