public void play() { string[] display = new string[5]; int[] moves = new int[numberOfPlayers]; while (!isGameFinished) { for (int i = 0; i < 5; i++) { display[i] = ""; } for (int player = 0; player < numberOfPlayers; player++) { IterationReturn buffer = iteration(player); moves[player] = buffer.move; for (int i = 0; i < 5; i++) { display[i] += buffer.display[i] + " "; } System.Threading.Thread.Sleep(miniPause); } for (int i = 0; i < 5; i++) { Console.WriteLine(display[i]); } Console.WriteLine("\n#" + getWinner(moves) + " won this round"); System.Threading.Thread.Sleep(bigPause); } }
private IterationReturn iteration(int player) { IterationReturn buffer = new IterationReturn(); int times = 0; for (int i = 0; i < numberOfFractions * numberOfTypes; i++) { if (cards[i].owner == player) { times++; } } int targetTimes = random(0, times) + 1; times = 0; for (int i = 0; i < numberOfFractions * numberOfTypes; i++) { if (cards[i].owner == player) { times++; } if (times == targetTimes) { buffer.move = i; break; } } if (buffer.move == -1) { buffer.display[0] = " "; buffer.display[1] = " "; buffer.display[2] = " "; buffer.display[3] = " "; buffer.display[4] = " "; } else { buffer.display[1] += fractionView[cards[buffer.move].fraction] + " |"; buffer.display[2] += cardView[cards[buffer.move].type] + " |"; buffer.display[3] += fractionView[cards[buffer.move].fraction] + "|"; } return(buffer); }