mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 02:38:02 +00:00
Fix so zones restored after selecting targets
This commit is contained in:
@@ -395,14 +395,21 @@ public class GuiDesktop implements IGuiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean openZone(ZoneType zoneType, Set<Player> players) {
|
||||
switch (zoneType) {
|
||||
case Battlefield:
|
||||
case Hand:
|
||||
return true; //don't actually need to open anything, but indicate that zone can be opened
|
||||
default:
|
||||
return false;
|
||||
public boolean openZones(List<ZoneType> zones, Map<Player, Object> players) {
|
||||
if (zones.size() == 1) {
|
||||
switch (zones.get(0)) {
|
||||
case Battlefield:
|
||||
case Hand:
|
||||
return true; //don't actually need to open anything, but indicate that zone can be opened
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreOldZones(Map<Player, Object> playersToRestoreZonesFor) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -327,24 +328,37 @@ public class GuiMobile implements IGuiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean openZone(ZoneType zoneType, Set<Player> players) {
|
||||
switch (zoneType) {
|
||||
case Battlefield:
|
||||
return true; //Battlefield is always open
|
||||
default:
|
||||
//open zone tab for given zone if needed
|
||||
boolean result = true;
|
||||
for (Player player : players) {
|
||||
VPlayerPanel playerPanel = FControl.getPlayerPanel(player);
|
||||
InfoTab zoneTab = playerPanel.getZoneTab(zoneType);
|
||||
if (zoneTab == null) {
|
||||
result = false;
|
||||
}
|
||||
else {
|
||||
playerPanel.setSelectedTab(zoneTab);
|
||||
public boolean openZones(List<ZoneType> zones, Map<Player, Object> players) {
|
||||
if (zones.size() == 1) {
|
||||
ZoneType zoneType = zones.get(0);
|
||||
switch (zoneType) {
|
||||
case Battlefield:
|
||||
return true; //Battlefield is always open
|
||||
default:
|
||||
//open zone tab for given zone if needed
|
||||
boolean result = true;
|
||||
for (Player player : players.keySet()) {
|
||||
VPlayerPanel playerPanel = FControl.getPlayerPanel(player);
|
||||
players.put(player, playerPanel.getSelectedTab()); //backup selected tab before changing it
|
||||
InfoTab zoneTab = playerPanel.getZoneTab(zoneType);
|
||||
if (zoneTab == null) {
|
||||
result = false;
|
||||
}
|
||||
else {
|
||||
playerPanel.setSelectedTab(zoneTab);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreOldZones(Map<Player, Object> playersToRestoreZonesFor) {
|
||||
for (Entry<Player, Object> player : playersToRestoreZonesFor.entrySet()) {
|
||||
VPlayerPanel playerPanel = FControl.getPlayerPanel(player.getKey());
|
||||
playerPanel.setSelectedTab((InfoTab)player.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,8 @@ public interface IGuiBase {
|
||||
void enableOverlay();
|
||||
void disableOverlay();
|
||||
void finishGame();
|
||||
boolean openZone(ZoneType zoneType, Set<Player> players);
|
||||
boolean openZones(List<ZoneType> zones, Map<Player, Object> players);
|
||||
void restoreOldZones(Map<Player, Object> playersToRestoreZonesFor);
|
||||
void updateStack();
|
||||
void updateZones(List<Pair<Player, ZoneType>> zonesToUpdate);
|
||||
void updateCards(Set<Card> cardsToUpdate);
|
||||
|
||||
@@ -36,9 +36,9 @@ import forge.util.Aggregates;
|
||||
import forge.util.gui.SGuiChoose;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -113,12 +113,17 @@ public class TargetSelection {
|
||||
return this.chooseCardFromStack(mandatory);
|
||||
}
|
||||
else {
|
||||
List<Card> validTargets = this.getValidCardsToTarget();
|
||||
if (zone.size() == 1 && GuiBase.getInterface().openZone(zone.get(0), getPlayersWithValidTargets(validTargets))) {
|
||||
final List<Card> validTargets = this.getValidCardsToTarget();
|
||||
final Map<Player, Object> playersWithValidTargets = new HashMap<Player, Object>();
|
||||
for (Card card : validTargets) {
|
||||
playersWithValidTargets.put(card.getController(), null);
|
||||
}
|
||||
if (GuiBase.getInterface().openZones(zone, playersWithValidTargets)) {
|
||||
InputSelectTargets inp = new InputSelectTargets(validTargets, ability, mandatory);
|
||||
inp.showAndWait();
|
||||
choiceResult = !inp.hasCancelled();
|
||||
bTargetingDone = inp.hasPressedOk();
|
||||
GuiBase.getInterface().restoreOldZones(playersWithValidTargets);
|
||||
}
|
||||
else {
|
||||
// for every other case an all-purpose GuiChoose
|
||||
@@ -129,14 +134,6 @@ public class TargetSelection {
|
||||
return choiceResult && chooseTargets(numTargets);
|
||||
}
|
||||
|
||||
private Set<Player> getPlayersWithValidTargets(List<Card> validTargets) {
|
||||
Set<Player> players = new HashSet<Player>();
|
||||
for (Card card : validTargets) {
|
||||
players.add(card.getController());
|
||||
}
|
||||
return players;
|
||||
}
|
||||
|
||||
// these have been copied over from CardFactoryUtil as they need two extra
|
||||
// parameters for target selection.
|
||||
// however, due to the changes necessary for SA_Requirements this is much
|
||||
|
||||
Reference in New Issue
Block a user