private void undoButton_Click(object sender, EventArgs e) { RoundModel round = new RoundModel(); int index = AllRounds.Count - 2; if (index > 0) { round = AllRounds[index]; } if (AllRounds.Count > 0) { NumberLogic.UndoNumberProperties(AllRounds.Last().WinningNumber, this); } DisplayCurrentRound(round); ReverseTextboxes(); if (AllRounds.Count > 0) { AllRounds.RemoveAt(AllRounds.Count - 1); } }
private void NumberButton_Click(object sender, EventArgs e) { Button button = (Button)sender; byte digit = byte.Parse(button.Text); RoundModel round = new RoundModel(); round.Spin = AllRounds.Count() + 1; round = UserInputHelper.EnterNumber(digit, round, this, sessionStartForm); AllRounds.Add(round); NumberLogic.UpdateNumberProperties(digit, this); UserInputHelper.CheckIfUserHasWon(round, CurrentUser, this, userWonForm); CascadeTextboxes(); DisplayCurrentRound(round); tickSound.Play(); }
private void inputTextBox_KeyDown(object sender, KeyEventArgs e) { RoundModel round = new RoundModel(); round.Spin = AllRounds.Count() + 1; if (e.KeyCode == Keys.Enter) { if (InputValueAllowed()) { byte currentNumber = byte.Parse(inputTextBox.Text); foreach (NumberModel number in AllRouletteNumbers) { if (currentNumber == number.Digit) { round = UserInputHelper.EnterNumber(currentNumber, round, this, sessionStartForm); } } AllRounds.Add(round); NumberLogic.UpdateNumberProperties(currentNumber, this); UserInputHelper.CheckIfUserHasWon(round, CurrentUser, this, userWonForm); } inputTextBox.Clear(); CascadeTextboxes(); DisplayCurrentRound(round); tickSound.Play(); } }
private void NumberButton_Click(object sender, EventArgs e) { Button button = (Button)sender; int digit = int.Parse(button.Content.ToString()); Round round = new Round(); round.Spin = AllRounds.Count() + 1; round = UserInputHandler.EnterNumber(digit, round, this); AllRounds.Add(round); NumberLogic.UpdateNumberProperties(digit, this); UserInputHandler.CheckIfUserHasWon(round, this); CascadeTextboxes(); DisplayCurrentRound(round); tickSound.Play(); }
private void InputTextBox_KeyDown(object sender, KeyEventArgs e) { Round round = new Round(); round.Spin = AllRounds.Count() + 1; if (e.Key == Key.Enter) { if (InputValueAllowed()) { byte currentNumber = byte.Parse(InputTextBox.Text); foreach (Number number in AllRouletteNumbers) { if (currentNumber == number.Digit) { round = UserInputHandler.EnterNumber(currentNumber, round, this); } } AllRounds.Add(round); NumberLogic.UpdateNumberProperties(currentNumber, this); UserInputHandler.CheckIfUserHasWon(round, this); } InputTextBox.Clear(); CascadeTextboxes(); DisplayCurrentRound(round); tickSound.Play(); } }
public static RoundModel EnterNumber(byte digit, RoundModel round, IRouletteSession rouletteSessionForm, ISessionStart sessionStartForm) { round.WinningNumber = digit; round.CalibrateBetUnit(round.Spin, rouletteSessionForm, sessionStartForm, digit); round.CalibrateMoney(digit, rouletteSessionForm); round.ExpectedNumbers = NumberLogic.GetExpectedNumbers(rouletteSessionForm, round); return(round); }
private void resetButton_Click(object sender, EventArgs e) { NumberLogic.ResetProgress(this); ResetUI(); }
public static RoundModel CalibrateBetUnit(this RoundModel round, int spin, IRouletteSession rouletteSess, ISessionStart sessionStart, byte winningNumber) { if (round.Spin == rouletteSess.SessionStart) { sessionStart = new SessionStartForm(); sessionStart.ShowDialog(); rouletteSess.StartingMoney = sessionStart.StartMoney; rouletteSess.StartingBetUnit = sessionStart.BetUnit; rouletteSess.Goal = rouletteSess.StartingMoney + rouletteSess.StartingBetUnit * 50; round.Money = rouletteSess.StartingMoney; round.BetUnit = rouletteSess.StartingBetUnit; } if (round.Spin >= rouletteSess.SessionStart) { if (rouletteSess.AllRounds.Last().Money > 0) { round.Money = rouletteSess.AllRounds.Last().Money; } else { round.Money = rouletteSess.StartingMoney; } if (rouletteSess.AllRounds.Last().BetUnit > 0) { round.BetUnit = rouletteSess.AllRounds.Last().BetUnit; } else { round.BetUnit = rouletteSess.StartingBetUnit; } CalibrateMoney(round, winningNumber, rouletteSess); decimal playingCost = NumberLogic.GetExpectedNumbers(rouletteSess, round).Count *round.BetUnit; if (round.Money - playingCost >= rouletteSess.StartingMoney - (rouletteSess.StartingBetUnit * 50)) { round.BetUnit = rouletteSess.StartingBetUnit; } if (round.Money - playingCost <= rouletteSess.StartingMoney - (rouletteSess.StartingBetUnit * 50)) { round.BetUnit = rouletteSess.StartingBetUnit * 2; } if (round.Money - playingCost <= rouletteSess.StartingMoney - (rouletteSess.StartingBetUnit * 150) && round.Money > rouletteSess.StartingMoney - (rouletteSess.StartingBetUnit * 350)) { round.BetUnit = rouletteSess.StartingBetUnit * 4; } if (round.Money - playingCost <= rouletteSess.StartingMoney - (rouletteSess.StartingBetUnit * 350) && round.Money > rouletteSess.StartingMoney - (rouletteSess.StartingBetUnit * 750)) { round.BetUnit = rouletteSess.StartingBetUnit * 8; } if (round.Money - playingCost <= rouletteSess.StartingMoney - (rouletteSess.StartingBetUnit * 750)) { round.BetUnit = rouletteSess.StartingBetUnit * 16; } } return(round); }
private void RestartButton_Click(object sender, System.Windows.RoutedEventArgs e) { NumberLogic.ResetProgress(this); ResetUI(); }