aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/Applications/ShiftLotto.cs
diff options
context:
space:
mode:
authorAShifter <[email protected]>2017-03-07 19:36:16 -0700
committerAShifter <[email protected]>2017-03-07 19:36:16 -0700
commited26b419631065bd743598a249d58589d2eda646 (patch)
tree992afa85bd9e1f49525bcd4d2425db854f286b67 /ShiftOS.WinForms/Applications/ShiftLotto.cs
parent1c0c7c6fa8cbc2c20f4a25457b934c61ffe4ec43 (diff)
downloadshiftos_thereturn-ed26b419631065bd743598a249d58589d2eda646.tar.gz
shiftos_thereturn-ed26b419631065bd743598a249d58589d2eda646.tar.bz2
shiftos_thereturn-ed26b419631065bd743598a249d58589d2eda646.zip
Fixed ShiftLotto
Fixed a bug in ShiftLotto where the amount of codepoints you had wasn't actually checked. This lead to me having -6732946923443264 Codepoints. Oops.
Diffstat (limited to 'ShiftOS.WinForms/Applications/ShiftLotto.cs')
-rw-r--r--ShiftOS.WinForms/Applications/ShiftLotto.cs64
1 files changed, 39 insertions, 25 deletions
diff --git a/ShiftOS.WinForms/Applications/ShiftLotto.cs b/ShiftOS.WinForms/Applications/ShiftLotto.cs
index a070d43..cc38582 100644
--- a/ShiftOS.WinForms/Applications/ShiftLotto.cs
+++ b/ShiftOS.WinForms/Applications/ShiftLotto.cs
@@ -76,41 +76,55 @@ namespace ShiftOS.WinForms.Applications
private void button1_Click(object sender, EventArgs e)
{
- // Convert the NumericUpDown to Int
+ // Make codePoints and difficulty in this function
int codePoints = Convert.ToInt32(Math.Round(cpUpDown.Value, 0));
int difficulty = Convert.ToInt32(Math.Round(difUpDown.Value, 0));
- // Create Random Ints
- Random rnd = new Random();
+ if (SaveSystem.CurrentSave.Codepoints <= 1)
+ {
+ Infobox.Show("Not enough Codepoints", "You do not have enough Codepoints to use ShiftLotto!");
+ }
+ else
+ {
+ if (SaveSystem.CurrentSave.Codepoints - (codePoints * difficulty) <= 0)
+ {
+ Infobox.Show("Not enough Codepoints", "You do not have enough Codepoints to gamble this amount!");
+ }
+ else
+ {
+ // Create Random Ints
+ Random rnd = new Random();
- // Set their highest possible number to Difficulty
- int guessedNumber = rnd.Next(0, difficulty);
- int winningNumber = rnd.Next(0, difficulty);
+ // Set their highest possible number to Difficulty
+ int guessedNumber = rnd.Next(0, difficulty);
+ int winningNumber = rnd.Next(0, difficulty);
- // Multiply CodePoints * Difficulty
- int jackpot = codePoints * difficulty;
+ // Multiply CodePoints * Difficulty
+ int jackpot = codePoints * difficulty;
- // Test the random ints
- if (guessedNumber == winningNumber)
- {
- // If you win
+ // Test the random ints
+ if (guessedNumber == winningNumber)
+ {
+ // If you win
- // Add Codepoints
- SaveSystem.TransferCodepointsFrom("shiftlotto", jackpot);
+ // Add Codepoints
+ SaveSystem.TransferCodepointsFrom("shiftlotto", jackpot);
- // Infobox
- Infobox.Show("YOU WON!", "Good Job! " + jackpot.ToString() + " CP has been added to your account. ");
- }
- else
- {
- // If you fail
+ // Infobox
+ Infobox.Show("YOU WON!", "Good Job! " + jackpot.ToString() + " CP has been added to your account. ");
+ }
+ else
+ {
+ // If you fail
- // Remove Codepoints
- SaveSystem.TransferCodepointsToVoid(jackpot);
+ // Remove Codepoints
+ SaveSystem.TransferCodepointsToVoid(jackpot);
- // Infobox
- Infobox.Show("YOU FAILED!", "Sorry! " + jackpot.ToString() + " CP has been removed from your account.");
- }
+ // Infobox
+ Infobox.Show("YOU FAILED!", "Sorry! " + jackpot.ToString() + " CP has been removed from your account.");
+ }
+ }
+ }
}
}
} \ No newline at end of file