package controls; import interfaces.IAttack; import resources.Algo; 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 updateTurn() { isATurn = isATurn ? false : true; return isATurn; } public boolean isATurn() { return isATurn; } @Override public boolean isALose() { return algo.getLoseA(); } @Override public boolean isBLose() { return algo.getLoseB(); } }