Newer
Older
Algolike / src / main / java / models / Algo.java
Shinji on 15 Jun 2022 1 KB ・GUIを設置
package models;

import java.util.*;

import static views.Constants.DECK_COUNT;

public class Algo {
	private LoseB loseB;
	private HandsB handsB;
	private LoseA loseA;
	private HandsA handsA;
	private Deck deck;
	int turnCount=0;
	public Algo() {
		loseB = new LoseB();
		handsB = new HandsB(loseB);
		loseA = new LoseA();
		handsA = new HandsA(loseA);
		deck = new Deck();
		deck.reset(DECK_COUNT);
		for(int i=0;i<2;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 drawA(int guess,  int target) {
		var b=getHandsB();
		var d = getDeck();
		this.handsA.drawA(guess, b, d, target);
		this.handsB.drawA(guess, b, d, target);
		this.deck.drawA(guess, b, d, target);
	}
	public void selectA(int guess, int attacker, int target) {
		var b=getHandsB();
		this.handsA.selectA(guess, attacker, b, target);
		this.handsB.selectA(guess, attacker, b, target);
	}
	public void drawB(int guess,  int target) {
		var a=getHandsA();
		var d = getDeck();

		this.handsB.drawB(guess, a, d, target);
		this.handsA.drawB(guess, a, d, target);
		this.deck.drawB(guess, a, d, target);
	}
	public void selectB(int guess, int attacker, int target) {
		var a=getHandsA();
		this.handsB.selectB(guess, attacker, a, target);
		this.handsA.selectB(guess, attacker, a, target);
	}
	private void countUpTurn(){
		turnCount++;
	}
	public List<Map.Entry<Integer, Boolean>> getDeck() {
		return deck.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();
	}
}