Ejemplo n.º 1
0
 private void resetCenter()
 {
     for (int i = 0; i < factories.Length; ++i)
     {
         factories[i] = bag.drawTiles(4);
         if (factories[i].Count < 4)
         {
             if (!boxLid.Empty)
             {
                 bag.AddRange(boxLid);
                 boxLid.Clear();
                 factories[i].AddRange(bag.drawTiles(4 - factories[i].Count));
             }
             else
             {
                 // No more tiles to draw, remaining factories will be empty.
                 break;
             }
         }
     }
     centerArea.Add(Color.WHITE);
     UpdateTiles();
 }
Ejemplo n.º 2
0
            /**
             * Adds the given tiles to this row, returning any overflow
             *
             * @param tc
             *            the set of tiles to add
             * @return a TileCollection representing the overflow tiles (is an empty collection if no overflow)
             */
            public TileCollection addTiles(TileCollection tc)
            {
                if (!tc.isAllOneColor())
                {
                    throw new ArgumentException("Invalid tile collection for build row: not all one color");
                }
                if (tc.getColor() != color && color != null) // Shouldn't happen, check canAddTiles() first
                {
                    return(tc);
                }
                color  = tc.getColor();
                count += tc.Count;
                int overflow = Math.Max(count - (row + 1), 0); // Can't have negative overflow

                count -= overflow;                             // 'overflow' extra tiles were added; remove them
                return(tc.drawTiles(overflow));                // Simplest way to get the appropriate TileCollection
            }