Пример #1
0
        private void ConvertToChips(decimal value)
        {
            Chips.Clear();

            if (value == 0)
            {
                return;
            }

            foreach (var key in ChipRates.Keys.Reverse())
            {
                int chipAmount = (int)(value / key);
                if (chipAmount > 0)
                {
                    Chips.Add(new ChipModel()
                    {
                        ChipColor = ChipRates[key], Count = chipAmount
                    });
                    value %= key;

                    if (value == 0)
                    {
                        break;
                    }
                }
            }
        }
Пример #2
0
        public void UpdateMovePreview(int column)
        {
            if (Game.Finished || GetCurrentPlayerType == PlayerType.Computer)
            {
                return;
            }

            var row = GetEmptyRowIndex(column);

            if (row == -1)
            {
                return;
            }

            if (Preview == null)
            {
                Preview = new ChipViewModel();
                Chips.Add(Preview);
            }

            var previewChip = Preview.Chip;

            previewChip.Column = column;
            previewChip.Row    = row;
            previewChip.Player = Game.CurrentPlayer;
        }
 public Builder AddChips(IEnumerable <ChipModel> models)
 {
     foreach (ChipModel model in models)
     {
         Chips.Add(model);
     }
     return(this);
 }
Пример #4
0
 protected int AddChip(Chip chip)
 {
     Chips.Add(chip);
     if (!WireDict.ContainsKey(chip.ID))
     {
         WireDict.Add(chip.ID, new List <Wire>());
     }
     return(Chips.Count - 1);
 }
Пример #5
0
            public void Give(ref Bot low, ref Bot high)
            {
                low.Assign(Chips.First());
                high.Assign(Chips.Last());

                Chips.Clear();
                Chips.Add(int.MaxValue);
                Chips.Add(int.MaxValue);
            }
    public void newTournament()
    {
        int amountToStart = 100000;

        foreach (PlayerImplementation player in playersImplementation.players)
        {
            Chips.Add(player.Id, 100000);
            ExecuteEvents.Execute <PlayerHandler> (player.PlayerInstance.gameObject, null, (x, y) => x.editChipsText(amountToStart));
        }
    }
Пример #7
0
 protected Chip AddChipIndexed(Chip chip)
 {
     Chips.Add(chip);
     if (!WireDict.ContainsKey(chip.ID))
     {
         WireDict.Add(chip.ID, new List <Wire>());
     }
     chip.index = Chips.Count - 1;
     return(chip);
 }
Пример #8
0
        /// <summary>
        /// Perform a move for the <see cref="Game.CurrentPlayer"/>
        /// </summary>
        /// <param name="column">Index between 0 (inclusive) and <see cref="Game.COLUMNS"/>(exlusive)</param>
        private void DoMove(int column)
        {
            if (Game.Finished)
            {
                return;
            }

            var row = GetEmptyRowIndex(column);

            if (row == -1)
            {
                return;
            }

            Game.Board[column, row] = Game.CurrentPlayer;

            if (Preview == null)
            {
                Preview = new ChipViewModel();
                Chips.Add(Preview);
            }

            var chip = Preview.Chip;

            chip.Row    = row;
            chip.Column = column;
            chip.Player = Game.CurrentPlayer;

            if (HasCurrentPlayerWon())
            {
                Game.Finished = true;
                return;
            }

            Preview = null;
            Game.Turn++;

            // Immediately perform the move for the AI
            if (GetCurrentPlayerType == PlayerType.Computer)
            {
                // Determine best move
                var rand = new Random();
                var col  = rand.Next(0, COLUMNS);

                DoMove(col);
            }
        }
Пример #9
0
        public Board(Board board)
        {
            this.Size               = board.Size;
            this.BlackHole          = new Chip(board.BlackHole);
            this.WinnerPlayerIdList = new List <int>();

            foreach (int id in board.WinnerPlayerIdList)
            {
                WinnerPlayerIdList.Add(id);
            }

            this.Chips = new List <List <Chip> >();

            for (int i = 0; i < board.Chips.Count; i++)
            {
                Chips.Add(new List <Chip>());

                for (int j = 0; j < board.Chips[i].Count; j++)
                {
                    Chips[i].Add(board.Chips[i][j] == null ? null : new Chip(board.Chips[i][j]));
                }
            }
        }
Пример #10
0
 protected int AddChip(Chip chip)
 {
     Chips.Add(chip);
     return(Chips.Count - 1);
 }
Пример #11
0
 public virtual void Receive(int x)
 {
     Chips.Add(x);
 }
 public Builder AddChip(ChipModel model)
 {
     Chips.Add(model);
     return(this);
 }
Пример #13
0
 public Assembly WithMatchingChipAndGenerator(Element element)
 {
     Chips.Add(element);
     Generators.Add(element);
     return(this);
 }
Пример #14
0
 public Assembly WithChip(Element chip)
 {
     Chips.Add(chip);
     return(this);
 }
Пример #15
0
 //Adding the chips
 public void AddChip(Chip c)
 {
     Chips.Add(c);
 }
Пример #16
0
        /// <summary>
        /// The CombineChips method is called to clean up the stack of chips.
        /// Collection of smaller value chips are combined into larger value chips.
        /// </summary>
        public void CombineChips()
        {
            Chips.Clear();  // Clear the current stack of chips.

            int quotient  = BetAmount / Chip.GetChipValue(ChipType.FiveHundredThousand);
            int remainder = BetAmount % Chip.GetChipValue(ChipType.FiveHundredThousand);

            if (quotient > 0)
            {
                for (int i = 0; i < quotient; i++)
                {
                    Chips.Add(new FiveHundredThousand(Chips.Count));
                }
            }

            quotient  = remainder / Chip.GetChipValue(ChipType.OneHundredThousand);
            remainder = remainder % Chip.GetChipValue(ChipType.OneHundredThousand);
            if (quotient > 0)
            {
                for (int i = 0; i < quotient; i++)
                {
                    Chips.Add(new OneHundredThousand(Chips.Count));
                }
            }

            quotient  = remainder / Chip.GetChipValue(ChipType.TwentyFiveThousand);
            remainder = remainder % Chip.GetChipValue(ChipType.TwentyFiveThousand);
            if (quotient > 0)
            {
                for (int i = 0; i < quotient; i++)
                {
                    Chips.Add(new TwentyFiveThousand(Chips.Count));
                }
            }

            quotient  = remainder / Chip.GetChipValue(ChipType.FiveThousand);
            remainder = remainder % Chip.GetChipValue(ChipType.FiveThousand);
            if (quotient > 0)
            {
                for (int i = 0; i < quotient; i++)
                {
                    Chips.Add(new FiveThousand(Chips.Count));
                }
            }

            quotient  = remainder / Chip.GetChipValue(ChipType.OneThousand);
            remainder = remainder % Chip.GetChipValue(ChipType.OneThousand);
            if (quotient > 0)
            {
                for (int i = 0; i < quotient; i++)
                {
                    Chips.Add(new OneThousand(Chips.Count));
                }
            }

            quotient  = remainder / Chip.GetChipValue(ChipType.FiveHundred);
            remainder = remainder % Chip.GetChipValue(ChipType.FiveHundred);
            if (quotient > 0)
            {
                for (int i = 0; i < quotient; i++)
                {
                    Chips.Add(new FiveHundred(Chips.Count));
                }
            }

            quotient  = remainder / Chip.GetChipValue(ChipType.OneHundred);
            remainder = remainder % Chip.GetChipValue(ChipType.OneHundred);
            if (quotient > 0)
            {
                for (int i = 0; i < quotient; i++)
                {
                    Chips.Add(new OneHundred(Chips.Count));
                }
            }

            quotient  = remainder / Chip.GetChipValue(ChipType.TwentyFive);
            remainder = remainder % Chip.GetChipValue(ChipType.TwentyFive);
            if (quotient > 0)
            {
                for (int i = 0; i < quotient; i++)
                {
                    Chips.Add(new TwentyFive(Chips.Count));
                }
            }

            quotient  = remainder / Chip.GetChipValue(ChipType.Five);
            remainder = remainder % Chip.GetChipValue(ChipType.Five);
            if (quotient > 0)
            {
                for (int i = 0; i < quotient; i++)
                {
                    Chips.Add(new Five(Chips.Count));
                }
            }

            quotient  = remainder / Chip.GetChipValue(ChipType.One);
            remainder = remainder % Chip.GetChipValue(ChipType.One);
            if (quotient > 0)
            {
                for (int i = 0; i < quotient; i++)
                {
                    Chips.Add(new One(Chips.Count));
                }
            }
        }
Пример #17
0
        /// <summary>
        /// The PlaceBet method is called to place a bet for the current selected chip.
        /// </summary>
        public void PlaceBet()
        {
            try
            {
                if (PlaceBets && SelectedChip != ChipType.Undefined)
                {
                    BetAmount = BetAmount + Chip.GetChipValue(SelectedChip);

                    // Create a chip at the bet location.
                    Chip chip = null;
                    switch (Bet.SelectedChip)
                    {
                    case ChipType.One:
                        chip = new One(Chips.Count());
                        break;

                    case ChipType.Five:
                        chip = new Five(Chips.Count());
                        break;

                    case ChipType.TwentyFive:
                        chip = new TwentyFive(Chips.Count());
                        break;

                    case ChipType.OneHundred:
                        chip = new OneHundred(Chips.Count());
                        break;

                    case ChipType.FiveHundred:
                        chip = new FiveHundred(Chips.Count());
                        break;

                    case ChipType.OneThousand:
                        chip = new OneThousand(Chips.Count());
                        break;

                    case ChipType.FiveThousand:
                        chip = new FiveThousand(Chips.Count());
                        break;

                    case ChipType.TwentyFiveThousand:
                        chip = new TwentyFiveThousand(Chips.Count());
                        break;

                    case ChipType.OneHundredThousand:
                        chip = new OneHundredThousand(Chips.Count());
                        break;

                    case ChipType.FiveHundredThousand:
                        chip = new FiveHundredThousand(Chips.Count());
                        break;
                    }

                    if (chip != null)
                    {
                        OnBetPlaced?.Invoke(chip.Value);    // Notify that the bet has been placed.
                        Chips.Add(chip);                    // Add the chip to the bet.
                        CombineChips();                     // Combine the chips.
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Bet.PlaceBet(object parameter): " + ex.ToString());
            }
        }