Update check

This commit is contained in:
Anthony Calosa
2022-04-01 07:08:36 +08:00
parent 9e2d469263
commit 218caf8b33
5 changed files with 27 additions and 6 deletions

View File

@@ -254,7 +254,8 @@ public class PlayEffect extends SpellAbilityEffect {
if (sa.hasParam("ShowCardToActivator")) { if (sa.hasParam("ShowCardToActivator")) {
game.getAction().revealTo(tgtCard, activator); game.getAction().revealTo(tgtCard, activator);
} }
if (singleOption && sa.getTargetCard() == null)
sa.setTargetCard(tgtCard);// show card to play rathern than showing the source card
if (singleOption && !controller.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantPlayCard", CardTranslation.getTranslatedName(tgtCard.getName())))) { if (singleOption && !controller.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantPlayCard", CardTranslation.getTranslatedName(tgtCard.getName())))) {
if (wasFaceDown) { if (wasFaceDown) {
tgtCard.turnFaceDownNoUpdate(); tgtCard.turnFaceDownNoUpdate();
@@ -304,6 +305,7 @@ public class PlayEffect extends SpellAbilityEffect {
if (!sa.hasParam("CastFaceDown")) { if (!sa.hasParam("CastFaceDown")) {
// only one mode can be used // only one mode can be used
tgtCard.setMayPlay(sa.getActivatingPlayer(), true, null, false, true, null);
tgtSA = sa.getActivatingPlayer().getController().getAbilityToPlay(tgtCard, sas); tgtSA = sa.getActivatingPlayer().getController().getAbilityToPlay(tgtCard, sas);
} else { } else {
// For Illusionary Mask effect // For Illusionary Mask effect

View File

@@ -3337,6 +3337,13 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
} }
return result; return result;
} }
public final List<Player> getMayPlayPlayers() {
List<Player> result = Lists.newArrayList();
for (CardPlayOption o : mayPlay.values()) {
result.add(o.getPlayer());
}
return result;
}
public final void setMayPlay(final Player player, final boolean withoutManaCost, final Cost altManaCost, final boolean withFlash, final boolean grantZonePermissions, final StaticAbility sta) { public final void setMayPlay(final Player player, final boolean withoutManaCost, final Cost altManaCost, final boolean withFlash, final boolean grantZonePermissions, final StaticAbility sta) {
this.mayPlay.put(sta, new CardPlayOption(player, sta, withoutManaCost, altManaCost, withFlash, grantZonePermissions)); this.mayPlay.put(sta, new CardPlayOption(player, sta, withoutManaCost, altManaCost, withFlash, grantZonePermissions));
} }

View File

@@ -477,7 +477,10 @@ public class CardView extends GameEntityView {
void updateNamedCard2(Card c) { void updateNamedCard2(Card c) {
set(TrackableProperty.NamedCard2, c.getNamedCard2()); set(TrackableProperty.NamedCard2, c.getNamedCard2());
} }
public boolean getMayPlayPlayers(PlayerView pv) {
TrackableCollection<PlayerView> col = get(TrackableProperty.MayPlayPlayers);
return col != null && col.contains(pv);
}
public boolean mayPlayerLook(PlayerView pv) { public boolean mayPlayerLook(PlayerView pv) {
TrackableCollection<PlayerView> col = get(TrackableProperty.PlayerMayLook); TrackableCollection<PlayerView> col = get(TrackableProperty.PlayerMayLook);
return col != null && col.contains(pv); return col != null && col.contains(pv);
@@ -877,6 +880,11 @@ public class CardView extends GameEntityView {
updateZoneText(c); updateZoneText(c);
updateDamage(c); updateDamage(c);
if (c.getMayPlayPlayers().isEmpty())
set(TrackableProperty.MayPlayPlayers, null);
else
set(TrackableProperty.MayPlayPlayers, PlayerView.getCollection(c.getMayPlayPlayers()));
if (c.getIntensity(false) > 0) { if (c.getIntensity(false) > 0) {
updateIntensity(c); updateIntensity(c);
} }

View File

@@ -73,6 +73,7 @@ public enum TrackableProperty {
NamedCard(TrackableTypes.StringType), NamedCard(TrackableTypes.StringType),
NamedCard2(TrackableTypes.StringType), NamedCard2(TrackableTypes.StringType),
PlayerMayLook(TrackableTypes.PlayerViewCollectionType, FreezeMode.IgnoresFreeze), PlayerMayLook(TrackableTypes.PlayerViewCollectionType, FreezeMode.IgnoresFreeze),
MayPlayPlayers(TrackableTypes.PlayerViewCollectionType, FreezeMode.IgnoresFreeze),
EntityAttachedTo(TrackableTypes.GameEntityViewType), EntityAttachedTo(TrackableTypes.GameEntityViewType),
EncodedCards(TrackableTypes.CardViewCollectionType), EncodedCards(TrackableTypes.CardViewCollectionType),
UntilLeavesBattlefield(TrackableTypes.CardViewCollectionType), UntilLeavesBattlefield(TrackableTypes.CardViewCollectionType),

View File

@@ -271,7 +271,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
public SpellAbility getAbilityToPlay(final Card hostCard, final List<SpellAbility> abilities, public SpellAbility getAbilityToPlay(final Card hostCard, final List<SpellAbility> abilities,
final ITriggerEvent triggerEvent) { final ITriggerEvent triggerEvent) {
// make sure another human player can't choose opponents cards just because he might see them // make sure another human player can't choose opponents cards just because he might see them
if ((triggerEvent != null||GuiBase.getInterface().isLibgdxPort()) && !hostCard.isInPlay() && !hostCard.getOwner().equals(player) && if (triggerEvent != null && !hostCard.isInPlay() && !hostCard.getOwner().equals(player) &&
!hostCard.getController().equals(player) && !hostCard.getController().equals(player) &&
// If player cast Shaman's Trance, they can play spells from any Graveyard (if other effects allow it to be cast) // If player cast Shaman's Trance, they can play spells from any Graveyard (if other effects allow it to be cast)
(!player.hasKeyword("Shaman's Trance") || !hostCard.isInZone(ZoneType.Graveyard))) { (!player.hasKeyword("Shaman's Trance") || !hostCard.isInZone(ZoneType.Graveyard))) {
@@ -283,9 +283,12 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
} }
} }
if (noPermission) { if (noPermission) {
//simulate default activate action to show zoom so we don't give a hint that the selected card is a spell return null;
if (GuiBase.getInterface().isLibgdxPort()) }
getGui().showZoom(hostCard.getView()); }
if (!hostCard.getController().equals(player)) {
if (!hostCard.getMayPlayPlayers().contains(player)) {
getGui().showZoom(hostCard.getView());
return null; return null;
} }
} }