Player has lobbyPlayerCreator, actual lobbyPlayer is calculated from whatever is written in player.сontroller

This commit is contained in:
Maxmtg
2013-05-27 10:04:18 +00:00
parent 39c85da7f8
commit 7fd61015a3
7 changed files with 19 additions and 13 deletions

View File

@@ -28,7 +28,7 @@ public class LobbyPlayerAi extends LobbyPlayer {
@Override
public Player getPlayer(GameState game) {
Player ai = new Player(this, game);
ai.setController(new PlayerControllerAi(game, ai));
ai.setController(new PlayerControllerAi(game, ai, this));
String currentAiProfile = Singletons.getModel().getPreferences().getPref(FPref.UI_CURRENT_AI_PROFILE);
String lastProfileChosen = game.getMatch().getPlayedGames().isEmpty() ? currentAiProfile : getAiProfile();

View File

@@ -16,7 +16,7 @@ public class LobbyPlayerHuman extends LobbyPlayer {
@Override
public Player getPlayer(GameState game) {
Player player = new Player(this, game);
player.setController(new PlayerControllerHuman(game, player));
player.setController(new PlayerControllerHuman(game, player, this));
return player;
}

View File

@@ -163,7 +163,7 @@ public class Player extends GameEntity implements Comparable<Player> {
private PlayerStatistics stats = new PlayerStatistics();
protected PlayerController controller;
private final LobbyPlayer lobbyPlayer;
private final LobbyPlayer lobbyPlayerCreator;
private int teamNumber = -1;
private Card activeScheme = null;
@@ -200,7 +200,7 @@ public class Player extends GameEntity implements Comparable<Player> {
this.zones.put(z, toPut);
}
this.setName(chooseName(lobby));
this.lobbyPlayer = lobby;
this.lobbyPlayerCreator = lobby;
}
private String chooseName(LobbyPlayer lobby) {
@@ -2739,7 +2739,11 @@ public class Player extends GameEntity implements Comparable<Player> {
* @return
*/
public final LobbyPlayer getLobbyPlayer() {
return lobbyPlayer;
return getController().getLobbyPlayer();
}
public final boolean isMindSlaved() {
return getController().getLobbyPlayer() != lobbyPlayerCreator;
}
private void setOutcome(PlayerOutcome outcome) {

View File

@@ -35,10 +35,12 @@ public abstract class PlayerController {
private PhaseType autoPassUntil = null;
private final Input autoPassPriorityInput;
protected final Player player;
protected final LobbyPlayer lobbyPlayer;
public PlayerController(GameState game0, Player p) {
public PlayerController(GameState game0, Player p, LobbyPlayer lp) {
game = game0;
player = p;
lobbyPlayer = lp;
autoPassPriorityInput = new InputAutoPassPriority(player);
}
@@ -90,7 +92,8 @@ public abstract class PlayerController {
// End of Triggers preliminary choice
public LobbyPlayer getLobbyPlayer() { return lobbyPlayer; }
/**
* Uses GUI to learn which spell the player (human in our case) would like to play
*/

View File

@@ -46,8 +46,8 @@ public class PlayerControllerAi extends PlayerController {
private final AiController brains;
public PlayerControllerAi(GameState game, Player p) {
super(game, p);
public PlayerControllerAi(GameState game, Player p, LobbyPlayer lp) {
super(game, p, lp);
brains = new AiController(p, game);

View File

@@ -53,8 +53,8 @@ public class PlayerControllerHuman extends PlayerController {
private final Input blockInput;
private final Input cleanupInput;
public PlayerControllerHuman(GameState game0, Player p) {
super(game0, p);
public PlayerControllerHuman(GameState game0, Player p, LobbyPlayer lp) {
super(game0, p, lp);
defaultInput = new InputPassPriority(player);
blockInput = new InputBlock(player, game0);
cleanupInput = new InputCleanup(player);

View File

@@ -81,8 +81,7 @@ public enum CDock implements ICDoc {
}
final Player p = findAffectedPlayer();
if( p == null ) return;
// if( c.isMindSlaved() ) return
if( p == null || p.isMindSlaved() ) return;
game.getInputQueue().invokeGameAction(new Runnable() {
@Override