public Gamble InitializeBet(String mode, decimal amount, Player p, int choice) { Player foundPlayer = _players.Find(desiredPlayer => p.Equals(desiredPlayer)); if (foundPlayer != null) { Gamble gamble = new Gamble(p); gamble.MakeBet(p, gamble.GetGameMode(mode), amount); _choices.Add(p, choice); return(gamble); } return(null); }
public void PayWinnersAndChargeLosers() { _players.ForEach(player => { Gamble playersBet = _bets.Find(betPlayer => player.Equals(betPlayer)); if (player.IsWinner) { player.AddBalance(playersBet.GetAmountToWin); } else { player.SubtractBalance(playersBet.GetAmountToLose); } }); }
private static void NewBet(Game g, Player p) { WriteLine($"Hey {p.Name} please input your desired amount to bet on: "); decimal amount = Decimal.Parse(ReadLine()); WriteLine($"{p.Name}, please enter the desired number to bet on (from 1 to {g.GetDiceFaces})"); int choice = Int32.Parse(ReadLine()); WriteLine($"{p.Name}, please enter the desired gamemode: (-1/2 Conservative, -2/5 Risky, -4/15 Desperate"); string mode = ReadLine(); Gamble newGamble = g.InitializeBet(mode, amount, p, choice); if (newGamble != null) { WriteLine("Bet sucessfully added."); GetGambleInfo(newGamble); } else { WriteLine("Couldn't process new bet, something bad happened."); } }
private static void GetGambleInfo(Gamble gamble) { WriteLine(gamble.GetGambleInfo()); }