コード例 #1
0
        /**
         * Adds tiles (from the selectedTiles buffer) to the given build row, overflowing to the floor line
         *
         * @param row
         *            the 0-indexed row number (>4 places tiles directly on the floor line)
         */
        public void addTilesToRow(object sender, EventArgs e)//(int row)
        {
            if (selectedTiles == null)
            {
                throw new InvalidOperationException("Tiles must be selected before they can be added to a row.");
            }
            int row = (int)((Button)sender).Tag;

            if (row > 4)
            {
                floorLine.AddRange(selectedTiles);
            }
            else
            {
                if (selectedTiles.Contains(Color.WHITE))
                {
                    floorLine.AddRange(selectedTiles.removeTilesOfColor(Color.WHITE));
                }
                floorLine.AddRange(buildRows[row].addTiles(selectedTiles));
            }
            selectedTiles = null;
            updateButtons();
            updateTiles();
            model.endTurn();
        }
コード例 #2
0
        /**
         * Invokes tileRow() for each build row and scoreFloor(), collecting the discard tiles into a single collection, and
         * triggers UI updates
         *
         * @return a TileCollection representing all of the tiles discarded by this player
         */
        public TileCollection finishRound()
        {
            TileCollection discard = new TileCollection();

            for (int i = 0; i < 5; ++i)
            {
                discard.AddRange(tileRow(i));
            }
            discard.AddRange(scoreFloor());
            updateTiles();
            updateScore();
            return(discard);
        }
コード例 #3
0
ファイル: Game.cs プロジェクト: Jsnhlbr5/Azul-C-Sharp
 /**
  * Ends a player's turn. If the round is over (all tiles have been picked), performs end-of-round activities
  * (tiling, scoring, and discard). If the game is not over, resets the common area for the next round; otherwise
  * tallies final bonuses and declares the winner before exiting.
  */
 public void endTurn()
 {
     playerBoards[curPlayer].updateTitle(false);
     if (roundOver())
     {
         TileCollection discard;
         for (int i = 0; i < numPlayers; ++i)
         {
             discard = playerBoards[i].finishRound();
             if (discard.Contains(Color.WHITE))
             {
                 curPlayer = i;
                 discard.removeTilesOfColor(Color.WHITE);
             }
             boxLid.AddRange(discard);
         }
         if (!gameOver())
         {
             resetCenter();
         }
         else
         {
             int score = -1;
             winner = "";
             foreach (PlayerBoard pb in playerBoards)
             {
                 int s = pb.finishGame();
                 if (s > score)
                 {
                     score  = s;
                     winner = pb.player;
                 }
             }
             DialogResult result = MessageBox.Show(winner + " wins!", "Game Over", MessageBoxButtons.OK, MessageBoxIcon.Information);
             if (result == DialogResult.OK)
             {
                 Close();
             }
         }
     }
     else
     {
         curPlayer = (curPlayer + 1) % numPlayers;
     }
     playerBoards[curPlayer].updateTitle(true);
 }
コード例 #4
0
ファイル: Game.cs プロジェクト: Jsnhlbr5/Azul-C-Sharp
 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();
 }
コード例 #5
0
ファイル: Game.cs プロジェクト: Jsnhlbr5/Azul-C-Sharp
        internal void PickTiles(object sender, EventArgs e)
        {
            int        factory = -1;
            TileButton btn     = (TileButton)sender;

            if (btn.Parent.GetType() == typeof(Factory))
            {
                factory = ((Factory)btn.Parent).Index;
            }
            Color color = (Color)btn.TileColor;

            TileCollection picked;

            // TODO the actual move stuff
            if (factory < 0)
            {
                picked = centerArea.removeTilesOfColor(color);
                if (centerArea.Contains(Color.WHITE))
                {
                    picked.AddRange(centerArea.removeTilesOfColor(Color.WHITE));
                }
            }
            else
            {
                picked = factories[factory].removeTilesOfColor(color);
                centerArea.AddRange(factories[factory]);
                factories[factory].Clear();
            }
            UpdateTiles();
            playerBoards[curPlayer].setSelectedTiles(picked);

            //if (netGame)
            //{
            //    connection.InvokeAsync("SendPick", curPlayer, factory, color);
            //}
        }