Newer
Older
Algolike / src / main / java / controls / StepScheduler.java
package controls;

import interfaces.IAttack;
import models.Algo;
import views.Constants;

import java.util.List;
import java.util.Map;

public class StepScheduler implements IAttack {
    Algo algo;
    int turnCount=0;
    boolean isATurn;
    boolean isSucceedLatestAttack;
    public StepScheduler(){
        algo = new Algo();
        isATurn=true;
    }

    @Override
    public void Attack(int guess, int attacker, int target) {
        if(isATurn){
            if(isDeckLess()){
                algo.inputSelectA(guess, attacker, target);
                isSucceedLatestAttack = algo.getSucceedSelectA().getKey();
            }else{
                algo.inputDrawA(guess, target);
                isSucceedLatestAttack = algo.getSucceedDrawA().getKey();
            }
        }else {
            if(isDeckLess()){
                algo.inputSelectB(guess, attacker, target);
                isSucceedLatestAttack = algo.getSucceedSelectB().getKey();
            }else{
                algo.inputDrawB(guess, target);
                isSucceedLatestAttack = algo.getSucceedDrawB().getKey();
            }
        }
        turnCount++;

    }

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

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

    @Override
    public Map.Entry<Integer, Boolean> getTopCard() {
        if(isDeckLess())return null;
        return algo.getDeck().get(0);
    }

    public boolean isDeckLess(){
        return algo.getDeck().size()==0;
    }

    @Override
    public int getDeckNumber() {
        return algo.getDeck().size();
    }

    public boolean isSucceedLatestAttack(){
        return isSucceedLatestAttack;
    }

    @Override
    public boolean shiftTurn() {
        isATurn = isATurn?false:true;
        return isATurn;
    }

    public boolean isATurn(){
        return isATurn;
    }
}