Newer
Older
Algolike / src / main / java / controls / AbstractGameState.java
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 abstract void attack(int guess, int attacker, int target);

    public List<Map.Entry<Integer, Boolean>> getMyHands() {
        return algo.getHandsA();
    }

    public List<Map.Entry<Integer, Boolean>> getOpponentHands() {
        return algo.getHandsB();
    }

    public Map.Entry<Integer, Boolean> 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();
    }
}