mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
controller and lobbyPlayer moved to base class
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package forge.game.ai;
|
||||
|
||||
import forge.game.player.LobbyPlayer;
|
||||
import forge.game.player.LobbyPlayerAi;
|
||||
import forge.util.Aggregates;
|
||||
import forge.util.FileUtil;
|
||||
@@ -96,9 +97,11 @@ public class AiProfileUtil {
|
||||
* @param fp0 an AI property.
|
||||
* @return String
|
||||
*/
|
||||
public static String getAIProp(final LobbyPlayerAi p, final AiProps fp0) {
|
||||
public static String getAIProp(final LobbyPlayer p, final AiProps fp0) {
|
||||
String val = null;
|
||||
String profile = p.getAiProfile();
|
||||
if (!(p instanceof LobbyPlayerAi))
|
||||
return "";
|
||||
String profile = ((LobbyPlayerAi) p).getAiProfile();
|
||||
|
||||
if (loadedProfiles.get(profile) != null) {
|
||||
val = loadedProfiles.get(profile).get(fp0);
|
||||
|
||||
@@ -31,7 +31,6 @@ import forge.game.ai.AiController;
|
||||
public class AIPlayer extends Player {
|
||||
|
||||
private final PlayerControllerAi controller;
|
||||
private final LobbyPlayerAi lobbyPlayer;
|
||||
/**
|
||||
* <p>
|
||||
* Constructor for AIPlayer.
|
||||
@@ -42,43 +41,12 @@ public class AIPlayer extends Player {
|
||||
* a {@link java.lang.String} object.
|
||||
*/
|
||||
public AIPlayer(final LobbyPlayerAi player, final GameState game) {
|
||||
super(player.getName(), game);
|
||||
lobbyPlayer = player;
|
||||
super(player, game);
|
||||
controller = new PlayerControllerAi(game, this);
|
||||
|
||||
}
|
||||
|
||||
public AiController getAi() {
|
||||
return controller.getAi();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// /////////////////////////
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.game.player.Player#getType()
|
||||
*/
|
||||
@Override
|
||||
public PlayerType getType() {
|
||||
return PlayerType.COMPUTER;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.game.player.Player#getController()
|
||||
*/
|
||||
@Override
|
||||
public PlayerControllerAi getController() {
|
||||
return controller;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.game.player.Player#getLobbyPlayer()
|
||||
*/
|
||||
@Override
|
||||
public LobbyPlayerAi getLobbyPlayer() {
|
||||
// TODO Auto-generated method stub
|
||||
return lobbyPlayer;
|
||||
}
|
||||
} // end AIPlayer class
|
||||
|
||||
@@ -40,11 +40,9 @@ import forge.game.GameState;
|
||||
|
||||
public class HumanPlayer extends Player {
|
||||
private final PlayerControllerHuman controller;
|
||||
private final LobbyPlayerHuman lobbyPlayer;
|
||||
|
||||
public HumanPlayer(final LobbyPlayerHuman player, GameState game) {
|
||||
super(player.getName(), game);
|
||||
lobbyPlayer = player;
|
||||
super(player, game);
|
||||
controller = new PlayerControllerHuman(game, this);
|
||||
}
|
||||
|
||||
@@ -62,11 +60,6 @@ public class HumanPlayer extends Player {
|
||||
p.getGame().getPhaseHandler().setPriority(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerControllerHuman getController() {
|
||||
return controller;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -240,8 +233,4 @@ public class HumanPlayer extends Player {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LobbyPlayerHuman getLobbyPlayer() {
|
||||
return lobbyPlayer;
|
||||
}
|
||||
} // end HumanPlayer class
|
||||
|
||||
@@ -83,7 +83,7 @@ import forge.util.MyRandom;
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public abstract class Player extends GameEntity implements Comparable<Player> {
|
||||
public class Player extends GameEntity implements Comparable<Player> {
|
||||
/** The poison counters. */
|
||||
private int poisonCounters = 0;
|
||||
|
||||
@@ -158,6 +158,8 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
||||
private Card currentPlane = null;
|
||||
|
||||
private PlayerStatistics stats = new PlayerStatistics();
|
||||
private PlayerController controller;
|
||||
private final LobbyPlayer lobbyPlayer;
|
||||
|
||||
private final List<Card> schemeDeck = new ArrayList<Card>();
|
||||
private Card activeScheme = null;
|
||||
@@ -185,7 +187,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
||||
* @param myPoisonCounters
|
||||
* a int.
|
||||
*/
|
||||
public Player(String name, GameState game0) {
|
||||
public Player(LobbyPlayer lobby, GameState game0) {
|
||||
game = game0;
|
||||
for (final ZoneType z : Player.ALL_ZONES) {
|
||||
final PlayerZone toPut = z == ZoneType.Battlefield
|
||||
@@ -193,7 +195,8 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
||||
: new PlayerZone(z, this);
|
||||
this.zones.put(z, toPut);
|
||||
}
|
||||
this.setName(name);
|
||||
this.setName(lobby.getName());
|
||||
this.lobbyPlayer = lobby;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2748,7 +2751,9 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
||||
* TODO: Write javadoc for this method.
|
||||
* @return
|
||||
*/
|
||||
public abstract LobbyPlayer getLobbyPlayer();
|
||||
public final LobbyPlayer getLobbyPlayer() {
|
||||
return lobbyPlayer;
|
||||
}
|
||||
|
||||
private void setOutcome(PlayerOutcome outcome) {
|
||||
stats.setOutcome(outcome);
|
||||
@@ -2865,8 +2870,12 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
||||
* TODO: Write javadoc for this method.
|
||||
* @return
|
||||
*/
|
||||
public abstract PlayerController getController();
|
||||
|
||||
public final PlayerController getController() {
|
||||
return controller;
|
||||
}
|
||||
public final void setController(PlayerController ctrlr) {
|
||||
controller = ctrlr;
|
||||
}
|
||||
/**
|
||||
* <p>
|
||||
* skipCombat.
|
||||
|
||||
Reference in New Issue
Block a user