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.cost.Cost;
|
||||||
import forge.game.keyword.Keyword;
|
import forge.game.keyword.Keyword;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
|
import forge.game.player.PlayerActionConfirmMode;
|
||||||
import forge.game.spellability.Spell;
|
import forge.game.spellability.Spell;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.game.spellability.SpellAbilityPredicates;
|
import forge.game.spellability.SpellAbilityPredicates;
|
||||||
@@ -158,6 +159,11 @@ public class PlayAi extends SpellAbilityAi {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean confirmAction(Player ai, SpellAbility sa, PlayerActionConfirmMode mode, String message) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see forge.card.ability.SpellAbilityAi#chooseSingleCard(forge.game.player.Player, forge.card.spellability.SpellAbility, java.util.List, boolean)
|
* @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);
|
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).
|
// 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
|
// 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.
|
// 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
|
// If Cast Targets will be checked on the Stack
|
||||||
for (final Card attachment : attachments) {
|
for (final Card attachment : attachments) {
|
||||||
String message = Localizer.getInstance().getMessage("lblDoYouWantAttachSourceToTarget", CardTranslation.getTranslatedName(attachment.getName()), attachToName);
|
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;
|
continue;
|
||||||
handleAttachment(attachment, attachTo, sa);
|
handleAttachment(attachment, attachTo, sa);
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,6 @@ public class AttachEffect extends SpellAbilityEffect {
|
|||||||
* the o
|
* the o
|
||||||
*/
|
*/
|
||||||
public static void handleAttachment(final Card card, final Object o, final SpellAbility sa) {
|
public static void handleAttachment(final Card card, final Object o, final SpellAbility sa) {
|
||||||
|
|
||||||
if (card == null) { return; }
|
if (card == null) { return; }
|
||||||
|
|
||||||
if (o instanceof Card) {
|
if (o instanceof Card) {
|
||||||
|
|||||||
@@ -183,18 +183,11 @@ public class PlayEffect extends SpellAbilityEffect {
|
|||||||
activator.addController(controlledByTimeStamp, controlledByPlayer);
|
activator.addController(controlledByTimeStamp, controlledByPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean singleOption = tgtCards.size() == 1 && amount == 1 && optional;
|
||||||
|
|
||||||
while (!tgtCards.isEmpty() && amount > 0) {
|
while (!tgtCards.isEmpty() && amount > 0) {
|
||||||
activator.getController().tempShowCards(showCards);
|
activator.getController().tempShowCards(showCards);
|
||||||
Card tgtCard = null;
|
Card tgtCard = controller.getController().chooseSingleEntityForEffect(tgtCards, sa, Localizer.getInstance().getMessage("lblSelectCardToPlay"), !singleOption, 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
activator.getController().endTempShowCards();
|
activator.getController().endTempShowCards();
|
||||||
if (tgtCard == null) {
|
if (tgtCard == null) {
|
||||||
break;
|
break;
|
||||||
@@ -210,12 +203,16 @@ public class PlayEffect extends SpellAbilityEffect {
|
|||||||
game.getAction().revealTo(tgtCard, activator);
|
game.getAction().revealTo(tgtCard, activator);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sa.hasParam("AllowRepeats")) {
|
if (singleOption && !controller.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantPlayCard", CardTranslation.getTranslatedName(tgtCard.getName())))) {
|
||||||
tgtCards.remove(tgtCard);
|
if (wasFaceDown) {
|
||||||
|
tgtCard.turnFaceDownNoUpdate();
|
||||||
|
tgtCard.updateStateForView();
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wasFaceDown) {
|
if (!sa.hasParam("AllowRepeats")) {
|
||||||
tgtCard.updateStateForView();
|
tgtCards.remove(tgtCard);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Card original = tgtCard;
|
final Card original = tgtCard;
|
||||||
@@ -272,6 +269,10 @@ public class PlayEffect extends SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
// in case player canceled from choice dialog
|
// in case player canceled from choice dialog
|
||||||
if (tgtSA == null) {
|
if (tgtSA == null) {
|
||||||
|
if (wasFaceDown) {
|
||||||
|
tgtCard.turnFaceDownNoUpdate();
|
||||||
|
tgtCard.updateStateForView();
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,7 +330,7 @@ public class PlayEffect extends SpellAbilityEffect {
|
|||||||
source.addRemembered(tgtSA.getHostCard());
|
source.addRemembered(tgtSA.getHostCard());
|
||||||
}
|
}
|
||||||
|
|
||||||
//Forgot only of playing was successful
|
//Forgot only if playing was successful
|
||||||
if (sa.hasParam("ForgetRemembered")) {
|
if (sa.hasParam("ForgetRemembered")) {
|
||||||
source.clearRemembered();
|
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:DBPutCounter:DB$ PutCounter | Defined$ Remembered | CounterType$ P1P1 | CounterNum$ X | SubAbility$ DBCleanup
|
||||||
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
|
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
|
||||||
SVar:X:Count$xPaid
|
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
|
SVar:DBPlay:DB$ Play | Defined$ Remembered | WithoutManaCost$ True | Optional$ True | SubAbility$ DBCleanup
|
||||||
DeckHints:Type$Instant|Sorcery
|
DeckHints:Type$Instant|Sorcery
|
||||||
DeckHas:Ability$Token & Ability$Counters
|
DeckHas:Ability$Token & Ability$Counters
|
||||||
|
|||||||
@@ -601,8 +601,6 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
|||||||
tempShow(delayedReveal.getCards());
|
tempShow(delayedReveal.getCards());
|
||||||
}
|
}
|
||||||
|
|
||||||
GameEntityViewMap<T, GameEntityView> gameCacheChoose = GameEntityView.getMap(optionList);
|
|
||||||
|
|
||||||
if (useSelectCardsInput(optionList)) {
|
if (useSelectCardsInput(optionList)) {
|
||||||
final InputSelectEntitiesFromList<T> input = new InputSelectEntitiesFromList<>(this, isOptional ? 0 : 1, 1,
|
final InputSelectEntitiesFromList<T> input = new InputSelectEntitiesFromList<>(this, isOptional ? 0 : 1, 1,
|
||||||
optionList, sa);
|
optionList, sa);
|
||||||
@@ -613,6 +611,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
|||||||
return Iterables.getFirst(input.getSelected(), null);
|
return Iterables.getFirst(input.getSelected(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GameEntityViewMap<T, GameEntityView> gameCacheChoose = GameEntityView.getMap(optionList);
|
||||||
final GameEntityView result = getGui().chooseSingleEntityForEffect(title,
|
final GameEntityView result = getGui().chooseSingleEntityForEffect(title,
|
||||||
gameCacheChoose.getTrackableKeys(), delayedReveal, isOptional);
|
gameCacheChoose.getTrackableKeys(), delayedReveal, isOptional);
|
||||||
endTempShowCards();
|
endTempShowCards();
|
||||||
@@ -626,8 +625,6 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
|||||||
@Override
|
@Override
|
||||||
public <T extends GameEntity> List<T> chooseEntitiesForEffect(final FCollectionView<T> optionList, final int min, final int max,
|
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) {
|
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
|
// useful details for debugging problems with the mass select logic
|
||||||
Sentry.getContext().addExtra("Card", sa.getCardView().toString());
|
Sentry.getContext().addExtra("Card", sa.getCardView().toString());
|
||||||
Sentry.getContext().addExtra("SpellAbility", sa.toString());
|
Sentry.getContext().addExtra("SpellAbility", sa.toString());
|
||||||
@@ -655,6 +652,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
|||||||
endTempShowCards();
|
endTempShowCards();
|
||||||
return (List<T>) input.getSelected();
|
return (List<T>) input.getSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
GameEntityViewMap<T, GameEntityView> gameCacheEntity = GameEntityView.getMap(optionList);
|
GameEntityViewMap<T, GameEntityView> gameCacheEntity = GameEntityView.getMap(optionList);
|
||||||
final List<GameEntityView> views = getGui().chooseEntitiesForEffect(title, gameCacheEntity.getTrackableKeys(), min, max, delayedReveal);
|
final List<GameEntityView> views = getGui().chooseEntitiesForEffect(title, gameCacheEntity.getTrackableKeys(), min, max, delayedReveal);
|
||||||
endTempShowCards();
|
endTempShowCards();
|
||||||
@@ -700,8 +698,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
|||||||
Map<SpellAbilityView, SpellAbility> spellViewCache = SpellAbilityView.getMap(spells);
|
Map<SpellAbilityView, SpellAbility> spellViewCache = SpellAbilityView.getMap(spells);
|
||||||
Object choice = getGui().one(title, Lists.newArrayList(spellViewCache.keySet()));
|
Object choice = getGui().one(title, Lists.newArrayList(spellViewCache.keySet()));
|
||||||
|
|
||||||
// Human is supposed to read the message and understand from it what to
|
// Human is supposed to read the message and understand from it what to choose
|
||||||
// choose
|
|
||||||
return spellViewCache.get(choice);
|
return spellViewCache.get(choice);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -948,8 +945,8 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
|||||||
CardCollection toTop = null;
|
CardCollection toTop = null;
|
||||||
|
|
||||||
tempShowCards(topN);
|
tempShowCards(topN);
|
||||||
if ( FModel.getPreferences().getPrefBoolean(FPref.UI_SELECT_FROM_CARD_DISPLAYS) &&
|
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
|
(!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);
|
CardCollectionView cardList = player.getCardsIn(ZoneType.Library);
|
||||||
ImmutablePair<CardCollection, CardCollection> result =
|
ImmutablePair<CardCollection, CardCollection> result =
|
||||||
arrangeForMove(localizer.getMessage("lblMoveCardstoToporBbottomofLibrary"), cardList, topN, true, true);
|
arrangeForMove(localizer.getMessage("lblMoveCardstoToporBbottomofLibrary"), cardList, topN, true, true);
|
||||||
@@ -1566,8 +1563,6 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SpellAbility> chooseSaToActivateFromOpeningHand(final List<SpellAbility> usableFromOpeningHand) {
|
public List<SpellAbility> chooseSaToActivateFromOpeningHand(final List<SpellAbility> usableFromOpeningHand) {
|
||||||
|
|
||||||
|
|
||||||
final CardCollection srcCards = new CardCollection();
|
final CardCollection srcCards = new CardCollection();
|
||||||
for (final SpellAbility sa : usableFromOpeningHand) {
|
for (final SpellAbility sa : usableFromOpeningHand) {
|
||||||
srcCards.add(sa.getHostCard());
|
srcCards.add(sa.getHostCard());
|
||||||
@@ -2557,7 +2552,6 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerLife() {
|
public void setPlayerLife() {
|
||||||
|
|
||||||
GameEntityViewMap<Player, PlayerView> gameCachePlayer = GameEntityView.getMap(getGame().getPlayers());
|
GameEntityViewMap<Player, PlayerView> gameCachePlayer = GameEntityView.getMap(getGame().getPlayers());
|
||||||
|
|
||||||
final PlayerView pv = getGui().oneOrNone(localizer.getMessage("lblSetLifeforWhichPlayer"), gameCachePlayer.getTrackableKeys());
|
final PlayerView pv = getGui().oneOrNone(localizer.getMessage("lblSetLifeforWhichPlayer"), gameCachePlayer.getTrackableKeys());
|
||||||
|
|||||||
Reference in New Issue
Block a user