From c0825e62c58cd76d3f2b9c34637ee37a21de222a Mon Sep 17 00:00:00 2001 From: Joe Zhao Date: Fri, 5 Dec 2014 20:07:14 +0800 Subject: Restructuring --- player/PlayerActionHandler.java | 23 +++-------------------- player/PlayerActionServer.java | 23 +++++++++++++++++------ 2 files changed, 20 insertions(+), 26 deletions(-) (limited to 'player') diff --git a/player/PlayerActionHandler.java b/player/PlayerActionHandler.java index 05a042c..26ba7e3 100644 --- a/player/PlayerActionHandler.java +++ b/player/PlayerActionHandler.java @@ -6,24 +6,7 @@ import mahjong.engine.Action; /** * Created by joe on 12/4/14. */ -public abstract class PlayerActionHandler { - public Hand hand=new Hand(); - int score; - - protected String name; - - public String getName() { - return name; - } - - public abstract Action stateAlert(Action action); - public abstract void stateUpdate(Action action); - - public void setScore(int score) { - this.score = score; - } - - public int getScore() { - return score; - } +public interface PlayerActionHandler { + public abstract Action stateAlert(Action action); // Player action required or not, state will not change + public abstract void stateUpdate(Action action); // Player action taken, changing state. } diff --git a/player/PlayerActionServer.java b/player/PlayerActionServer.java index 49fcef4..09d2417 100644 --- a/player/PlayerActionServer.java +++ b/player/PlayerActionServer.java @@ -6,21 +6,32 @@ import mahjong.engine.Action; /** * Created by joe on 12/4/14. */ -public abstract class PlayerActionServer { - public Hand hand=new Hand(); + +// TODO Hard to manage relations +public class PlayerActionServer implements PlayerActionHandler { + Hand hand=new Hand(); int score; protected String name; + PlayerActionHandler player; + + PlayerActionServer(PlayerActionHandler player) + { + this.player=player; + } + public String getName() { return name; } - public abstract Action stateAlert(Action action); - public abstract void stateUpdate(Action action); + public Action stateAlert(Action action) + { + return null; + } - public void setScore(int score) { - this.score = score; + public void stateUpdate(Action action) + { } public int getScore() { -- cgit v1.2.3-70-g09d2