public int PayOut(Greyhound Winner) { //if the dog won, return the amount bet if(Winner == Dog) { return Amount; } //otherwise return the negative of the amount bet else return 0-Amount; }
private void PrepareInitialData() { //players and dogs are ready on track to race and bet dogs[0] = new Greyhound() { dogname = "dog 1", RaceTrackLength = 970, MyPictureBox = picturedog1 }; dogs[1] = new Greyhound() { dogname = "dog 2", RaceTrackLength = 970, MyPictureBox = picturedog2 }; dogs[2] = new Greyhound() { dogname = "dog 3", RaceTrackLength = 970, MyPictureBox = picturedog3 }; dogs[3] = new Greyhound() { dogname = "dog 4", RaceTrackLength = 970, MyPictureBox = picturedog4 }; player[0] = Balance.GetAPlayer(1); player[1] = Balance.GetAPlayer(2); player[2] = Balance.GetAPlayer(3); player[0].MyLabel = lblBets; player[0].MyRadioButton = radioPlayer1; player[0].MyText = txtPlayer1; player[1].MyLabel = lblBets; player[1].MyRadioButton = radioPlayer2; player[1].MyText = txtPlayer2; player[2].MyLabel = lblBets; player[2].MyRadioButton = radioPlayer3; player[2].MyText = txtPlayer3; player[0].MyRadioButton.Text = player[0].Name; player[1].MyRadioButton.Text = player[1].Name; player[2].MyRadioButton.Text = player[2].Name; numericdogNumber.Minimum = 1; numericdogNumber.Maximum = 4; numericdogNumber.Value = 1; }
private void PrepareInitialData() { cars[0] = new Greyhound() { CarName = "Car 1", RaceTrackLength = 970, MyPictureBox = pictureCar1 }; cars[1] = new Greyhound() { CarName = "Car 2", RaceTrackLength = 970, MyPictureBox = pictureCar2 }; cars[2] = new Greyhound() { CarName = "Car 3", RaceTrackLength = 970, MyPictureBox = pictureCar3 }; cars[3] = new Greyhound() { CarName = "Car 4", RaceTrackLength = 970, MyPictureBox = pictureCar4 }; punters[0] = Factory.GetAPunter(1); punters[1] = Factory.GetAPunter(2); punters[2] = Factory.GetAPunter(3); punters[0].MyLabel = lblBets; punters[0].MyRadioButton = radioPunter1; punters[0].MyText = txtPunter1; punters[1].MyLabel = lblBets; punters[1].MyRadioButton = radioPunter2; punters[1].MyText = txtPunter2; punters[2].MyLabel = lblBets; punters[2].MyRadioButton = radioPunter3; punters[2].MyText = txtPunter3; punters[0].MyRadioButton.Text = punters[0].Name; punters[1].MyRadioButton.Text = punters[1].Name; punters[2].MyRadioButton.Text = punters[2].Name; numericCarNumber.Minimum = 1; numericCarNumber.Maximum = 4; numericCarNumber.Value = 1; }
public Bet(Player player, Greyhound greyhound, decimal amount) { Player = player; Greyhound = greyhound; Amount = amount; }
private void Timer_Tick(object sender, EventArgs e) { // timer length set and will display the winner dog if (sender is Timer) { Timer timer = sender as Timer; int index = 0; while (index < timers.Length) { if (timers[index] == timer) { break; } index++; } PictureBox picture = dogs[index].MyPictureBox; if (picture.Location.X + picture.Width > dogs[index].RaceTrackLength) { timer.Stop(); stop++; if (winnerdog == null) { winnerdog = dogs[index]; } } else { int jump = new Random().Next(1, 15); picture.Location = new Point(picture.Location.X + jump, picture.Location.Y); } } if (stop == timers.Length) { // message for the dog who came first MessageBox.Show(winnerdog.dogname + " Finished First!!!"); SetBet(); foreach (Player player in player) { if (player.MyBet != null) { if (player.MyBet.dog == winnerdog) { player.Cash += player.MyBet.Amount; // player amount after winning player.MyText.Text = player.Name + "You Won and total comes to $" + player.Cash; player.Winner = true; } else { player.Cash -= player.MyBet.Amount; if (player.Cash == 0) { player.MyText.Text = "BUSTED"; player.Busted = true; player.MyRadioButton.Enabled = false; } else { // player amount deducation when lost player.MyText.Text = player.Name + " You Lost and remaning with $" + player.Cash; } } } } winnerdog = null; stop = 0; timers = new Timer[4]; btnPlaceBet.Enabled = true; btnStartRace.Enabled = false; int count = 0; foreach (Player player in player) { if (player.Busted) { count++; } if (player.MyRadioButton.Enabled && player.MyRadioButton.Checked) { //enabling the max bet button to it maxlimit lblMaxBet.Text = "Max Bet is $" + player.Cash; } player.MyBet = null; player.Winner = false; } if (count == player.Length) { btnPlaceBet.Enabled = false; btnGameOver.Enabled = true; } foreach (Greyhound dog in dogs) { dog.MyPictureBox.Location = new Point(1, dog.MyPictureBox.Location.Y); } } }
// Bet Mybet = new Bet(); public Form1() { InitializeComponent(); dogsArray[0] = new Greyhound() { MyPictureBox = pictureBox1, Name = "Day Break", RaceTrackLength = racetrackPictureBox.Width - pictureBox1.Width, StartingPosition = pictureBox1.Left, Randomizer = Randomizer, oddsFor = Randomizer.Next(1, 3), oddsAgainst = Randomizer.Next(2, 8) }; dogsArray[1] = new Greyhound() { MyPictureBox = pictureBox2, Name = "Lightning's Revenge", RaceTrackLength = racetrackPictureBox.Width - pictureBox1.Width, StartingPosition = pictureBox2.Left, Randomizer = Randomizer, oddsFor = Randomizer.Next(1, 3), oddsAgainst = Randomizer.Next(2, 14) }; dogsArray[2] = new Greyhound() { MyPictureBox = pictureBox3, Name = "Mytosis", RaceTrackLength = racetrackPictureBox.Width - pictureBox1.Width, StartingPosition = pictureBox3.Left, Randomizer = Randomizer, oddsFor = Randomizer.Next(1, 3), oddsAgainst = Randomizer.Next(2, 12) }; dogsArray[3] = new Greyhound() { MyPictureBox = pictureBox4, Name = "Sleeping Sycamore", RaceTrackLength = racetrackPictureBox.Width - pictureBox1.Width, StartingPosition = pictureBox4.Left, Randomizer = Randomizer, oddsFor = Randomizer.Next(1, 3), oddsAgainst = Randomizer.Next(2, 10) }; guyArray[0] = new Guy() { MyBet = null, Name = "Zack", Cash = 50, MyLabel = lblZack, MyRadioButton = rdbtnZack, MyLabel2 = lblZackBet }; guyArray[1] = new Guy() { MyBet = null, Name = "Nick", Cash = 75, MyLabel = lblNick, MyRadioButton = rdbtnNick, MyLabel2 = lblNickBet }; guyArray[2] = new Guy() { MyBet = null, Name = "Taylor", Cash = 45, MyLabel = lblTaylor, MyRadioButton = rdbtnTaylor, MyLabel2 = lblTaylorBet }; guyArray[0].UpdateLabels(); guyArray[1].UpdateLabels(); guyArray[2].UpdateLabels(); if (dogsArray[0].oddsFor.ToString() == dogsArray[0].oddsAgainst.ToString()) { lblDBOdds.Text = "Even"; } else { lblDBOdds.Text = dogsArray[0].oddsAgainst.ToString() + " : " + dogsArray[0].oddsFor.ToString(); } if (dogsArray[1].oddsFor.ToString() == dogsArray[1].oddsAgainst.ToString()) { LROdds.Text = "Even"; } else { LROdds.Text = dogsArray[1].oddsAgainst.ToString() + " : " + dogsArray[1].oddsFor.ToString(); } if (dogsArray[2].oddsFor.ToString() == dogsArray[2].oddsAgainst.ToString()) { MOdds.Text = "Even"; } else { MOdds.Text = dogsArray[2].oddsAgainst.ToString() + " : " + dogsArray[2].oddsFor.ToString(); } if (dogsArray[3].oddsFor.ToString() == dogsArray[3].oddsAgainst.ToString()) { SSOdds.Text = "Even"; } else { SSOdds.Text = dogsArray[3].oddsAgainst.ToString() + " : " + dogsArray[3].oddsFor.ToString(); } }
private void initializeGreyhounds() { greyhounds = new Greyhound[numOfDogs]; int a = 1; for(int i = allPicBoxes.Length - 1; i >= 0; i--) { if(!allPicBoxes[i].Name.Equals(trackPictureBox.Name)) { greyhounds[i] = new Greyhound(a++, trackPictureBox.Left, trackPictureBox.Right, (PictureBox) allPicBoxes[i], randomizer); } } }
private void Timer_Tick(object sender, EventArgs e) { if (sender is Timer) { Timer timer = sender as Timer; int index = 0; while (index < timers.Length) { if (timers[index] == timer) { break; } index++; } PictureBox picture = cars[index].MyPictureBox; if (picture.Location.X + picture.Width > cars[index].RaceTrackLength) { timer.Stop(); stop++; if (winnerCar == null) { winnerCar = cars[index]; } } else { int jump = new Random().Next(1, 15); picture.Location = new Point(picture.Location.X + jump, picture.Location.Y); } } if (stop == timers.Length) { MessageBox.Show(winnerCar.CarName + " is Won!!!"); SetBet(); foreach (Punter punter in punters) { if (punter.MyBet != null) { if (punter.MyBet.Car == winnerCar) { punter.Cash += punter.MyBet.Amount; punter.MyText.Text = punter.Name + " Won and now has $" + punter.Cash; punter.Winner = true; } else { punter.Cash -= punter.MyBet.Amount; if (punter.Cash == 0) { punter.MyText.Text = "BUSTED"; punter.Busted = true; punter.MyRadioButton.Enabled = false; } else { punter.MyText.Text = punter.Name + " Lost and now has $" + punter.Cash; } } } } winnerCar = null; stop = 0; timers = new Timer[4]; btnPlaceBet.Enabled = true; btnStartRace.Enabled = false; int count = 0; foreach (Punter punter in punters) { if (punter.Busted) { count++; } if (punter.MyRadioButton.Enabled && punter.MyRadioButton.Checked) { lblMaxBet.Text = "Max Bet is $" + punter.Cash; } punter.MyBet = null; punter.Winner = false; } if (count == punters.Length) { btnPlaceBet.Enabled = false; btnGameOver.Enabled = true; } foreach (Greyhound car in cars) { car.MyPictureBox.Location = new Point(1, car.MyPictureBox.Location.Y); } } }
protected void Form1_Load(object sender, EventArgs e) { Greyhound gh = new Greyhound(this); //pass the form as 'this' //then you can call gh.Run() }
public SimEvent(Greyhound greyhound) { m_greyhound = greyhound; }