mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
lobbyPlayers have strict types, this is used to provide separate code paths to deliver messages to GUI player and remote one.
lobbyPlayer has a factory method to build concrete player.
This commit is contained in:
3
.gitattributes
vendored
3
.gitattributes
vendored
@@ -14058,6 +14058,9 @@ src/main/java/forge/game/player/AIPlayer.java svneol=native#text/plain
|
|||||||
src/main/java/forge/game/player/GameLossReason.java -text
|
src/main/java/forge/game/player/GameLossReason.java -text
|
||||||
src/main/java/forge/game/player/HumanPlayer.java svneol=native#text/plain
|
src/main/java/forge/game/player/HumanPlayer.java svneol=native#text/plain
|
||||||
src/main/java/forge/game/player/LobbyPlayer.java -text
|
src/main/java/forge/game/player/LobbyPlayer.java -text
|
||||||
|
src/main/java/forge/game/player/LobbyPlayerAi.java -text
|
||||||
|
src/main/java/forge/game/player/LobbyPlayerHuman.java -text
|
||||||
|
src/main/java/forge/game/player/LobbyPlayerRemote.java -text
|
||||||
src/main/java/forge/game/player/Player.java svneol=native#text/plain
|
src/main/java/forge/game/player/Player.java svneol=native#text/plain
|
||||||
src/main/java/forge/game/player/PlayerController.java -text
|
src/main/java/forge/game/player/PlayerController.java -text
|
||||||
src/main/java/forge/game/player/PlayerControllerAi.java -text
|
src/main/java/forge/game/player/PlayerControllerAi.java -text
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import java.util.Random;
|
|||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import forge.game.player.LobbyPlayer;
|
import forge.game.player.LobbyPlayer;
|
||||||
import forge.game.player.PlayerType;
|
import forge.game.player.LobbyPlayerAi;
|
||||||
|
import forge.game.player.LobbyPlayerHuman;
|
||||||
|
import forge.game.player.LobbyPlayerRemote;
|
||||||
import forge.gui.toolbox.FSkin;
|
import forge.gui.toolbox.FSkin;
|
||||||
import forge.util.MyRandom;
|
import forge.util.MyRandom;
|
||||||
|
|
||||||
@@ -57,17 +59,17 @@ public class Lobby {
|
|||||||
"Walter", "Wilfred", "William", "Winston"
|
"Walter", "Wilfred", "William", "Winston"
|
||||||
};
|
};
|
||||||
|
|
||||||
private Map<String, LobbyPlayer> remotePlayers = new ConcurrentHashMap<String, LobbyPlayer>();
|
private Map<String, LobbyPlayerRemote> remotePlayers = new ConcurrentHashMap<String, LobbyPlayerRemote>();
|
||||||
private final LobbyPlayer guiPlayer = new LobbyPlayer(PlayerType.HUMAN, "Human");
|
private final LobbyPlayerHuman guiPlayer = new LobbyPlayerHuman("Human");
|
||||||
|
|
||||||
|
|
||||||
public final LobbyPlayer getGuiPlayer() {
|
public final LobbyPlayerHuman getGuiPlayer() {
|
||||||
return guiPlayer;
|
return guiPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final LobbyPlayer getAiPlayer() { return getAiPlayer(getRandomName()); }
|
public final LobbyPlayer getAiPlayer() { return getAiPlayer(getRandomName()); }
|
||||||
public final LobbyPlayer getAiPlayer(String name) {
|
public final LobbyPlayer getAiPlayer(String name) {
|
||||||
LobbyPlayer player = new LobbyPlayer(PlayerType.COMPUTER, name);
|
LobbyPlayer player = new LobbyPlayerAi(name);
|
||||||
player.setAvatarIndex(MyRandom.getRandom().nextInt(FSkin.getAvatars().size()));
|
player.setAvatarIndex(MyRandom.getRandom().nextInt(FSkin.getAvatars().size()));
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
@@ -101,7 +103,7 @@ public class Lobby {
|
|||||||
if (remotePlayers.containsKey(name))
|
if (remotePlayers.containsKey(name))
|
||||||
return remotePlayers.get(name);
|
return remotePlayers.get(name);
|
||||||
|
|
||||||
LobbyPlayer res = new LobbyPlayer(PlayerType.REMOTE, name);
|
LobbyPlayerRemote res = new LobbyPlayerRemote(name);
|
||||||
// have to load avatar from remote user's preferences here
|
// have to load avatar from remote user's preferences here
|
||||||
remotePlayers.put(name, res);
|
remotePlayers.put(name, res);
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ import forge.CardPredicates;
|
|||||||
import forge.CardUtil;
|
import forge.CardUtil;
|
||||||
import forge.Command;
|
import forge.Command;
|
||||||
import forge.CounterType;
|
import forge.CounterType;
|
||||||
import forge.FThreads;
|
|
||||||
import forge.GameEntity;
|
import forge.GameEntity;
|
||||||
import forge.card.CardType;
|
import forge.card.CardType;
|
||||||
import forge.card.TriggerReplacementBase;
|
import forge.card.TriggerReplacementBase;
|
||||||
|
|||||||
@@ -45,11 +45,8 @@ import forge.game.phase.EndOfTurn;
|
|||||||
import forge.game.phase.PhaseHandler;
|
import forge.game.phase.PhaseHandler;
|
||||||
import forge.game.phase.Untap;
|
import forge.game.phase.Untap;
|
||||||
import forge.game.phase.Upkeep;
|
import forge.game.phase.Upkeep;
|
||||||
import forge.game.player.AIPlayer;
|
|
||||||
import forge.game.player.HumanPlayer;
|
|
||||||
import forge.game.player.LobbyPlayer;
|
import forge.game.player.LobbyPlayer;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.player.PlayerType;
|
|
||||||
import forge.game.zone.MagicStack;
|
import forge.game.zone.MagicStack;
|
||||||
import forge.game.zone.PlayerZone;
|
import forge.game.zone.PlayerZone;
|
||||||
import forge.game.zone.Zone;
|
import forge.game.zone.Zone;
|
||||||
@@ -99,7 +96,7 @@ public class GameState {
|
|||||||
type = t;
|
type = t;
|
||||||
List<Player> players = new ArrayList<Player>();
|
List<Player> players = new ArrayList<Player>();
|
||||||
for (LobbyPlayer p : players2) {
|
for (LobbyPlayer p : players2) {
|
||||||
Player pl = getIngamePlayer(p);
|
Player pl = p.getPlayer(this);
|
||||||
players.add(pl);
|
players.add(pl);
|
||||||
ingamePlayers.add(pl);
|
ingamePlayers.add(pl);
|
||||||
}
|
}
|
||||||
@@ -495,19 +492,6 @@ public class GameState {
|
|||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Only game knows how to get suitable players out of just connected clients.
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public Player getIngamePlayer(LobbyPlayer player) {
|
|
||||||
if (player.getType() == PlayerType.HUMAN) {
|
|
||||||
return new HumanPlayer(player, this);
|
|
||||||
} else {
|
|
||||||
return new AIPlayer(player, this);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this method.
|
* TODO: Write javadoc for this method.
|
||||||
* @param p
|
* @param p
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
|
|
||||||
import forge.Constant.Preferences;
|
import forge.Constant.Preferences;
|
||||||
import forge.FThreads;
|
import forge.FThreads;
|
||||||
@@ -21,6 +23,7 @@ import forge.game.event.DuelOutcomeEvent;
|
|||||||
import forge.game.player.AIPlayer;
|
import forge.game.player.AIPlayer;
|
||||||
import forge.game.player.HumanPlayer;
|
import forge.game.player.HumanPlayer;
|
||||||
import forge.game.player.LobbyPlayer;
|
import forge.game.player.LobbyPlayer;
|
||||||
|
import forge.game.player.LobbyPlayerHuman;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.player.PlayerStatistics;
|
import forge.game.player.PlayerStatistics;
|
||||||
import forge.game.player.PlayerType;
|
import forge.game.player.PlayerType;
|
||||||
@@ -102,7 +105,7 @@ public class MatchController {
|
|||||||
game.getGameLog().add("Final", result.getWinner() + " won", 0);
|
game.getGameLog().add("Final", result.getWinner() + " won", 0);
|
||||||
|
|
||||||
// add result entries to the game log
|
// add result entries to the game log
|
||||||
final LobbyPlayer human = Singletons.getControl().getPlayer().getLobbyPlayer();
|
final LobbyPlayerHuman human = Singletons.getControl().getLobby().getGuiPlayer();
|
||||||
|
|
||||||
|
|
||||||
final List<String> outcomes = new ArrayList<String>();
|
final List<String> outcomes = new ArrayList<String>();
|
||||||
@@ -146,9 +149,10 @@ public class MatchController {
|
|||||||
for (Player p : currentGame.getPlayers()) {
|
for (Player p : currentGame.getPlayers()) {
|
||||||
if ( !(p instanceof AIPlayer))
|
if ( !(p instanceof AIPlayer))
|
||||||
continue;
|
continue;
|
||||||
|
AIPlayer ai = (AIPlayer) p;
|
||||||
|
|
||||||
String currentAiProfile = Singletons.getModel().getPreferences().getPref(FPref.UI_CURRENT_AI_PROFILE);
|
String currentAiProfile = Singletons.getModel().getPreferences().getPref(FPref.UI_CURRENT_AI_PROFILE);
|
||||||
String lastProfileChosen = this.getPlayedGames().isEmpty() ? currentAiProfile : p.getLobbyPlayer().getAiProfile();
|
String lastProfileChosen = this.getPlayedGames().isEmpty() ? currentAiProfile : ai.getLobbyPlayer().getAiProfile();
|
||||||
|
|
||||||
// TODO: implement specific AI profiles for quest mode.
|
// TODO: implement specific AI profiles for quest mode.
|
||||||
boolean wantRandomProfile = currentAiProfile.equals(AiProfileUtil.AI_PROFILE_RANDOM_DUEL)
|
boolean wantRandomProfile = currentAiProfile.equals(AiProfileUtil.AI_PROFILE_RANDOM_DUEL)
|
||||||
@@ -156,11 +160,10 @@ public class MatchController {
|
|||||||
|
|
||||||
String profileToSet = wantRandomProfile ? AiProfileUtil.getRandomProfile() : lastProfileChosen;
|
String profileToSet = wantRandomProfile ? AiProfileUtil.getRandomProfile() : lastProfileChosen;
|
||||||
|
|
||||||
p.getLobbyPlayer().setAiProfile(profileToSet);
|
ai.getLobbyPlayer().setAiProfile(profileToSet);
|
||||||
System.out.println(String.format("AI profile %s was chosen for the lobby player %s.", p.getLobbyPlayer().getAiProfile(), p.getLobbyPlayer().getName()));
|
System.out.println(String.format("AI profile %s was chosen for the lobby player %s.", ai.getLobbyPlayer().getAiProfile(), ai.getLobbyPlayer().getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
HumanPlayer localHuman = (HumanPlayer) Aggregates.firstFieldEquals(currentGame.getPlayers(), Player.Accessors.FN_GET_TYPE, PlayerType.HUMAN);
|
HumanPlayer localHuman = (HumanPlayer) Aggregates.firstFieldEquals(currentGame.getPlayers(), Player.Accessors.FN_GET_TYPE, PlayerType.HUMAN);
|
||||||
FControl.SINGLETON_INSTANCE.setPlayer(localHuman);
|
FControl.SINGLETON_INSTANCE.setPlayer(localHuman);
|
||||||
|
|||||||
@@ -17,8 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package forge.game.ai;
|
package forge.game.ai;
|
||||||
|
|
||||||
import forge.Singletons;
|
import forge.game.player.LobbyPlayerAi;
|
||||||
import forge.game.player.LobbyPlayer;
|
|
||||||
import forge.util.Aggregates;
|
import forge.util.Aggregates;
|
||||||
import forge.util.FileUtil;
|
import forge.util.FileUtil;
|
||||||
|
|
||||||
@@ -97,7 +96,7 @@ public class AiProfileUtil {
|
|||||||
* @param fp0 an AI property.
|
* @param fp0 an AI property.
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
public static String getAIProp(final LobbyPlayer p, final AiProps fp0) {
|
public static String getAIProp(final LobbyPlayerAi p, final AiProps fp0) {
|
||||||
String val = null;
|
String val = null;
|
||||||
String profile = p.getAiProfile();
|
String profile = p.getAiProfile();
|
||||||
|
|
||||||
@@ -159,7 +158,7 @@ public class AiProfileUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple class test facility for AiProfileUtil.
|
* Simple class test facility for AiProfileUtil.
|
||||||
*/
|
*-/
|
||||||
public static void selfTest() {
|
public static void selfTest() {
|
||||||
final LobbyPlayer activePlayer = Singletons.getControl().getPlayer().getLobbyPlayer();
|
final LobbyPlayer activePlayer = Singletons.getControl().getPlayer().getLobbyPlayer();
|
||||||
System.out.println(String.format("Current profile = %s", activePlayer.getAiProfile()));
|
System.out.println(String.format("Current profile = %s", activePlayer.getAiProfile()));
|
||||||
@@ -181,4 +180,5 @@ public class AiProfileUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import forge.util.Aggregates;
|
|||||||
public class AIPlayer extends Player {
|
public class AIPlayer extends Player {
|
||||||
|
|
||||||
private final PlayerControllerAi controller;
|
private final PlayerControllerAi controller;
|
||||||
|
private final LobbyPlayerAi lobbyPlayer;
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Constructor for AIPlayer.
|
* Constructor for AIPlayer.
|
||||||
@@ -48,9 +49,11 @@ public class AIPlayer extends Player {
|
|||||||
* @param myName
|
* @param myName
|
||||||
* a {@link java.lang.String} object.
|
* a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
public AIPlayer(final LobbyPlayer player, final GameState game) {
|
public AIPlayer(final LobbyPlayerAi player, final GameState game) {
|
||||||
super(player, game);
|
super(player.getName(), game);
|
||||||
|
lobbyPlayer = player;
|
||||||
controller = new PlayerControllerAi(game, this);
|
controller = new PlayerControllerAi(game, this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AiController getAi() {
|
public AiController getAi() {
|
||||||
@@ -99,7 +102,16 @@ public class AIPlayer extends Player {
|
|||||||
* @see forge.game.player.Player#getController()
|
* @see forge.game.player.Player#getController()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PlayerController getController() {
|
public PlayerControllerAi getController() {
|
||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see forge.game.player.Player#getLobbyPlayer()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public LobbyPlayerAi getLobbyPlayer() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return lobbyPlayer;
|
||||||
|
}
|
||||||
} // end AIPlayer class
|
} // end AIPlayer class
|
||||||
|
|||||||
@@ -40,10 +40,12 @@ import forge.game.GameState;
|
|||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
|
|
||||||
public class HumanPlayer extends Player {
|
public class HumanPlayer extends Player {
|
||||||
private PlayerControllerHuman controller;
|
private final PlayerControllerHuman controller;
|
||||||
|
private final LobbyPlayerHuman lobbyPlayer;
|
||||||
|
|
||||||
public HumanPlayer(final LobbyPlayer player, GameState game) {
|
public HumanPlayer(final LobbyPlayerHuman player, GameState game) {
|
||||||
super(player, game);
|
super(player.getName(), game);
|
||||||
|
lobbyPlayer = player;
|
||||||
controller = new PlayerControllerHuman(game, this);
|
controller = new PlayerControllerHuman(game, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,10 +86,7 @@ public class HumanPlayer extends Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlayerType getType() {
|
public PlayerControllerHuman getController() {
|
||||||
return PlayerType.HUMAN;
|
|
||||||
}
|
|
||||||
public PlayerController getController() {
|
|
||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,4 +268,9 @@ public class HumanPlayer extends Player {
|
|||||||
game.getStack().add(sa, x);
|
game.getStack().add(sa, x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LobbyPlayerHuman getLobbyPlayer() {
|
||||||
|
return lobbyPlayer;
|
||||||
|
}
|
||||||
} // end HumanPlayer class
|
} // end HumanPlayer class
|
||||||
|
|||||||
@@ -1,28 +1,25 @@
|
|||||||
package forge.game.player;
|
package forge.game.player;
|
||||||
|
|
||||||
|
import forge.game.GameState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This means a player's part unchanged for all games.
|
* This means a player's part unchanged for all games.
|
||||||
*
|
*
|
||||||
* May store player's assets here.
|
* May store player's assets here.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class LobbyPlayer implements IHasIcon {
|
public abstract class LobbyPlayer implements IHasIcon {
|
||||||
|
|
||||||
protected final PlayerType type;
|
public abstract PlayerType getType();
|
||||||
public final PlayerType getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected final String name;
|
protected final String name;
|
||||||
protected String imageKey;
|
protected String imageKey;
|
||||||
private int avatarIndex = -1;
|
private int avatarIndex = -1;
|
||||||
|
|
||||||
/** The AI profile. */
|
/** The AI profile. */
|
||||||
private String aiProfile = "";
|
|
||||||
|
|
||||||
public LobbyPlayer(PlayerType type, String name) {
|
|
||||||
|
|
||||||
this.type = type;
|
public LobbyPlayer(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,8 +41,8 @@ public class LobbyPlayer implements IHasIcon {
|
|||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
result = prime * result + name.hashCode();
|
||||||
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
result = prime * result + getType().hashCode();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +65,7 @@ public class LobbyPlayer implements IHasIcon {
|
|||||||
} else if (!name.equals(other.name)) {
|
} else if (!name.equals(other.name)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return type == other.type;
|
return getType() == other.getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAvatarIndex() {
|
public int getAvatarIndex() {
|
||||||
@@ -79,11 +76,5 @@ public class LobbyPlayer implements IHasIcon {
|
|||||||
this.avatarIndex = avatarIndex;
|
this.avatarIndex = avatarIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAiProfile(String profileName) {
|
public abstract Player getPlayer(GameState gameState); // factory method to create player
|
||||||
aiProfile = profileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAiProfile() {
|
|
||||||
return aiProfile;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
32
src/main/java/forge/game/player/LobbyPlayerAi.java
Normal file
32
src/main/java/forge/game/player/LobbyPlayerAi.java
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package forge.game.player;
|
||||||
|
|
||||||
|
import forge.game.GameState;
|
||||||
|
|
||||||
|
public class LobbyPlayerAi extends LobbyPlayer {
|
||||||
|
public LobbyPlayerAi(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String aiProfile = "";
|
||||||
|
|
||||||
|
public void setAiProfile(String profileName) {
|
||||||
|
aiProfile = profileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAiProfile() {
|
||||||
|
return aiProfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PlayerType getType() {
|
||||||
|
return PlayerType.COMPUTER;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see forge.game.player.LobbyPlayer#getPlayer(forge.game.GameState)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Player getPlayer(GameState game) {
|
||||||
|
return new AIPlayer(this, game);
|
||||||
|
}
|
||||||
|
}
|
||||||
19
src/main/java/forge/game/player/LobbyPlayerHuman.java
Normal file
19
src/main/java/forge/game/player/LobbyPlayerHuman.java
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package forge.game.player;
|
||||||
|
|
||||||
|
import forge.game.GameState;
|
||||||
|
|
||||||
|
public class LobbyPlayerHuman extends LobbyPlayer {
|
||||||
|
public LobbyPlayerHuman(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PlayerType getType() {
|
||||||
|
return PlayerType.HUMAN;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Player getPlayer(GameState game) {
|
||||||
|
return new HumanPlayer(this, game);
|
||||||
|
}
|
||||||
|
}
|
||||||
25
src/main/java/forge/game/player/LobbyPlayerRemote.java
Normal file
25
src/main/java/forge/game/player/LobbyPlayerRemote.java
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package forge.game.player;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.NotImplementedException;
|
||||||
|
|
||||||
|
import forge.game.GameState;
|
||||||
|
|
||||||
|
public class LobbyPlayerRemote extends LobbyPlayer {
|
||||||
|
public LobbyPlayerRemote(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PlayerType getType() {
|
||||||
|
return PlayerType.REMOTE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see forge.game.player.LobbyPlayer#getPlayer(forge.game.GameState)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Player getPlayer(GameState gameState) {
|
||||||
|
// Cannot create remote players yet
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -164,7 +164,6 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
|||||||
ZoneType.Library, ZoneType.Graveyard, ZoneType.Hand, ZoneType.Exile, ZoneType.Command, ZoneType.Ante,
|
ZoneType.Library, ZoneType.Graveyard, ZoneType.Hand, ZoneType.Exile, ZoneType.Command, ZoneType.Ante,
|
||||||
ZoneType.Sideboard));
|
ZoneType.Sideboard));
|
||||||
|
|
||||||
protected final LobbyPlayer lobbyPlayer;
|
|
||||||
protected final GameState game;
|
protected final GameState game;
|
||||||
|
|
||||||
public final PlayerOutcome getOutcome() {
|
public final PlayerOutcome getOutcome() {
|
||||||
@@ -183,8 +182,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
|||||||
* @param myPoisonCounters
|
* @param myPoisonCounters
|
||||||
* a int.
|
* a int.
|
||||||
*/
|
*/
|
||||||
public Player(LobbyPlayer lobbyPlayer0, GameState game0) {
|
public Player(String name, GameState game0) {
|
||||||
lobbyPlayer = lobbyPlayer0;
|
|
||||||
game = game0;
|
game = game0;
|
||||||
for (final ZoneType z : Player.ALL_ZONES) {
|
for (final ZoneType z : Player.ALL_ZONES) {
|
||||||
final PlayerZone toPut = z == ZoneType.Battlefield
|
final PlayerZone toPut = z == ZoneType.Battlefield
|
||||||
@@ -192,7 +190,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
|||||||
: new PlayerZone(z, this);
|
: new PlayerZone(z, this);
|
||||||
this.zones.put(z, toPut);
|
this.zones.put(z, toPut);
|
||||||
}
|
}
|
||||||
this.setName(lobbyPlayer.getName());
|
this.setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameState getGame() { // I'll probably regret about this
|
public GameState getGame() { // I'll probably regret about this
|
||||||
@@ -207,7 +205,9 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
|||||||
public boolean isHuman() { return getType() == PlayerType.HUMAN; }
|
public boolean isHuman() { return getType() == PlayerType.HUMAN; }
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean isComputer() { return getType() == PlayerType.COMPUTER; }
|
public boolean isComputer() { return getType() == PlayerType.COMPUTER; }
|
||||||
public abstract PlayerType getType();
|
public PlayerType getType() {
|
||||||
|
return getLobbyPlayer().getType();
|
||||||
|
}
|
||||||
|
|
||||||
public List<Card> getSchemeDeck() {
|
public List<Card> getSchemeDeck() {
|
||||||
|
|
||||||
@@ -2727,9 +2727,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
|||||||
* TODO: Write javadoc for this method.
|
* TODO: Write javadoc for this method.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public LobbyPlayer getLobbyPlayer() {
|
public abstract LobbyPlayer getLobbyPlayer();
|
||||||
return lobbyPlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setOutcome(PlayerOutcome outcome) {
|
private void setOutcome(PlayerOutcome outcome) {
|
||||||
stats.setOutcome(outcome);
|
stats.setOutcome(outcome);
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ import forge.card.spellability.SpellAbility;
|
|||||||
import forge.card.trigger.TriggerType;
|
import forge.card.trigger.TriggerType;
|
||||||
import forge.game.GameState;
|
import forge.game.GameState;
|
||||||
import forge.game.PlanarDice;
|
import forge.game.PlanarDice;
|
||||||
|
import forge.game.player.HumanPlayer;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.zone.PlayerZone;
|
import forge.game.zone.PlayerZone;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
@@ -285,7 +286,7 @@ public final class GuiDisplayUtil {
|
|||||||
List<Card> humanDevExileSetup = new ArrayList<Card>();
|
List<Card> humanDevExileSetup = new ArrayList<Card>();
|
||||||
List<Card> computerDevExileSetup = new ArrayList<Card>();
|
List<Card> computerDevExileSetup = new ArrayList<Card>();
|
||||||
|
|
||||||
final Player human = Singletons.getControl().getPlayer();
|
final HumanPlayer human = Singletons.getControl().getPlayer();
|
||||||
final Player ai = human.getOpponents().get(0);
|
final Player ai = human.getOpponents().get(0);
|
||||||
|
|
||||||
if (!tChangePlayer.trim().toLowerCase().equals("none")) {
|
if (!tChangePlayer.trim().toLowerCase().equals("none")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user