mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Refactor for facedown
This commit is contained in:
@@ -28,6 +28,7 @@ import forge.game.card.CardPredicates;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.keyword.Keyword;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerActionConfirmMode;
|
||||
import forge.game.spellability.Spell;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.SpellAbilityPredicates;
|
||||
@@ -158,6 +159,11 @@ public class PlayAi extends SpellAbilityAi {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean confirmAction(Player ai, SpellAbility sa, PlayerActionConfirmMode mode, String message) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.ability.SpellAbilityAi#chooseSingleCard(forge.game.player.Player, forge.card.spellability.SpellAbility, java.util.List, boolean)
|
||||
*/
|
||||
@@ -192,7 +198,7 @@ public class PlayAi extends SpellAbilityAi {
|
||||
|
||||
spell = (Spell) spell.copyWithDefinedCost(abCost);
|
||||
}
|
||||
if (AiPlayDecision.WillPlay == ((PlayerControllerAi)ai.getController()).getAi().canPlayFromEffectAI(spell, !isOptional, true)) {
|
||||
if (AiPlayDecision.WillPlay == ((PlayerControllerAi)ai.getController()).getAi().canPlayFromEffectAI(spell, !(isOptional || sa.hasParam("Optional")), true)) {
|
||||
// Before accepting, see if the spell has a valid number of targets (it should at this point).
|
||||
// Proceeding past this point if the spell is not correctly targeted will result
|
||||
// in "Failed to add to stack" error and the card disappearing from the game completely.
|
||||
|
||||
@@ -90,7 +90,7 @@ public class AttachEffect extends SpellAbilityEffect {
|
||||
// If Cast Targets will be checked on the Stack
|
||||
for (final Card attachment : attachments) {
|
||||
String message = Localizer.getInstance().getMessage("lblDoYouWantAttachSourceToTarget", CardTranslation.getTranslatedName(attachment.getName()), attachToName);
|
||||
if ( sa.hasParam("Optional") && !p.getController().confirmAction(sa, null, message) )
|
||||
if (sa.hasParam("Optional") && !p.getController().confirmAction(sa, null, message))
|
||||
continue;
|
||||
handleAttachment(attachment, attachTo, sa);
|
||||
}
|
||||
@@ -118,7 +118,6 @@ public class AttachEffect extends SpellAbilityEffect {
|
||||
* the o
|
||||
*/
|
||||
public static void handleAttachment(final Card card, final Object o, final SpellAbility sa) {
|
||||
|
||||
if (card == null) { return; }
|
||||
|
||||
if (o instanceof Card) {
|
||||
|
||||
@@ -183,18 +183,11 @@ public class PlayEffect extends SpellAbilityEffect {
|
||||
activator.addController(controlledByTimeStamp, controlledByPlayer);
|
||||
}
|
||||
|
||||
boolean singleOption = tgtCards.size() == 1 && amount == 1 && optional;
|
||||
|
||||
while (!tgtCards.isEmpty() && amount > 0) {
|
||||
activator.getController().tempShowCards(showCards);
|
||||
Card tgtCard = null;
|
||||
if (tgtCards.size() == 1 && amount == 1 && optional) {
|
||||
tgtCard = tgtCards.get(0);
|
||||
if (!controller.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantPlayCard", CardTranslation.getTranslatedName(tgtCard.getName())))) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
tgtCard = controller.getController().chooseSingleEntityForEffect(tgtCards, sa, Localizer.getInstance().getMessage("lblSelectCardToPlay"), optional, null);
|
||||
}
|
||||
|
||||
Card tgtCard = controller.getController().chooseSingleEntityForEffect(tgtCards, sa, Localizer.getInstance().getMessage("lblSelectCardToPlay"), !singleOption, null);
|
||||
activator.getController().endTempShowCards();
|
||||
if (tgtCard == null) {
|
||||
break;
|
||||
@@ -210,12 +203,16 @@ public class PlayEffect extends SpellAbilityEffect {
|
||||
game.getAction().revealTo(tgtCard, activator);
|
||||
}
|
||||
|
||||
if (!sa.hasParam("AllowRepeats")) {
|
||||
tgtCards.remove(tgtCard);
|
||||
if (singleOption && !controller.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantPlayCard", CardTranslation.getTranslatedName(tgtCard.getName())))) {
|
||||
if (wasFaceDown) {
|
||||
tgtCard.turnFaceDownNoUpdate();
|
||||
tgtCard.updateStateForView();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (wasFaceDown) {
|
||||
tgtCard.updateStateForView();
|
||||
if (!sa.hasParam("AllowRepeats")) {
|
||||
tgtCards.remove(tgtCard);
|
||||
}
|
||||
|
||||
final Card original = tgtCard;
|
||||
@@ -272,6 +269,10 @@ public class PlayEffect extends SpellAbilityEffect {
|
||||
}
|
||||
// in case player canceled from choice dialog
|
||||
if (tgtSA == null) {
|
||||
if (wasFaceDown) {
|
||||
tgtCard.turnFaceDownNoUpdate();
|
||||
tgtCard.updateStateForView();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -329,7 +330,7 @@ public class PlayEffect extends SpellAbilityEffect {
|
||||
source.addRemembered(tgtSA.getHostCard());
|
||||
}
|
||||
|
||||
//Forgot only of playing was successful
|
||||
//Forgot only if playing was successful
|
||||
if (sa.hasParam("ForgetRemembered")) {
|
||||
source.clearRemembered();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ A:AB$ Token | Cost$ SubCounter<X/LOYALTY> | Planeswalker$ True | TokenScript$ gu
|
||||
SVar:DBPutCounter:DB$ PutCounter | Defined$ Remembered | CounterType$ P1P1 | CounterNum$ X | SubAbility$ DBCleanup
|
||||
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
|
||||
SVar:X:Count$xPaid
|
||||
A:AB$ ChangeZone | Cost$ SubCounter<8/LOYALTY> | Planeswalker$ True | Ultimate$ True | Origin$ Library | Destination$ Exile | ChangeType$ Instant.SharesColorWith Card.Self,Sorcery.SharesColorWith Card.Self | ChangeNum$ 1 | SubAbility$ DBPlay | RememberChanged$ True | SpellDescription$ Search your library for an instant or sorcery card that shares a color with this planeswalker, exile that card, then shuffle. You may cast that card without paying its mana cost.
|
||||
A:AB$ ChangeZone | Cost$ SubCounter<8/LOYALTY> | Planeswalker$ True | Ultimate$ True | Origin$ Library | Destination$ Exile | ChangeType$ Instant.SharesColorWith,Sorcery.SharesColorWith | ChangeNum$ 1 | SubAbility$ DBPlay | RememberChanged$ True | SpellDescription$ Search your library for an instant or sorcery card that shares a color with this planeswalker, exile that card, then shuffle. You may cast that card without paying its mana cost.
|
||||
SVar:DBPlay:DB$ Play | Defined$ Remembered | WithoutManaCost$ True | Optional$ True | SubAbility$ DBCleanup
|
||||
DeckHints:Type$Instant|Sorcery
|
||||
DeckHas:Ability$Token & Ability$Counters
|
||||
|
||||
@@ -601,8 +601,6 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
||||
tempShow(delayedReveal.getCards());
|
||||
}
|
||||
|
||||
GameEntityViewMap<T, GameEntityView> gameCacheChoose = GameEntityView.getMap(optionList);
|
||||
|
||||
if (useSelectCardsInput(optionList)) {
|
||||
final InputSelectEntitiesFromList<T> input = new InputSelectEntitiesFromList<>(this, isOptional ? 0 : 1, 1,
|
||||
optionList, sa);
|
||||
@@ -613,6 +611,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
||||
return Iterables.getFirst(input.getSelected(), null);
|
||||
}
|
||||
|
||||
GameEntityViewMap<T, GameEntityView> gameCacheChoose = GameEntityView.getMap(optionList);
|
||||
final GameEntityView result = getGui().chooseSingleEntityForEffect(title,
|
||||
gameCacheChoose.getTrackableKeys(), delayedReveal, isOptional);
|
||||
endTempShowCards();
|
||||
@@ -626,8 +625,6 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
||||
@Override
|
||||
public <T extends GameEntity> List<T> chooseEntitiesForEffect(final FCollectionView<T> optionList, final int min, final int max,
|
||||
final DelayedReveal delayedReveal, final SpellAbility sa, final String title, final Player targetedPlayer, Map<String, Object> params) {
|
||||
|
||||
|
||||
// useful details for debugging problems with the mass select logic
|
||||
Sentry.getContext().addExtra("Card", sa.getCardView().toString());
|
||||
Sentry.getContext().addExtra("SpellAbility", sa.toString());
|
||||
@@ -655,6 +652,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
||||
endTempShowCards();
|
||||
return (List<T>) input.getSelected();
|
||||
}
|
||||
|
||||
GameEntityViewMap<T, GameEntityView> gameCacheEntity = GameEntityView.getMap(optionList);
|
||||
final List<GameEntityView> views = getGui().chooseEntitiesForEffect(title, gameCacheEntity.getTrackableKeys(), min, max, delayedReveal);
|
||||
endTempShowCards();
|
||||
@@ -700,8 +698,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
||||
Map<SpellAbilityView, SpellAbility> spellViewCache = SpellAbilityView.getMap(spells);
|
||||
Object choice = getGui().one(title, Lists.newArrayList(spellViewCache.keySet()));
|
||||
|
||||
// Human is supposed to read the message and understand from it what to
|
||||
// choose
|
||||
// Human is supposed to read the message and understand from it what to choose
|
||||
return spellViewCache.get(choice);
|
||||
}
|
||||
|
||||
@@ -948,8 +945,8 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
||||
CardCollection toTop = null;
|
||||
|
||||
tempShowCards(topN);
|
||||
if ( FModel.getPreferences().getPrefBoolean(FPref.UI_SELECT_FROM_CARD_DISPLAYS) &&
|
||||
(!GuiBase.getInterface().isLibgdxPort()) && (!GuiBase.isNetworkplay())) { //prevent crash for desktop vs mobile port it will crash the netplay since mobile doesnt have manipulatecardlist, send the alternate below
|
||||
if (FModel.getPreferences().getPrefBoolean(FPref.UI_SELECT_FROM_CARD_DISPLAYS) &&
|
||||
(!GuiBase.getInterface().isLibgdxPort()) && (!GuiBase.isNetworkplay())) { //prevent crash for desktop vs mobile port it will crash the netplay since mobile doesnt have manipulatecardlist, send the alternate below
|
||||
CardCollectionView cardList = player.getCardsIn(ZoneType.Library);
|
||||
ImmutablePair<CardCollection, CardCollection> result =
|
||||
arrangeForMove(localizer.getMessage("lblMoveCardstoToporBbottomofLibrary"), cardList, topN, true, true);
|
||||
@@ -1566,8 +1563,6 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
||||
|
||||
@Override
|
||||
public List<SpellAbility> chooseSaToActivateFromOpeningHand(final List<SpellAbility> usableFromOpeningHand) {
|
||||
|
||||
|
||||
final CardCollection srcCards = new CardCollection();
|
||||
for (final SpellAbility sa : usableFromOpeningHand) {
|
||||
srcCards.add(sa.getHostCard());
|
||||
@@ -2557,7 +2552,6 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
||||
*/
|
||||
@Override
|
||||
public void setPlayerLife() {
|
||||
|
||||
GameEntityViewMap<Player, PlayerView> gameCachePlayer = GameEntityView.getMap(getGame().getPlayers());
|
||||
|
||||
final PlayerView pv = getGui().oneOrNone(localizer.getMessage("lblSetLifeforWhichPlayer"), gameCachePlayer.getTrackableKeys());
|
||||
|
||||
Reference in New Issue
Block a user