Unfinished
[code language=”csharp”] /*
Mark Hesser
Oct 29, 2017
RPSLV Form App
Rock Paper Scissors Lizard Spock
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace RPSLV_Form_App
{
public partial class RPSLV : Form
{
public RPSLV()
{
InitializeComponent();
}
//Declarations
int computerChoice, playerChoice = 0;
Random randNumber = new Random();
string computerResult = "", gameResult = "", playerResult = "";
bool Quit = false, isPlayable = false, choiceKeyListener = true, quitKeyListener = true;
int playerWins = 0, computerWins = 0;
int playerWinCase = 0, playerCase = 0;
private void btn_playerRock_Click(object sender, EventArgs e)
{
playerChoice = 1; playerResult = "Rock";
process_computerChoice(); process_Choices();
}
private void btn_playerPaper_Click(object sender, EventArgs e)
{
playerChoice = 2; playerResult = "Paper";
process_computerChoice(); process_Choices();
}
private void btn_playerScissors_Click(object sender, EventArgs e)
{
playerChoice = 3; playerResult = "Scissors";
process_computerChoice(); process_Choices();
}
private void btn_playerLizard_Click(object sender, EventArgs e)
{
playerChoice = 4; playerResult = "Lizard";
process_computerChoice(); process_Choices();
}
private void btn_playerSpock_Click(object sender, EventArgs e)
{
playerChoice = 5; playerResult = "Spock";
process_computerChoice(); process_Choices();
}
void process_computerChoice()
{
computerChoice = randNumber.Next(5) + 1;
}
void process_Choices()
{
//Switch that determines the result of the Game
switch (computerChoice)
{
case 1: computerResult = "Rock";
switch (playerChoice)
{
case 1: playerCase = 0; playerWinCase = 0; break;
case 2: playerCase = 2; playerWinCase = 1; break;
case 3: playerCase = 10; playerWinCase = 2; break;
case 4: playerCase = 3; playerWinCase = 2; break;
case 5: playerCase = 9; playerWinCase = 1; break;
default: break;
}
break;
case 2: computerResult = "Paper";
switch (playerChoice)
{
case 1: playerCase = 2; playerWinCase = 2; break;
case 2: playerCase = 0; playerWinCase = 0; break;
case 3: playerCase = 1; playerWinCase = 1; break;
case 4: playerCase = 7; playerWinCase = 1; break;
case 5: playerCase = 8; playerWinCase = 2; break;
default: break;
}
break;
case 3: computerResult = "Scissors";
switch (playerChoice)
{
case 1: playerCase = 10; playerWinCase = 1; break;
case 2: playerCase = 1; playerWinCase = 2; break;
case 3: playerCase = 0; playerWinCase = 0; break;
case 4: playerCase = 6; playerWinCase = 2; break;
case 5: playerCase = 5; playerWinCase = 1; break;
default: break;
}
break;
case 4: computerResult = "Lizard";
switch (playerChoice)
{
case 1: playerCase = 3; playerWinCase = 1; break;
case 2: playerCase = 7; playerWinCase = 2; break;
case 3: playerCase = 6; playerWinCase = 1; break;
case 4: playerCase = 0; playerWinCase = 0; break;
case 5: playerCase = 4; playerWinCase = 2; break;
default: break;
}
break;
case 5: computerResult = "Spock";
switch (playerChoice)
{
case 1: playerCase = 9; playerWinCase = 2; break;
case 2: playerCase = 8; playerWinCase = 1; break;
case 3: playerCase = 5; playerWinCase = 2; break;
case 4: playerCase = 4; playerWinCase = 1; break;
case 5: playerCase = 0; playerWinCase = 0; break;
default: break;
}
break;
default: break;
}
switch (playerCase)
{
case 1: label_gameResult.Text = "Scissors cut Paper"; break;
case 2: label_gameResult.Text = ("Paper covers Rock"); break;
case 3: label_gameResult.Text = ("Rock crushes Lizard"); break;
case 4: label_gameResult.Text = ("Lizard poisons Spock"); break;
case 5: label_gameResult.Text = ("Spock smashes Scissors"); break;
case 6: label_gameResult.Text = ("Scissors decapitate Lizard"); break;
case 7: label_gameResult.Text = ("Lizard eats Paper"); break;
case 8: label_gameResult.Text = ("Paper disproves Spock"); break;
case 9: label_gameResult.Text = ("Spock vaporizes Rock"); break;
case 10: label_gameResult.Text = ("Rock crushes Scissors"); break;
default: label_gameResult.Text = ("It’s a Tie!"); break;
}
switch (playerWinCase)
{
case 1: label_winResult.Text = ("You Win!"); playerWins++; break;
case 2: label_winResult.Text = ("You Lose!"); computerWins++; break;
default: label_winResult.Text = ("Nobody Wins…"); break;
}
update_Win();
makeLabelsVisible();
}
void update_Win()
{
label_PlayerResult.Text = playerResult;
label_ComputerResult.Text = computerResult;
label_Player.Text = "Player " + playerWins;
label_Computer.Text = "Computer " + computerWins;
}
void makeLabelsVisible()
{
label_Computer.Visible = true; label_ComputerResult.Visible = true;
label_Player.Visible = true; label_PlayerResult.Visible = true;
label_winResult.Visible = true; label_gameResult.Visible = true; label_vs.Visible = true;
}
}
}