mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Player has lobbyPlayerCreator, actual lobbyPlayer is calculated from whatever is written in player.сontroller
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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,6 +92,7 @@ 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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user