namespace RCS_CalebFontenot { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private int cpuAction; private long cpuRockCount = 0, playerRockCount = 0, cpuScissorsCount = 0, playerScissorsCount = 0, cpuPaperCount = 0, playerPaperCount = 0; private void updateTextBoxes() { // Increment the textboxes! cpuRockCounter.Text = "Rock: " + cpuRockCount.ToString(); playerRockCounter.Text = "Rock: " + playerRockCount.ToString(); cpuPaperCounter.Text = "Paper: " + cpuPaperCount.ToString(); playerPaperCounter.Text = "Paper: " + playerPaperCount.ToString(); cpuScissorsCounter.Text = "Scissors: " + cpuScissorsCount.ToString(); playerScissorsCounter.Text = "Scissors: " + playerScissorsCount.ToString(); } private void winIncrement(string whatToIncrement) { // Increment the variables! switch (whatToIncrement) { case "rockDraw": cpuRockCount++; playerRockCount++; break; case "paperDraw": cpuPaperCount++; playerPaperCount++; break; case "scissorsDraw": cpuScissorsCount++; playerScissorsCount++; break; case "cpuRock": cpuRockCount++; break; case "playerRock": playerRockCount++; break; case "cpuPaper": cpuPaperCount++; break; case "playerPaper": playerPaperCount++; break; case "cpuScissors": cpuScissorsCount++; break; case "playerScissors": playerScissorsCount++; break; } updateTextBoxes(); } private void endGame() { // Disable the interactivity of the images. rockPictureBox.Enabled = false; paperPictureBox.Enabled = false; scissorPictureBox.Enabled = false; // Re-enable the newGameButton. newGameButton.Enabled = true; } private void playRound(int action) { // The action variable determines what we will do. switch (action) { case -1: //The Player is starting the game. Random rng = new Random(); cpuAction = rng.Next(0, 3); statusLabel.Text = "The computer has chosen a move. Please make yours."; // Clear the computer choice image. cpuMove.Visible = false; break; case 0: // The player has chosen rock. switch (cpuAction) { case 0: statusLabel.Text = "The computer has chosen rock. You chose rock as well. It is a draw."; winIncrement("rockDraw"); cpuMove.Visible = true; cpuMove.Image = Properties.Resources.Rock; break; case 1: statusLabel.Text = "The computer chose paper. You chose rock. The computer wins!"; winIncrement("cpuPaper"); cpuMove.Visible = true; cpuMove.Image = Properties.Resources.Paper; break; case 2: statusLabel.Text = "The computer chose scissors. You chose rock. You win!"; winIncrement("playerScissors"); cpuMove.Visible = true; cpuMove.Image = Properties.Resources.Scissors; break; } endGame(); break; case 1: switch (cpuAction) { case 0: statusLabel.Text = "The computer has chosen rock. You chose paper. You win!"; winIncrement("cpuRock"); cpuMove.Visible = true; cpuMove.Image = Properties.Resources.Rock; break; case 1: statusLabel.Text = "The computer chose paper. You chose paper as well. It is a draw."; winIncrement("paperDraw"); cpuMove.Visible = true; cpuMove.Image = Properties.Resources.Paper; break; case 2: statusLabel.Text = "The computer chose scissors. You chose paper. The computer wins!"; winIncrement("cpuScissors"); cpuMove.Image = Properties.Resources.Scissors; cpuMove.Visible = true; break; } endGame(); break; case 2: { switch (cpuAction) { case 0: statusLabel.Text = "The computer has chosen rock. You chose scissors. The computer wins!"; winIncrement("cpuRock"); cpuMove.Image = Properties.Resources.Rock; cpuMove.Visible = true; break; case 1: statusLabel.Text = "The computer chose paper. You chose scissors. You win!"; winIncrement("playerScissors"); cpuMove.Image = Properties.Resources.Paper; cpuMove.Visible = true; break; case 2: statusLabel.Text = "The computer chose scissors. You chose scissors as well. It is a draw."; winIncrement("paperDraw"); cpuMove.Image = Properties.Resources.Scissors; cpuMove.Visible = true; break; } } endGame(); break; } } private void Form1_Load(object sender, EventArgs e) { // Do some stuff on start statusLabel.Text = "Ready. Press 'New Game' to start a game."; // Disable the interactivity of the images. rockPictureBox.Enabled = false; paperPictureBox.Enabled = false; scissorPictureBox.Enabled = false; } private void clearButton_Click(object sender, EventArgs e) { cpuRockCount = 0; playerRockCount = 0; cpuScissorsCount = 0; playerScissorsCount = 0; cpuPaperCount = 0; playerPaperCount = 0; updateTextBoxes(); } private void newGameButton_Click(object sender, EventArgs e) { // Enable the images' interactivity. rockPictureBox.Enabled = true; paperPictureBox.Enabled = true; scissorPictureBox.Enabled = true; // Disable this button. newGameButton.Enabled = false; playRound(-1); } private void rockPictureBox_Click(object sender, EventArgs e) { playRound(0); } private void paperPictureBox_Click(object sender, EventArgs e) { playRound(1); } private void scissorPictureBox_Click(object sender, EventArgs e) { playRound(2); } private void exitButton_Click(object sender, EventArgs e) { this.Close(); } } }