Fix flashback zone to work more like other zones and not crash for desktop game

This commit is contained in:
drdev
2014-10-15 19:53:29 +00:00
parent e9c0e600ec
commit 8aa9fd050e
10 changed files with 32 additions and 71 deletions

1
.gitattributes vendored
View File

@@ -1253,7 +1253,6 @@ forge-gui-mobile/src/forge/screens/match/views/VCardDisplayArea.java -text
forge-gui-mobile/src/forge/screens/match/views/VDevMenu.java -text
forge-gui-mobile/src/forge/screens/match/views/VDisplayArea.java -text
forge-gui-mobile/src/forge/screens/match/views/VField.java -text
forge-gui-mobile/src/forge/screens/match/views/VFlashbackZone.java -text
forge-gui-mobile/src/forge/screens/match/views/VGameMenu.java -text
forge-gui-mobile/src/forge/screens/match/views/VLog.java -text
forge-gui-mobile/src/forge/screens/match/views/VManaPool.java -text

View File

@@ -335,6 +335,7 @@ public class CardView extends GameEntityView {
case Exile:
case Battlefield:
case Graveyard:
case Flashback:
case Stack:
//cards in these zones are visible to all
return true;

View File

@@ -1146,6 +1146,9 @@ public class Player extends GameEntity implements Comparable<Player> {
}
return cards;
}
else if (zoneType == ZoneType.Flashback) {
return getCardsActivableInExternalZones(true);
}
PlayerZone zone = getZone(zoneType);
return zone == null ? CardCollection.EMPTY : zone.getCards(filterOutPhasedOut);

View File

@@ -223,6 +223,8 @@ public class PlayerView extends GameEntityView {
return TrackableProperty.Hand;
case Library:
return TrackableProperty.Library;
case Flashback:
return TrackableProperty.Flashback;
default:
return null; //other zones not represented
}
@@ -231,6 +233,17 @@ public class PlayerView extends GameEntityView {
TrackableProperty prop = getZoneProp(zone.getZoneType());
if (prop == null) { return; }
set(prop, CardView.getCollection(zone.getCards()));
//update flashback zone when graveyard, library, or exile zones updated
switch (zone.getZoneType()) {
case Graveyard:
case Library:
case Exile:
set(TrackableProperty.Flashback, CardView.getCollection(zone.getPlayer().getCardsIn(ZoneType.Flashback)));
break;
default:
break;
}
}
public int getMana(final byte color) {

View File

@@ -13,6 +13,7 @@ public enum ZoneType {
Graveyard(false),
Battlefield(false),
Exile(false),
Flashback(false),
Command(false),
Stack(false),
Sideboard(true),

View File

@@ -1,7 +1,6 @@
package forge.screens.match;
import java.awt.event.ActionEvent;
import forge.game.card.CardView;
import forge.game.player.PlayerView;
import forge.game.zone.ZoneType;
import forge.gui.ForgeAction;
@@ -32,27 +31,5 @@ public class ZoneAction extends ForgeAction {
@Override
public void actionPerformed(final ActionEvent e) {
FloatingCardArea.show(player, zone);
/*final Iterable<CardView> choices = getCardsAsIterable();
if (choices == null || !choices.iterator().hasNext()) {
GuiChoose.reveal(title, "no cards");
return;
}
final List<CardStateView> choices2 = Lists.newLinkedList();
for (final CardView cv : choices) {
choices2.add(cv.getCurrentState());
}
final CardStateView choice = GuiChoose.oneOrNone(title, choices2);
if (choice != null) {
doAction(choice.getCard());
}*/
}
protected Iterable<CardView> getCardsAsIterable() {
return player.getCards(zone);
}
protected void doAction(final CardView c) {
}
}

View File

@@ -25,7 +25,6 @@ import com.google.common.base.Function;
import forge.Singletons;
import forge.UiCommand;
import forge.game.card.CardView;
import forge.game.player.PlayerView;
import forge.game.zone.ZoneType;
import forge.gui.framework.ICDoc;
@@ -66,22 +65,7 @@ public class CField implements ICDoc {
final ZoneAction libraryAction = new ZoneAction(player, ZoneType.Library, MatchConstants.HUMANLIBRARY);
final ZoneAction exileAction = new ZoneAction(player, ZoneType.Exile, MatchConstants.HUMANEXILED);
final ZoneAction graveAction = new ZoneAction(player, ZoneType.Graveyard, MatchConstants.HUMANGRAVEYARD);
@SuppressWarnings("serial")
final ZoneAction flashBackAction = new ZoneAction(player, null, MatchConstants.HUMANFLASHBACK) {
@Override
protected void doAction(final CardView c) {
// activate cards only via your own flashback button
if (player.getLobbyPlayer() != Singletons.getControl().getGuiPlayer()) {
return;
}
CPrompt.SINGLETON_INSTANCE.selectCard(c, null);
}
@Override
protected Iterable<CardView> getCardsAsIterable() {
return player.getFlashback();
}
};
final ZoneAction flashBackAction = new ZoneAction(player, ZoneType.Flashback, MatchConstants.HUMANFLASHBACK);
Function<Byte, Void> manaAction = new Function<Byte, Void>() {
public Void apply(Byte colorCode) {

View File

@@ -62,6 +62,17 @@ public class FloatingCardArea extends CardArea {
if (cardArea != null) {
cardArea.refresh();
}
//refresh flashback zone when graveyard, library, or exile zones updated
switch (zone) {
case Graveyard:
case Library:
case Exile:
refresh(player, ZoneType.Flashback);
break;
default:
break;
}
}
private final PlayerView player;

View File

@@ -1,24 +0,0 @@
package forge.screens.match.views;
import forge.FThreads;
import forge.game.player.PlayerView;
public class VFlashbackZone extends VCardDisplayArea {
private final PlayerView player;
public VFlashbackZone(PlayerView player0) {
player = player0;
}
@Override
public void update() {
FThreads.invokeInEdtNowOrLater(updateRoutine);
}
private final Runnable updateRoutine = new Runnable() {
@Override
public void run() {
refreshCardPanels(player.getFlashback());
}
};
}

View File

@@ -40,7 +40,6 @@ public class VPlayerPanel extends FContainer {
private final VZoneDisplay commandZone;
private final LifeLabel lblLife;
private final InfoTab tabManaPool;
private final InfoTab tabFlashbackZone;
private final Map<ZoneType, InfoTab> zoneTabs = new HashMap<ZoneType, InfoTab>();
private final List<InfoTab> tabs = new ArrayList<InfoTab>();
private InfoTab selectedTab;
@@ -55,10 +54,7 @@ public class VPlayerPanel extends FContainer {
addZoneDisplay(ZoneType.Hand, FSkinImage.HAND);
addZoneDisplay(ZoneType.Graveyard, FSkinImage.GRAVEYARD);
addZoneDisplay(ZoneType.Library, FSkinImage.LIBRARY);
VFlashbackZone flashbackZone = add(new VFlashbackZone(player0));
tabFlashbackZone = add(new InfoTab(FSkinImage.FLASHBACK, flashbackZone));
tabs.add(tabFlashbackZone);
addZoneDisplay(ZoneType.Flashback, FSkinImage.FLASHBACK);
VManaPool manaPool = add(new VManaPool(player));
tabManaPool = add(new InfoTab(FSkinImage.MANA_X, manaPool));
@@ -186,7 +182,7 @@ public class VPlayerPanel extends FContainer {
case Graveyard:
case Library:
case Exile:
tabFlashbackZone.update();
zoneTabs.get(ZoneType.Flashback).update();
break;
default:
break;