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