diff --git a/src/main/java/controls/AbstractGameState.java b/src/main/java/controls/AbstractGameState.java new file mode 100644 index 0000000..0de21e9 --- /dev/null +++ b/src/main/java/controls/AbstractGameState.java @@ -0,0 +1,55 @@ +package controls; + +import resources.Algo; + +import java.util.List; +import java.util.Map; + +public abstract class AbstractGameState { + Algo algo; + static boolean isATurn; + boolean isSucceedLatestAttack; + public AbstractGameState(Algo algo){ + this.algo = algo; + isATurn=algo.isATurn(); + } + public void setTurn(){} + public abstract void attack(int guess, int attacker, int target); + public List> getMyHands() { + return algo.getHandsA(); + } + + public List> getOpponentHands() { + return algo.getHandsB(); + } + + public Map.Entry getTopCard() { + if (isDeckLess()) return null; + return algo.getDeck().get(0); + } + public void updateTurn() { + algo.updateTurn(); + isATurn= algo.isATurn(); + } + public boolean isATurn() { + return isATurn; + } + public boolean isDeckLess() { + return algo.getDeck().size() == 0; + } + public boolean isSucceedLatestAttack() { + return isSucceedLatestAttack; + } + + public int getDeckNumber() { + return algo.getDeck().size(); + } + + public boolean isALose() { + return algo.getLoseA(); + } + + public boolean isBLose() { + return algo.getLoseB(); + } +}