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