From a104219967f7e531f6c8f3d58eea355335690f83 Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Fri, 26 Jul 2019 16:14:22 +0200 Subject: [PATCH] Added naming support in Player and subclasses --- src/dev/kske/chess/game/NaturalPlayer.java | 1 + src/dev/kske/chess/game/Player.java | 11 ++++++++--- src/dev/kske/chess/game/UCIPlayer.java | 9 +-------- src/dev/kske/chess/game/ai/AIPlayer.java | 1 + 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/dev/kske/chess/game/NaturalPlayer.java b/src/dev/kske/chess/game/NaturalPlayer.java index e181320..9d12e61 100644 --- a/src/dev/kske/chess/game/NaturalPlayer.java +++ b/src/dev/kske/chess/game/NaturalPlayer.java @@ -28,6 +28,7 @@ public class NaturalPlayer extends Player implements MouseListener { public NaturalPlayer(Color color, OverlayComponent overlayComponent) { super(color); this.overlayComponent = overlayComponent; + name = "Player"; moveRequested = false; overlayComponent.addMouseListener(this); diff --git a/src/dev/kske/chess/game/Player.java b/src/dev/kske/chess/game/Player.java index 9e55756..8163532 100644 --- a/src/dev/kske/chess/game/Player.java +++ b/src/dev/kske/chess/game/Player.java @@ -11,9 +11,10 @@ import dev.kske.chess.board.Piece.Color; */ public abstract class Player { - protected Game game; - protected Board board; - protected Color color; + protected Game game; + protected Board board; + protected Color color; + protected String name; public Player(Color color) { this.color = color; @@ -39,4 +40,8 @@ public abstract class Player { public Color getColor() { return color; } public void setColor(Color color) { this.color = color; } + + public String getName() { return name; } + + public void setName(String name) { this.name = name; } } diff --git a/src/dev/kske/chess/game/UCIPlayer.java b/src/dev/kske/chess/game/UCIPlayer.java index edf1a56..5e57a45 100644 --- a/src/dev/kske/chess/game/UCIPlayer.java +++ b/src/dev/kske/chess/game/UCIPlayer.java @@ -19,9 +19,7 @@ import dev.kske.chess.uci.UCIOption; */ public class UCIPlayer extends Player implements UCIListener { - private UCIHandle handle; - - private String name, author; + private UCIHandle handle; private List options; public UCIPlayer(Color color, String enginePath) { @@ -57,11 +55,6 @@ public class UCIPlayer extends Player implements UCIListener { this.name = name; } - @Override - public void onIdAuthor(String author) { - this.author = author; - } - @Override public void onUCIOk() { System.out.println("UCI ok"); diff --git a/src/dev/kske/chess/game/ai/AIPlayer.java b/src/dev/kske/chess/game/ai/AIPlayer.java index 9e1f2fe..0a386a3 100644 --- a/src/dev/kske/chess/game/ai/AIPlayer.java +++ b/src/dev/kske/chess/game/ai/AIPlayer.java @@ -32,6 +32,7 @@ public class AIPlayer extends Player { public AIPlayer(Color color, int maxDepth, int alphaBetaThreshold) { super(color); + name = "AIPlayer"; availableProcessors = Runtime.getRuntime().availableProcessors(); this.maxDepth = maxDepth; this.alphaBetaThreshold = alphaBetaThreshold;