Skip to content

Instantly share code, notes, and snippets.

/Form1.cs Secret

Created December 14, 2012 01:20
Show Gist options
  • Save anonymous/251d14af71735db798c1 to your computer and use it in GitHub Desktop.
Save anonymous/251d14af71735db798c1 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
decimal Cash;
public void UpdateForm()
{
label5.Text = Cash.ToString();
}
public Form1()
{
InitializeComponent();
Cash = 100;
}
public void button1_Click(object sender, EventArgs e) //button1 = the "Bet" button
{
Random number = new Random();
int randomNumber;
randomNumber = number.Next(1, 10);
label5.Text = randomNumber.ToString();
label2.Text = Cash.ToString();
label6.Visible = false;
if (numericUpDown2.Value > Cash) //numericUpDown2 = the amount you bet
{
numericUpDown2.Value = numericUpDown2.Value = 0;
MessageBox.Show(" You can't bet more cash than you currently have!\nPress OK to bet again!\n");
}
label5.Text = randomNumber.ToString(); //label5 = the randomly generated number
label2.Text = Cash.ToString(); //label2 = the amount of cash you have
if (randomNumber == numericUpDown1.Value) //numericUpDown1 = what number you bet the generated number (randomNumber) is going to be
{
if (pictureBox1.Visible == true) //pictureBox1 = George, that damned monkey
{
label6.Visible = true; //label6 = what George says
label6.Text = " Jackpot!\n/ Glad I'm here?";
Cash = Cash + numericUpDown2.Value + (numericUpDown2.Value * 25);
MessageBox.Show("You won: $" + (numericUpDown2.Value * 25) + "!");
}
else
{
Cash = Cash + numericUpDown2.Value + (numericUpDown2.Value * 25);
MessageBox.Show("You won: $" + (numericUpDown2.Value * 25) + "!");
}
}
label5.Text = randomNumber.ToString();
label2.Text = Cash.ToString();
if ((randomNumber * 2) == numericUpDown1.Value || (randomNumber / 2) == numericUpDown1.Value)
{
if (pictureBox1.Visible == true)
{
label6.Visible = true;
label6.Text = " Nice job, buddy!\n/";
Cash = Cash + numericUpDown2.Value + (numericUpDown2.Value * 5);
MessageBox.Show("You won: $" + (numericUpDown2.Value * 5) + "!");
}
else
{
Cash = Cash + numericUpDown2.Value + (numericUpDown2.Value * 5);
MessageBox.Show("You won: $" + (numericUpDown2.Value * 5) + "!");
}
}
label5.Text = randomNumber.ToString();
label2.Text = Cash.ToString();
if (randomNumber == numericUpDown1.Value + 1 || randomNumber == numericUpDown1.Value - 1)
{
if (pictureBox1.Visible == true)
{
label6.Visible = true;
label6.Text = " Whoo! You go!\n/";
Cash = Cash + numericUpDown2.Value + (numericUpDown2.Value * 3);
MessageBox.Show("You won: $" + (numericUpDown2.Value * 3) + "!");
}
else
{
Cash = Cash + numericUpDown2.Value + (numericUpDown2.Value * 3);
MessageBox.Show("You won: $" + (numericUpDown2.Value * 3) + "!");
}
}
label5.Text = randomNumber.ToString();
label2.Text = Cash.ToString();
if (randomNumber == 10 || randomNumber == 20 || randomNumber == 30 || randomNumber == 40 ||
randomNumber == 50)
{
if (pictureBox1.Visible == true)
{
label6.Visible = true;
label6.Text = " Nice, bro!\n/";
Cash = Cash + numericUpDown2.Value + (numericUpDown2.Value * 2);
MessageBox.Show("You won: $" + (numericUpDown2.Value * 2) + "!");
}
else
{
Cash = Cash + numericUpDown2.Value + (numericUpDown2.Value * 2);
MessageBox.Show("You won: $" + (numericUpDown2.Value * 2) + "!");
}
}
label5.Text = randomNumber.ToString();
label2.Text = Cash.ToString();
UpdateForm();
if (numericUpDown1.Value != randomNumber || numericUpDown1.Value != randomNumber - 1 ||
numericUpDown1.Value != randomNumber + 1 || numericUpDown1.Value != 10
|| numericUpDown1.Value != 20 || numericUpDown1.Value != 30 || numericUpDown1.Value != 40
|| numericUpDown1.Value != 50 || numericUpDown1.Value != randomNumber * 2
|| numericUpDown1.Value != randomNumber / 2)
{
if (pictureBox1.Visible == true)
{
label6.Visible = true;
label6.Text = " Bummer, dude!\n/";
Cash = Cash - (numericUpDown2.Value);
}
else
{
Cash = Cash - (numericUpDown2.Value);
}
}
label5.Text = randomNumber.ToString();
label2.Text = Cash.ToString();
if (Cash <= 0)
{
MessageBox.Show("You lost!\nPress Play Again to play again!");
button2.Visible = true;
}
label5.Text = randomNumber.ToString();
label2.Text = Cash.ToString();
if (Cash >= 500)
{
button4.Visible = true; //button4 = the button which summons George
}
label5.Text = randomNumber.ToString();
label2.Text = Cash.ToString();
if (pictureBox1.Visible == true)
{
button4.Visible = false;
}
label5.Text = randomNumber.ToString();
label2.Text = Cash.ToString();
}
private void button2_Click(object sender, EventArgs e) //button2 = play again button
{
button2.Visible = false;
Cash = 100;
label2.Text = Cash.ToString();
}
private void button3_Click(object sender, EventArgs e) //button3 = instructions
{
MessageBox.Show("A number between 1 and 50 will be randomly generated. You can bet any amount of cash on whichever number you think it's going to be. If the number you bet on is the exact number generated, you will win what you bet times 25. If the number generated divided by two or multiplied by two is the number you bet on, you win what you bet times five. If the number you bet on is the number next or previous to the generated number, you win what you bet times three. Additionally, if the number generated is either 10, 20, 30, 40 or 50, you win what you bet times two. \n\nAlso, if your cash exceeds 1000, you can get accompanied by the Tiki-Gamble-Monkey George, who might just increase your luck.");
}
private void button4_Click(object sender, EventArgs e) //button4 = the button used to summon George
{
button4.Visible = false;
pictureBox1.Visible = true;
label6.Visible = true;
label6.Text = " Let's gamble!\n/";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment