Fix mobile game compile errors from recent refactoring

This commit is contained in:
drdev
2014-12-17 02:01:58 +00:00
parent d9abca9538
commit b97b586d2d
7 changed files with 20 additions and 12 deletions

View File

@@ -2195,6 +2195,7 @@ public class Player extends GameEntity implements Comparable<Player> {
controllerCreator = ctrlr; controllerCreator = ctrlr;
controller = ctrlr; controller = ctrlr;
view.updateAvatarIndex(this); view.updateAvatarIndex(this);
view.updateAvatarCardImageKey(this);
view.updateIsAI(this); view.updateIsAI(this);
view.updateLobbyPlayerName(this); view.updateLobbyPlayerName(this);
} }

View File

@@ -65,6 +65,13 @@ public class PlayerView extends GameEntityView {
set(TrackableProperty.AvatarIndex, p.getLobbyPlayer().getAvatarIndex()); set(TrackableProperty.AvatarIndex, p.getLobbyPlayer().getAvatarIndex());
} }
public String getAvatarCardImageKey() {
return get(TrackableProperty.AvatarCardImageKey);
}
void updateAvatarCardImageKey(Player p) {
set(TrackableProperty.AvatarCardImageKey, p.getLobbyPlayer().getAvatarCardImageKey());
}
public FCollectionView<PlayerView> getOpponents() { public FCollectionView<PlayerView> getOpponents() {
return get(TrackableProperty.Opponents); return get(TrackableProperty.Opponents);
} }

View File

@@ -88,6 +88,7 @@ public enum TrackableProperty {
IsAI(TrackableTypes.BooleanType), IsAI(TrackableTypes.BooleanType),
LobbyPlayerName(TrackableTypes.StringType), LobbyPlayerName(TrackableTypes.StringType),
AvatarIndex(TrackableTypes.IntegerType), AvatarIndex(TrackableTypes.IntegerType),
AvatarCardImageKey(TrackableTypes.StringType),
Opponents(TrackableTypes.PlayerViewCollectionType), Opponents(TrackableTypes.PlayerViewCollectionType),
Life(TrackableTypes.IntegerType), Life(TrackableTypes.IntegerType),
PoisonCounters(TrackableTypes.IntegerType), PoisonCounters(TrackableTypes.IntegerType),

View File

@@ -49,7 +49,7 @@ public class MatchController implements IMatchController {
private MatchController() { } private MatchController() { }
public static final MatchController instance = new MatchController(); public static final MatchController instance = new MatchController();
private static final Map<LobbyPlayer, FImage> avatarImages = new HashMap<LobbyPlayer, FImage>(); private static final Map<String, FImage> avatarImages = new HashMap<String, FImage>();
private static MatchScreen view; private static MatchScreen view;
@@ -58,21 +58,21 @@ public class MatchController implements IMatchController {
} }
public static FImage getPlayerAvatar(final PlayerView p) { public static FImage getPlayerAvatar(final PlayerView p) {
LobbyPlayer lp = p.getLobbyPlayer(); String lp = p.getLobbyPlayerName();
FImage avatar = avatarImages.get(lp); FImage avatar = avatarImages.get(lp);
if (avatar == null) { if (avatar == null) {
if (lp.getAvatarCardImageKey() == null) { if (p.getAvatarCardImageKey() == null) {
avatar = new FTextureRegionImage(FSkin.getAvatars().get(lp.getAvatarIndex())); avatar = new FTextureRegionImage(FSkin.getAvatars().get(p.getAvatarIndex()));
} }
else { //handle lobby players with art from cards else { //handle lobby players with art from cards
avatar = CardRenderer.getCardArt(lp.getAvatarCardImageKey(), false); avatar = CardRenderer.getCardArt(p.getAvatarCardImageKey(), false);
} }
} }
return avatar; return avatar;
} }
public static void setPlayerAvatar(final LobbyPlayer lp, final FImage avatarImage) { public static void setPlayerAvatar(final LobbyPlayer lp, final FImage avatarImage) {
avatarImages.put(lp, avatarImage); avatarImages.put(lp.getName(), avatarImage);
} }
public void refreshCardDetails(Iterable<CardView> cards) { public void refreshCardDetails(Iterable<CardView> cards) {
@@ -176,7 +176,7 @@ public class MatchController implements IMatchController {
public void updatePlayerControl() { public void updatePlayerControl() {
//show/hide hand for top player based on whether the opponent is controlled //show/hide hand for top player based on whether the opponent is controlled
if (MatchUtil.getHumanCount() == 1) { if (MatchUtil.getHumanCount() == 1) {
Player player = Player.get(view.getTopPlayerPanel().getPlayer()); PlayerView player = view.getTopPlayerPanel().getPlayer();
if (player.getMindSlaveMaster() != null) { if (player.getMindSlaveMaster() != null) {
view.getTopPlayerPanel().setSelectedZone(ZoneType.Hand); view.getTopPlayerPanel().setSelectedZone(ZoneType.Hand);
} }

View File

@@ -24,7 +24,6 @@ import forge.game.GameView;
import forge.game.card.CardView; import forge.game.card.CardView;
import forge.game.combat.CombatView; import forge.game.combat.CombatView;
import forge.game.phase.PhaseType; import forge.game.phase.PhaseType;
import forge.game.player.Player;
import forge.game.player.PlayerView; import forge.game.player.PlayerView;
import forge.game.zone.ZoneType; import forge.game.zone.ZoneType;
import forge.match.MatchUtil; import forge.match.MatchUtil;
@@ -231,7 +230,7 @@ public class MatchScreen extends FScreen {
} }
public boolean isTopHumanPlayerActive() { public boolean isTopHumanPlayerActive() {
return topPlayerPrompt != null && Player.get(topPlayerPanel.getPlayer()) == MatchUtil.getCurrentPlayer(); return topPlayerPrompt != null && topPlayerPanel.getPlayer() == MatchUtil.getCurrentPlayer().getView();
} }
public VPrompt getActivePrompt() { public VPrompt getActivePrompt() {

View File

@@ -81,7 +81,7 @@ public class VManaPool extends VDisplayArea {
@Override @Override
public boolean tap(float x, float y, int count) { public boolean tap(float x, float y, int count) {
if (player.getLobbyPlayer() == GamePlayerUtil.getGuiPlayer()) { if (player.isLobbyPlayer(GamePlayerUtil.getGuiPlayer())) {
MatchUtil.getHumanController().useMana(colorCode); MatchUtil.getHumanController().useMana(colorCode);
} }
return true; return true;
@@ -89,7 +89,7 @@ public class VManaPool extends VDisplayArea {
@Override @Override
public boolean flick(float x, float y) { public boolean flick(float x, float y) {
if (player.getLobbyPlayer() == GamePlayerUtil.getGuiPlayer()) { if (player.isLobbyPlayer(GamePlayerUtil.getGuiPlayer())) {
//on two finger tap, keep using mana until it runs out or no longer can be put towards the cost //on two finger tap, keep using mana until it runs out or no longer can be put towards the cost
while (MatchUtil.getHumanController().useMana(colorCode)) {} while (MatchUtil.getHumanController().useMana(colorCode)) {}
} }

View File

@@ -299,7 +299,7 @@ public class VPlayerPanel extends FContainer {
} }
//when gui player loses life, vibrate device for a length of time based on amount of life lost //when gui player loses life, vibrate device for a length of time based on amount of life lost
if (vibrateDuration > 0 && player.getLobbyPlayer() == MatchUtil.getGuiPlayer() && if (vibrateDuration > 0 && player.isLobbyPlayer(MatchUtil.getGuiPlayer()) &&
FModel.getPreferences().getPrefBoolean(FPref.UI_VIBRATE_ON_LIFE_LOSS)) { FModel.getPreferences().getPrefBoolean(FPref.UI_VIBRATE_ON_LIFE_LOSS)) {
//never vibrate more than two seconds regardless of life lost or poison counters gained //never vibrate more than two seconds regardless of life lost or poison counters gained
Gdx.input.vibrate(Math.min(vibrateDuration, 2000)); Gdx.input.vibrate(Math.min(vibrateDuration, 2000));