Newer
Older
Algolike / src / main / java / models / Deck.java
package models;

import java.util.*;

public class Deck {
	private Map.Entry<Boolean, Integer> succeedDrawB;
	private Map.Entry<Boolean, Integer> succeedDrawA;
	private List<Map.Entry<Integer, Boolean>>  value = new ArrayList<>();
	//added
	public void reset(int num){
		for(int i=0;i<num;i++){
			this.value.add(new AbstractMap.SimpleEntry<>(i,false));
		}
		Collections.shuffle(this.value);
	}
	//added
	public Map.Entry<Integer, Boolean> head(){
		var card=getValue().get(0);
		getValue().remove(getValue().get(0));
		return card;
	}
	public List<Map.Entry<Integer, Boolean>>  getValue() {
		return value;
	}
	public void updateSucceedDrawB(Map.Entry<Boolean, Integer> succeedDrawB) {
		this.succeedDrawB = succeedDrawB;
		value = this.value.subList(1, this.value.size());
	}
	public void updateSucceedDrawA(Map.Entry<Boolean, Integer> succeedDrawA) {
		this.succeedDrawA = succeedDrawA;
		value = this.value.subList(1, this.value.size());
	}
}