mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Update check to viewable cards
This commit is contained in:
@@ -3337,6 +3337,13 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
||||
}
|
||||
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) {
|
||||
this.mayPlay.put(sta, new CardPlayOption(player, sta, withoutManaCost, altManaCost, withFlash, grantZonePermissions));
|
||||
}
|
||||
|
||||
@@ -477,6 +477,10 @@ public class CardView extends GameEntityView {
|
||||
void updateNamedCard2(Card c) {
|
||||
set(TrackableProperty.NamedCard2, c.getNamedCard2());
|
||||
}
|
||||
public boolean getMayPlayPlayers(PlayerView pv) {
|
||||
TrackableCollection<PlayerView> col = get(TrackableProperty.MayPlayPlayers);
|
||||
return col != null && col.indexOf(pv) != -1;
|
||||
}
|
||||
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
|
||||
@@ -877,6 +881,11 @@ public class CardView extends GameEntityView {
|
||||
updateZoneText(c);
|
||||
updateDamage(c);
|
||||
|
||||
if (c.getMayPlayPlayers().isEmpty())
|
||||
set(TrackableProperty.MayPlayPlayers, null);
|
||||
else
|
||||
set(TrackableProperty.MayPlayPlayers, PlayerView.getCollection(c.getMayPlayPlayers()));
|
||||
|
||||
if (c.getIntensity(false) > 0) {
|
||||
updateIntensity(c);
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ public enum TrackableProperty {
|
||||
NamedCard(TrackableTypes.StringType),
|
||||
NamedCard2(TrackableTypes.StringType),
|
||||
PlayerMayLook(TrackableTypes.PlayerViewCollectionType, FreezeMode.IgnoresFreeze),
|
||||
MayPlayPlayers(TrackableTypes.PlayerViewCollectionType, FreezeMode.IgnoresFreeze),
|
||||
EntityAttachedTo(TrackableTypes.GameEntityViewType),
|
||||
EncodedCards(TrackableTypes.CardViewCollectionType),
|
||||
UntilLeavesBattlefield(TrackableTypes.CardViewCollectionType),
|
||||
|
||||
@@ -15,6 +15,7 @@ import forge.card.CardRenderer.CardStackPosition;
|
||||
import forge.card.CardZoom;
|
||||
import forge.card.CardZoom.ActivateHandler;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.FThreads;
|
||||
import forge.gui.GuiBase;
|
||||
import forge.screens.match.MatchController;
|
||||
@@ -365,8 +366,13 @@ public abstract class VCardDisplayArea extends VDisplayArea implements ActivateH
|
||||
}
|
||||
|
||||
public boolean selectCard(boolean selectEntireStack) {
|
||||
if (!getCard().getController().equals(MatchController.instance.getCurrentPlayer()) && !getCard().mayPlayerLook(MatchController.instance.getCurrentPlayer())) {
|
||||
if (!getCard().getController().equals(MatchController.instance.getCurrentPlayer()) && !ZoneType.Battlefield.equals(getCard().getZone())) {
|
||||
if (getCard().mayPlayerLook(MatchController.instance.getCurrentPlayer())) { // can see the card, check if can play...
|
||||
if (!getCard().getMayPlayPlayers(MatchController.instance.getCurrentPlayer()))
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (MatchController.instance.getGameController().selectCard(getCard(), getOtherCardsToSelect(selectEntireStack), null)) {
|
||||
Gdx.graphics.requestRendering();
|
||||
|
||||
Reference in New Issue
Block a user