Fix so player 2 receives zones properly in network game

This commit is contained in:
drdev
2015-07-19 00:13:10 +00:00
parent fa1046d5be
commit c75a63305d
4 changed files with 16 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ import java.io.Serializable;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import forge.game.IIdentifiable; import forge.game.IIdentifiable;
@@ -66,6 +67,12 @@ public abstract class TrackableObject implements IIdentifiable, Serializable {
} }
} }
public final void updateObjLookup() {
for (final Entry<TrackableProperty, Object> prop : props.entrySet()) {
prop.getKey().updateObjLookup(prop.getValue());
}
}
/** /**
* Copy all change properties of another Trackable object to this object. * Copy all change properties of another Trackable object to this object.
*/ */

View File

@@ -48,6 +48,7 @@ public class TrackableTypes {
protected void updateObjLookup(T newObj) { protected void updateObjLookup(T newObj) {
if (!objLookup.containsKey(newObj.getId())) { if (!objLookup.containsKey(newObj.getId())) {
objLookup.put(newObj.getId(), newObj); objLookup.put(newObj.getId(), newObj);
newObj.updateObjLookup();
} }
} }

View File

@@ -27,6 +27,7 @@ import forge.game.player.PlayerView;
import forge.interfaces.IGameController; import forge.interfaces.IGameController;
import forge.interfaces.IGuiGame; import forge.interfaces.IGuiGame;
import forge.interfaces.IMayViewCards; import forge.interfaces.IMayViewCards;
import forge.trackable.TrackableTypes;
public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards { public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards {
private PlayerView currentPlayer = null; private PlayerView currentPlayer = null;
@@ -67,6 +68,13 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards {
@Override @Override
public void setGameView(final GameView gameView0) { public void setGameView(final GameView gameView0) {
if (gameView == null || gameView0 == null) { if (gameView == null || gameView0 == null) {
if (gameView0 != null) {
//ensure lookup dictionaries are reset before each game
TrackableTypes.CardViewType.clearLookupDictionary();
TrackableTypes.PlayerViewType.clearLookupDictionary();
TrackableTypes.StackItemViewType.clearLookupDictionary();
gameView0.updateObjLookup();
}
gameView = gameView0; gameView = gameView0;
return; return;
} }

View File

@@ -44,7 +44,6 @@ import forge.quest.QuestController;
import forge.sound.MusicPlaylist; import forge.sound.MusicPlaylist;
import forge.sound.SoundSystem; import forge.sound.SoundSystem;
import forge.trackable.TrackableCollection; import forge.trackable.TrackableCollection;
import forge.trackable.TrackableTypes;
import forge.util.CollectionSuppliers; import forge.util.CollectionSuppliers;
import forge.util.collect.FCollectionView; import forge.util.collect.FCollectionView;
import forge.util.maps.HashMapOfLists; import forge.util.maps.HashMapOfLists;
@@ -128,11 +127,6 @@ public class HostedMatch {
} }
public void startGame() { public void startGame() {
//ensure lookup dictionaries are cleared before each game
TrackableTypes.CardViewType.clearLookupDictionary();
TrackableTypes.PlayerViewType.clearLookupDictionary();
TrackableTypes.StackItemViewType.clearLookupDictionary();
nextGameDecisions.clear(); nextGameDecisions.clear();
SoundSystem.instance.setBackgroundMusic(MusicPlaylist.MATCH); SoundSystem.instance.setBackgroundMusic(MusicPlaylist.MATCH);