public void PlaceBet(Player p, Field[] fields, int value) { if (CurrentChipsOnTable() + value > maxChipsOnTable) throw new TooManyChipsException(); if (!players.ContainsKey(p) && players.Count == MAX_PLAYERS) throw new TableFullException(); if (!players.ContainsKey(p)) players.Add(p, (Colour)Enum.GetValues(typeof(Colour)).GetValue(players.Count)); foreach (Field field in fields) { if (!betsByFields.ContainsKey(field)) { betsByFields.Add(field, new List<Bet>()); } betsByFields[field].Add(new Bet(p, value, GetBetType(fields))); } }
public IList<Bet> BetsByField(Field field) { if (!betsByFields.ContainsKey(field)) return EMPTY; return betsByFields[field]; }
private BetType GetBetType(Field[] fields) { if (fields.Length == 1) return BetType.SINGLE; if (fields.Length == 2) return BetType.SPLIT; throw new ArgumentException("Unsupported bet type for " + fields + " fields"); }
public void PlaceBet(Player p, Field[] fields, int value) { if (CurrentChipsOnTable() + value > maxChipsOnTable) throw new TooManyChipsException(); if (!players.ContainsKey(p) && players.Count == MAX_PLAYERS) throw new TableFullException(); if (!players.ContainsKey(p)) players.Add(p, (Colour)Enum.GetValues(typeof(Colour)).GetValue(players.Count)); if (IsBallRolling && (timer.TimeInMillis - ballStartedRolling > CUT_OFF_TIME)) throw new NoMoreBetsException(); if (!walletService.IsAvailable(p, value)) throw new NotEnoughChipsException(); walletService.AdjustBalance(p, -1 * value); foreach (Field field in fields) { if (!betsByFields.ContainsKey(field)) { betsByFields.Add(field, new List<Bet>()); } betsByFields[field].Add(new Bet(p, value, GetBetType(fields))); } if (!waitingForPlayersToComplete.Contains(p)) waitingForPlayersToComplete.Add(p); }
public void PlaceBet(Player p, Field field, int value) { PlaceBet(p, new Field[] { field }, value); }
public bool Equals(Field obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; return obj.FieldName == this.FieldName && Equals(this.WinningStrategy,obj.WinningStrategy); }
public bool Equals(Field obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; return obj.FieldName == this.FieldName; }