package resources; import java.util.Comparator; import java.util.List; import java.util.Map; import static views.Constants.DECK_COUNT; import static views.Constants.HAND_COUNT; public class Algo { private LoseB loseB; private HandsB handsB; private LoseA loseA; private HandsA handsA; private Deck deck; private SucceedDrawA succeedDrawA; private SucceedDrawB succeedDrawB; private SucceedSelectA succeedSelectA; private SucceedSelectB succeedSelectB; int turnCount = 0; boolean isATurn; public Algo() { ///モデル生成分 loseB = new LoseB(); handsB = new HandsB(loseB); loseA = new LoseA(); handsA = new HandsA(loseA); deck = new Deck(); succeedDrawA = new SucceedDrawA(handsB, deck, handsA); succeedDrawB = new SucceedDrawB(deck, handsB, handsA); succeedSelectA = new SucceedSelectA(handsB, handsA); succeedSelectB = new SucceedSelectB(handsA, handsB); //追加分 isATurn = true; deck.init(DECK_COUNT); } public void inputSelectA(int guess, int attacker, int target) { this.succeedSelectA.inputSelectA(guess, attacker, target); } public void inputDrawA(int guess, int target) { this.succeedDrawA.inputDrawA(guess, target); } public void inputDrawB(int guess, int target) { this.succeedDrawB.inputDrawB(guess, target); } public void inputSelectB(int guess, int attacker, int target) { this.succeedSelectB.inputSelectB(guess, attacker, target); } public Map.Entry<Boolean, Map.Entry<Integer, Integer>> getSucceedSelectB() { return succeedSelectB.getValue(); } public Map.Entry<Boolean, Map.Entry<Integer, Integer>> getSucceedSelectA() { return succeedSelectA.getValue(); } public List<Map.Entry<Integer, Boolean>> getDeck() { return deck.getValue(); } public Map.Entry<Boolean, Integer> getSucceedDrawB() { return succeedDrawB.getValue(); } public boolean getLoseA() { return loseA.getValue(); } public boolean getLoseB() { return loseB.getValue(); } public List<Map.Entry<Integer, Boolean>> getHandsB() { return handsB.getValue(); } public List<Map.Entry<Integer, Boolean>> getHandsA() { return handsA.getValue(); } public Map.Entry<Boolean, Integer> getSucceedDrawA() { return succeedDrawA.getValue(); } //追加分 /** * 各プレイヤーに手札を配るメソッド */ public void distributeHands(){ for (int i = 0; i < HAND_COUNT; i++) { handsA.getValue().add(deck.head()); handsB.getValue().add(deck.head()); } getHandsA().sort(Comparator.comparing(Map.Entry<Integer, Boolean>::getKey)); getHandsB().sort(Comparator.comparing(Map.Entry<Integer, Boolean>::getKey)); } public void setDeck(int... param){ deck.setValue(param); } public boolean isATurn() { return isATurn; } public void updateTurn() { isATurn = !isATurn; } }