コード例 #1
0
 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)));
     }
 }
コード例 #2
0
 public IList<Bet> BetsByField(Field field)
 {
     if (!betsByFields.ContainsKey(field)) return EMPTY;
     return betsByFields[field];
 }
コード例 #3
0
 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");
 }
コード例 #4
0
        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);
        }
コード例 #5
0
 public void PlaceBet(Player p, Field field, int value)
 {
     PlaceBet(p, new Field[] { field }, value);
 }
コード例 #6
0
 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);
 }
コード例 #7
0
 public bool Equals(Field obj)
 {
     if (ReferenceEquals(null, obj)) return false;
     if (ReferenceEquals(this, obj)) return true;
     return obj.FieldName == this.FieldName;
 }