package extend.zp;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class RoomCard {
	public List<Integer>	cardList;
	EXRoom					room;

	public RoomCard(EXRoom table) {
		this.cardList = new ArrayList<Integer>();
		this.room = table;
	}

	public void init() {

		this.cardList.clear();

		this.initCard();

		this.shuffle();
	}

	private void initCard() {
		for (int index = 1; index <= 10; index++) {
			for (int index2 = 0; index2 < 4; index2++) {
				this.cardList.add(100 + index);
				this.cardList.add(200 + index);
			}
		}
	}

	private void shuffle() {
		Collections.shuffle(this.cardList);
	}

	public int pop() {

		if (this.cardList.size() == 0) {
			this.room.bankerSeat = this.room.activeSeat;
		}

		int card = this.cardList.remove(0);
		return card;

	}

	public int getCount() {
		return this.cardList.size();
	}
	
	public List<Integer> dealFake() {
		List<Integer> dealCards = new ArrayList<Integer>();
		String cardStr = "209, 205, 103, 106, 206, 202, 203, 101, 210, 101, 110, 104, 208, 108, 108, 110, 206, 110, 107, 207";
		String[] cards = cardStr.split(", ");
		for(String c : cards) {
			Integer card = Integer.valueOf(c);
			dealCards.add(card);
		}
		return dealCards;
	}

	public List<Integer> dealFake1() {
		List<Integer> dealCards = new ArrayList<Integer>();
		//String cardStr = "102, 103, 104, 107, 108, 108, 109, 202, 202, 204, 204, 204, 205, 205, 206, 206, 207, 208, 210";
		String cardStr = "103, 104, 104, 104, 105, 110, 110, 110, 110, 108, 109, 109, 109, 109, 108, 108, 204, 205, 206";
		String[] cards = cardStr.split(", ");
		for(String c : cards) {
			Integer card = Integer.valueOf(c);
			dealCards.add(card);
		}
		return dealCards;
	}
	
	public List<Integer> dealFake2() {
		List<Integer> dealCards = new ArrayList<Integer>();
		String cardStr = "102, 103, 101, 105, 105, 108, 109, 110, 203, 201, 206, 207, 208, 207, 202, 202, 210, 209, 209";
		String[] cards = cardStr.split(", ");
		for(String c : cards) {
			Integer card = Integer.valueOf(c);
			dealCards.add(card);
		}
		return dealCards;
	}
	
	public List<Integer> dealFake3() {
		List<Integer> dealCards = new ArrayList<Integer>();
		String cardStr = "102, 102, 107, 107, 110, 109, 202, 202, 207, 207, 210, 201, 201, 101, 107, 210, 107, 103, 101";
		String[] cards = cardStr.split(", ");
		for(String c : cards) {
			Integer card = Integer.valueOf(c);
			dealCards.add(card);
		}
		return dealCards;
	}

	public List<Integer> deal(int num) {
		List<Integer> dealCards = new ArrayList<Integer>();

		for (int index = 0; index < num; index++) {
			dealCards.add(this.pop());
		}
		return dealCards;

	}
}
