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 isATurn?algo.getHandsA():algo.getHandsB(); } @Override public List<Map.Entry<Integer, Boolean>> getOpponentHands() { return isATurn?algo.getHandsB():algo.getHandsA(); } @Override public Map.Entry<Integer, Boolean> getTopCard() { if(isDeckLess())return null; return algo.getDeck().get(0); } public boolean isDeckLess(){ return algo.getDeck().size()==0; } public boolean isSucceedLatestAttack(){ return isSucceedLatestAttack; } public boolean getIsATurn(){ return isATurn; } }