mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
Remove global Player cache, instead make it hang off the Game object.
This commit is contained in:
@@ -304,6 +304,6 @@ public class GuiDesktop implements IGuiBase {
|
||||
|
||||
@Override
|
||||
public void setPlayerAvatar(LobbyPlayer player, IHasIcon ihi) {
|
||||
CMatchUI.SINGLETON_INSTANCE.avatarImages.put(player, ihi.getIconImageKey());
|
||||
CMatchUI.SINGLETON_INSTANCE.avatarImages.put(player.getName(), ihi.getIconImageKey());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,6 @@ import forge.match.IMatchController;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.menus.IMenuProvider;
|
||||
import forge.model.FModel;
|
||||
import forge.player.LobbyPlayerHuman;
|
||||
import forge.properties.ForgePreferences;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.screens.match.controllers.CAntes;
|
||||
@@ -110,11 +109,11 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
private boolean showOverlay = true;
|
||||
|
||||
private IVDoc<? extends ICDoc> selectedDocBeforeCombat;
|
||||
public final Map<LobbyPlayer, String> avatarImages = new HashMap<LobbyPlayer, String>();
|
||||
|
||||
private SkinImage getPlayerAvatar(final LobbyPlayer p, final int defaultIndex) {
|
||||
if (avatarImages.containsKey(p)) {
|
||||
return ImageCache.getIcon(avatarImages.get(p));
|
||||
public final Map<String, String> avatarImages = new HashMap<String, String>();
|
||||
|
||||
private SkinImage getPlayerAvatar(final PlayerView p, final int defaultIndex) {
|
||||
if (avatarImages.containsKey(p.getLobbyPlayerName())) {
|
||||
return ImageCache.getIcon(avatarImages.get(p.getLobbyPlayerName()));
|
||||
}
|
||||
|
||||
int avatarIdx = p.getAvatarIndex();
|
||||
@@ -147,7 +146,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
commands.add(c);
|
||||
|
||||
//setAvatar(f, new ImageIcon(FSkin.getAvatars().get()));
|
||||
setAvatar(f, getPlayerAvatar(p.getLobbyPlayer(), Integer.parseInt(indices[i > 2 ? 1 : 0])));
|
||||
setAvatar(f, getPlayerAvatar(p, Integer.parseInt(indices[i > 2 ? 1 : 0])));
|
||||
f.getLayoutControl().initialize();
|
||||
c.getLayoutControl().initialize();
|
||||
i++;
|
||||
@@ -167,7 +166,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
|
||||
int i = 0;
|
||||
for (final PlayerView p : sortedPlayers) {
|
||||
if (allHands || p.getLobbyPlayer() instanceof LobbyPlayerHuman || CardView.mayViewAny(p.getHand(), p)) {
|
||||
if (allHands || !p.isAI() || CardView.mayViewAny(p.getHand(), p)) {
|
||||
VHand newHand = new VHand(EDocID.Hands[i], p);
|
||||
newHand.getLayoutControl().initialize();
|
||||
hands.add(newHand);
|
||||
|
||||
@@ -80,7 +80,7 @@ public class QuestDraftWinLose extends ControlWinLose {
|
||||
final Iterable<PlayerView> players = lastGame.getPlayers();
|
||||
boolean gameHadHumanPlayer = false;
|
||||
for (final PlayerView p : players) {
|
||||
if (p.getLobbyPlayer().equals(questLobbyPlayer)) {
|
||||
if (p.isLobbyPlayer(questLobbyPlayer)) {
|
||||
gameHadHumanPlayer = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ public class VAssignDamage {
|
||||
}
|
||||
else if (defender instanceof PlayerView) {
|
||||
final PlayerView p = (PlayerView)defender;
|
||||
fakeCard = new CardView(-1, defender.toString(), p, CMatchUI.SINGLETON_INSTANCE.avatarImages.get(p.getLobbyPlayer()));
|
||||
fakeCard = new CardView(-1, defender.toString(), p, CMatchUI.SINGLETON_INSTANCE.avatarImages.get(p.getLobbyPlayerName()));
|
||||
}
|
||||
addPanelForDefender(pnlDefenders, fakeCard);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class CField implements ICDoc {
|
||||
|
||||
Function<Byte, Boolean> manaAction = new Function<Byte, Boolean>() {
|
||||
public Boolean apply(Byte colorCode) {
|
||||
if (CField.this.player.getLobbyPlayer() == Singletons.getControl().getGuiPlayer()) {
|
||||
if (CField.this.player.isLobbyPlayer(Singletons.getControl().getGuiPlayer())) {
|
||||
return MatchUtil.getHumanController().useMana(colorCode.byteValue());
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -20,7 +20,6 @@ package forge.view.arcane;
|
||||
import forge.Singletons;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.framework.SDisplayUtil;
|
||||
@@ -169,7 +168,7 @@ public class FloatingCardArea extends CardArea {
|
||||
player = player0;
|
||||
title = Lang.getPossessedObject(player0.getName(), zone.name()) + " (%d)";
|
||||
|
||||
boolean isAi = Player.get(player0).getController().isAI();
|
||||
boolean isAi = player0.isAI();
|
||||
switch (zone) {
|
||||
case Exile:
|
||||
locPref = isAi ? FPref.ZONE_LOC_AI_EXILE : FPref.ZONE_LOC_HUMAN_EXILE;
|
||||
|
||||
Reference in New Issue
Block a user