
public class Pisti {
	private static int NPLAYERS = 2;
	private static int NROUNDS = 10;

	public static void main (String[] args) {
		
		int turn = 0; // inidcates which player's turn it is
		Card1 topCard = null; // null means no card on top yet
		int nCardsOnDesk = 0;
		int scoreOnDesk = 0; // total score of cards on desk
		int score0 = 0; 
		int score1 = 0; 
		
		int round = 0;
		while (round < NROUNDS)
		{
			// create a random card for next player
			Card1 nextCard = new Card1();
			System.out.println("Player " + turn + " plays : " + nextCard);
			
			// can this card capture the cards on desk?
			if (nCardsOnDesk > 0 && (nextCard.isJack () || nextCard.sameFace (topCard)))
			{
				if (nCardsOnDesk == 1 && nextCard.sameFace (topCard)) {
					// pisti situation
					scoreOnDesk += 9;
				}
				else {
					scoreOnDesk += nextCard.getScore ();
				}
				if (turn == 0)
					score0 += scoreOnDesk;
				else
					score1 += scoreOnDesk;
				System.out.println("Player " + turn + " takes the cards. Scores : " + score0 + " / " + score1 + "\n");
				nCardsOnDesk = 0;
				scoreOnDesk = 0;
				topCard = null;
			}
			else {
				// nothing special, just put the card on desk
				nCardsOnDesk++;
				topCard = nextCard;
				scoreOnDesk += nextCard.getScore ();
			}
			
			if (turn == NPLAYERS - 1)
				round++;
			turn = (turn + 1) % NPLAYERS;
		}
		
		
	}
	
}

