Merge branch 'NewMaster' into 'master'

[Mobile] update PlayEffect

See merge request core-developers/forge!6467
This commit is contained in:
Anthony Calosa
2022-04-01 11:27:44 +00:00
7 changed files with 22 additions and 7 deletions

View File

@@ -254,7 +254,8 @@ public class PlayEffect extends SpellAbilityEffect {
if (sa.hasParam("ShowCardToActivator")) {
game.getAction().revealTo(tgtCard, activator);
}
if (singleOption && sa.getTargetCard() == null)
sa.setPlayEffectCard(tgtCard);// show card to play rather than showing the source card
if (singleOption && !controller.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantPlayCard", CardTranslation.getTranslatedName(tgtCard.getName())))) {
if (wasFaceDown) {
tgtCard.turnFaceDownNoUpdate();

View File

@@ -477,7 +477,6 @@ public class CardView extends GameEntityView {
void updateNamedCard2(Card c) {
set(TrackableProperty.NamedCard2, c.getNamedCard2());
}
public boolean mayPlayerLook(PlayerView pv) {
TrackableCollection<PlayerView> col = get(TrackableProperty.PlayerMayLook);
// TODO don't use contains as it only queries the backing HashSet which is problematic for netplay because of unsynchronized player ids

View File

@@ -113,6 +113,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
private ManaCost multiKickerManaCost;
private Player activatingPlayer;
private Player targetingPlayer;
private Card playEffectCard;
private Pair<Long, Player> controlledByPlayer;
private ManaCostBeingPaid manaCostBeingPaid;
private boolean spentPhyrexian = false;
@@ -1788,6 +1789,12 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
targetChosen.add(card);
setStackDescription(getHostCard().getName() + " - targeting " + card);
}
public void setPlayEffectCard(final Card card) {
playEffectCard = card;
}
public Card getPlayEffectCard() {
return playEffectCard;
}
/**
* <p>

View File

@@ -27,6 +27,7 @@ import forge.game.player.Player;
import forge.game.player.PlayerView;
import forge.game.spellability.SpellAbility;
import forge.game.spellability.SpellAbilityView;
import forge.gui.GuiBase;
import forge.localinstance.properties.ForgePreferences;
import forge.model.FModel;
import forge.player.PlayerControllerHuman;
@@ -123,10 +124,16 @@ public abstract class InputBase implements java.io.Serializable, Input {
controller.getGui().showPromptMessage(getOwner(), message);
}
protected final void showMessage(final String message, final SpellAbilityView sav) {
controller.getGui().showCardPromptMessage(getOwner(), message, sav.getHostCard());
if (GuiBase.isNetworkplay()) //todo additional check to pass this
controller.getGui().showPromptMessage(getOwner(), message);
else
controller.getGui().showCardPromptMessage(getOwner(), message, sav.getHostCard());
}
protected final void showMessage(final String message, final CardView card) {
controller.getGui().showCardPromptMessage(getOwner(), message, card);
if (GuiBase.isNetworkplay()) //todo additional check to pass this
controller.getGui().showPromptMessage(getOwner(), message);
else
controller.getGui().showCardPromptMessage(getOwner(), message, card);
}
protected String getTurnPhasePriorityMessage(final Game game) {

View File

@@ -78,8 +78,8 @@ public class InputConfirm extends InputSyncronizedBase {
return controller.getGui().confirm(null, message, defaultIsYes, options);
if (sa.getTargets() != null && sa.getTargets().isTargetingAnyCard() && sa.getTargets().size() == 1)
return controller.getGui().confirm((sa.getTargetCard()==null)?null:CardView.get(sa.getTargetCard()), message, defaultIsYes, options);
if (ApiType.Play.equals(sa.getApi()) && sa.getHostCard() != null && sa.getHostCard().getImprintedCards().size() == 1)
return controller.getGui().confirm((sa.getHostCard().getImprintedCards().get(0)==null)?null:CardView.get(sa.getHostCard().getImprintedCards().get(0)), message, defaultIsYes, options);
if (ApiType.Play.equals(sa.getApi()) && sa.getPlayEffectCard() != null)
return controller.getGui().confirm(CardView.get(sa.getPlayEffectCard()), message, defaultIsYes, options);
return controller.getGui().confirm(CardView.get(sa.getHostCard()), message, defaultIsYes, options);
} else {
InputConfirm inp;

View File

@@ -76,7 +76,7 @@ public enum ProtocolMethod {
refreshField (Mode.SERVER, Void.TYPE),
// TODO case "setPlayerAvatar":
openZones (Mode.SERVER, PlayerZoneUpdates.class, PlayerView.class, Collection/*ZoneType*/.class, Map/*PlayerView,Object*/.class),
restoreOldZones (Mode.SERVER, Void.TYPE, PlayerView.class, Iterable/*PlayerZoneUpdates*/.class),
restoreOldZones (Mode.SERVER, Void.TYPE, PlayerView.class, PlayerZoneUpdates.class),
isUiSetToSkipPhase (Mode.SERVER, Boolean.TYPE, PlayerView.class, PhaseType.class),
setRememberedActions(Mode.SERVER, Void.TYPE),
nextRememberedAction(Mode.SERVER, Void.TYPE),

View File

@@ -286,6 +286,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
return null;
}
}
//FIXME - on mobile gui it allows the card to cast from opponent hands issue #2127, investigate where the bug occurs before this method is called
spellViewCache = SpellAbilityView.getMap(abilities);
final SpellAbilityView resultView = getGui().getAbilityToPlay(CardView.get(hostCard),
Lists.newArrayList(spellViewCache.keySet()), triggerEvent);