mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
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:
@@ -1,5 +1,6 @@
|
|||||||
package forge.card.ability.effects;
|
package forge.card.ability.effects;
|
||||||
|
|
||||||
|
import java.security.InvalidParameterException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -37,31 +38,33 @@ public class ChooseTypeEffect extends SpellAbilityEffect {
|
|||||||
validTypes.addAll(Arrays.asList(sa.getParam("ValidTypes").split(",")));
|
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 Target tgt = sa.getTarget();
|
||||||
final List<Player> tgtPlayers = getTargetPlayers(sa);
|
final List<Player> tgtPlayers = getTargetPlayers(sa);
|
||||||
|
|
||||||
for (final Player p : tgtPlayers) {
|
if( !validTypes.isEmpty()) {
|
||||||
if ((tgt == null) || p.canBeTargetedBy(sa)) {
|
for (final Player p : tgtPlayers) {
|
||||||
if (type.equals("Card")) {
|
if ((tgt == null) || p.canBeTargetedBy(sa)) {
|
||||||
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);
|
|
||||||
}
|
|
||||||
String choice = p.getController().chooseSomeType(type, sa.getParam("AILogic"), validTypes, invalidTypes);
|
String choice = p.getController().chooseSomeType(type, sa.getParam("AILogic"), validTypes, invalidTypes);
|
||||||
card.setChosenType(choice);
|
card.setChosenType(choice);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
|
throw new InvalidParameterException(sa.getSourceCard() + "'s ability resulted in no types to choose from");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import forge.game.player.Player;
|
|||||||
import forge.game.zone.PlayerZone;
|
import forge.game.zone.PlayerZone;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.gui.GuiChoose;
|
import forge.gui.GuiChoose;
|
||||||
import forge.gui.GuiDialog;
|
import forge.util.Lang;
|
||||||
import forge.util.MyRandom;
|
import forge.util.MyRandom;
|
||||||
|
|
||||||
public class DigEffect extends SpellAbilityEffect {
|
public class DigEffect extends SpellAbilityEffect {
|
||||||
@@ -116,21 +116,18 @@ public class DigEffect extends SpellAbilityEffect {
|
|||||||
final Card dummy = new Card();
|
final Card dummy = new Card();
|
||||||
dummy.setName("[No valid cards]");
|
dummy.setName("[No valid cards]");
|
||||||
|
|
||||||
|
boolean hasRevealed = true;
|
||||||
if (sa.hasParam("Reveal")) {
|
if (sa.hasParam("Reveal")) {
|
||||||
GuiChoose.one("Revealing cards from library", top);
|
GuiChoose.one("Revealing cards from library", top);
|
||||||
// Singletons.getModel().getGameAction().revealToCopmuter(top.toArray());
|
// Singletons.getModel().getGameAction().revealToCopmuter(top.toArray());
|
||||||
// - for when it exists
|
// - for when it exists
|
||||||
} else if (sa.hasParam("RevealOptional")) {
|
} else if (sa.hasParam("RevealOptional")) {
|
||||||
String question = "Reveal: ";
|
String question = "Reveal: " + Lang.joinHomogenous(top) +"?";
|
||||||
for (final Card c : top) {
|
|
||||||
question += c + " ";
|
hasRevealed = p.getController().confirmAction(sa, null, question);
|
||||||
}
|
if ( hasRevealed )
|
||||||
if (p.isHuman() && GuiDialog.confirm(host, question)) {
|
p.getGame().getAction().reveal(top, p);
|
||||||
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);
|
|
||||||
}
|
|
||||||
} else if (sa.hasParam("RevealValid")) {
|
} else if (sa.hasParam("RevealValid")) {
|
||||||
final String revealValid = sa.getParam("RevealValid");
|
final String revealValid = sa.getParam("RevealValid");
|
||||||
final List<Card> toReveal = CardLists.getValidCards(top, revealValid, host.getController(), host);
|
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());
|
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) {
|
for (final Card one : top) {
|
||||||
host.addRemembered(one);
|
host.addRemembered(one);
|
||||||
}
|
}
|
||||||
@@ -317,14 +314,15 @@ public class DigEffect extends SpellAbilityEffect {
|
|||||||
// now, move the rest to destZone2
|
// now, move the rest to destZone2
|
||||||
if (destZone2.equals(ZoneType.Library)) {
|
if (destZone2.equals(ZoneType.Library)) {
|
||||||
if (choser.isHuman()) {
|
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
|
// put them in any order
|
||||||
while (rest.size() > 0) {
|
while (rest.size() > 0) {
|
||||||
Card chosen;
|
Card chosen;
|
||||||
if (!skipReorder && rest.size() > 1) {
|
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);
|
chosen = GuiChoose.one(prompt, rest);
|
||||||
} else {
|
} else {
|
||||||
chosen = rest.get(0);
|
chosen = rest.get(0);
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
package forge.card.cost;
|
package forge.card.cost;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardUtil;
|
import forge.CardUtil;
|
||||||
@@ -99,7 +98,7 @@ public abstract class CostPartWithList extends CostPart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// always returns true, made this to inline with return
|
// 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.
|
if(canPayListAtOnce()) { // This is used by reveal. Without it when opponent would reveal hand, you'll get N message boxes.
|
||||||
this.list.addAll(targetCards);
|
this.list.addAll(targetCards);
|
||||||
doListPayment(ability, targetCards);
|
doListPayment(ability, targetCards);
|
||||||
@@ -113,7 +112,7 @@ public abstract class CostPartWithList extends CostPart {
|
|||||||
protected abstract void doPayment(SpellAbility ability, Card targetCard);
|
protected abstract void doPayment(SpellAbility ability, Card targetCard);
|
||||||
// Overload these two only together, set to true and perform payment on list
|
// Overload these two only together, set to true and perform payment on list
|
||||||
protected boolean canPayListAtOnce() { return false; }
|
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.
|
* TODO: Write javadoc for this method.
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
package forge.card.cost;
|
package forge.card.cost;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
@@ -222,7 +221,7 @@ public class CostReveal extends CostPartWithList {
|
|||||||
|
|
||||||
@Override protected boolean canPayListAtOnce() { return true; }
|
@Override protected boolean canPayListAtOnce() { return true; }
|
||||||
@Override
|
@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());
|
ability.getActivatingPlayer().getGame().getAction().reveal(targetCards, ability.getActivatingPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
package forge.game;
|
package forge.game;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -1404,10 +1403,11 @@ public class GameAction {
|
|||||||
* @param targetCard
|
* @param targetCard
|
||||||
* @param activatingPlayer
|
* @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()) {
|
for(Player p : game.getPlayers()) {
|
||||||
if ( cardOwner == p) continue;
|
if (cardOwner == p /*&& zt.isKnown()*/) continue;
|
||||||
p.getController().reveal(cardOwner + " reveals card", cards, ZoneType.Hand, cardOwner);
|
p.getController().reveal(cardOwner + " reveals card from " + zt, cards, zt, cardOwner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -720,6 +720,10 @@ public class AiController {
|
|||||||
case Encode:
|
case Encode:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case Dig:
|
||||||
|
Card topc = player.getZone(ZoneType.Library).get(0);
|
||||||
|
return topc.isInstant() || topc.isSorcery();
|
||||||
|
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
String exMsg = String.format("AI confirmAction does not know what to decide about %s API with %s mode.", api, mode);
|
String exMsg = String.format("AI confirmAction does not know what to decide about %s API with %s mode.", api, mode);
|
||||||
|
|||||||
Reference in New Issue
Block a user