mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38: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;
|
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));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -477,6 +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.indexOf(pv) != -1;
|
||||||
|
}
|
||||||
public boolean mayPlayerLook(PlayerView pv) {
|
public boolean mayPlayerLook(PlayerView pv) {
|
||||||
TrackableCollection<PlayerView> col = get(TrackableProperty.PlayerMayLook);
|
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
|
// 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);
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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),
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import forge.card.CardRenderer.CardStackPosition;
|
|||||||
import forge.card.CardZoom;
|
import forge.card.CardZoom;
|
||||||
import forge.card.CardZoom.ActivateHandler;
|
import forge.card.CardZoom.ActivateHandler;
|
||||||
import forge.game.card.CardView;
|
import forge.game.card.CardView;
|
||||||
|
import forge.game.zone.ZoneType;
|
||||||
import forge.gui.FThreads;
|
import forge.gui.FThreads;
|
||||||
import forge.gui.GuiBase;
|
import forge.gui.GuiBase;
|
||||||
import forge.screens.match.MatchController;
|
import forge.screens.match.MatchController;
|
||||||
@@ -365,8 +366,13 @@ public abstract class VCardDisplayArea extends VDisplayArea implements ActivateH
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean selectCard(boolean selectEntireStack) {
|
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())) {
|
||||||
return false;
|
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)) {
|
if (MatchController.instance.getGameController().selectCard(getCard(), getOtherCardsToSelect(selectEntireStack), null)) {
|
||||||
Gdx.graphics.requestRendering();
|
Gdx.graphics.requestRendering();
|
||||||
|
|||||||
Reference in New Issue
Block a user