Esempio n. 1
0
        /// <summary>
        /// Initialize the tiles.
        /// </summary>
        public void SetupTiles()
        {
            Tiles   = new ScrabbleTile[ScrabbleForm.BOARD_WIDTH, ScrabbleForm.BOARD_HEIGHT];
            TileBag = new TileBag();
            //var specialTilePositions = ScrabbleForm.WordScorer.GetTileTypes();

            foreach (var virtuTile in ScrabbleForm.Game.Grid)
            {
                var tile = new ScrabbleTile(ScrabbleForm)
                {
                    Ligne = virtuTile.Ligne,
                    Col   = virtuTile.Col,
                };
                tile.BackColor = SystemColors.ButtonFace;
                tile.Location  = new Point(virtuTile.Ligne * (ScrabbleForm.TILE_SIZE + 2), virtuTile.Col * (ScrabbleForm.TILE_SIZE + 2));
                tile.Size      = new Size(ScrabbleForm.TILE_SIZE, ScrabbleForm.TILE_SIZE);
                //tile.UseVisualStyleBackColor = false;
                tile.Font      = new Font("Verdana", 25.75F, FontStyle.Regular);
                tile.Click    += Tile_Click;
                tile.DragDrop += Tile_DragDrop;
                tile.SetRegularBackgroundColour();
                ScrabbleForm.Controls.Add(tile);

                Tiles[virtuTile.Ligne, virtuTile.Col] = tile;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Initialize the tiles.
        /// </summary>
        public void SetupTiles()
        {
            Tiles   = new ScrabbleTile[ScrabbleForm.BOARD_WIDTH, ScrabbleForm.BOARD_HEIGHT];
            TileBag = new TileBag();
            var specialTilePositions = WordScorer.GetTileTypes();

            for (int x = 1; x <= ScrabbleForm.BOARD_WIDTH; x++)
            {
                for (int y = 1; y <= ScrabbleForm.BOARD_HEIGHT; y++)
                {
                    var tile = new ScrabbleTile
                    {
                        XLoc = x - 1,
                        YLoc = y - 1
                    };
                    tile.BackColor = SystemColors.ButtonFace;
                    tile.Location  = new Point(x * (ScrabbleForm.TILE_SIZE + 2), y * (ScrabbleForm.TILE_SIZE + 2));
                    tile.Size      = new Size(ScrabbleForm.TILE_SIZE, ScrabbleForm.TILE_SIZE);
                    tile.UseVisualStyleBackColor = false;
                    tile.Font     = new Font("Verdana", 15.75F, FontStyle.Regular);
                    tile.Click   += Tile_Click;
                    tile.TileType = specialTilePositions[x - 1, y - 1];
                    tile.SetRegularBackgroundColour();
                    ScrabbleForm.Controls.Add(tile);

                    Tiles[x - 1, y - 1] = tile;
                }
            }
        }
Esempio n. 3
0
        public void RackAddTiles()
        {
            // Arrange
            var r  = new Rack();
            var tb = new TileBag();

            var tiles = new List <Tile>()
            {
                new Tile("A"),
                new Tile("B"),
                new Tile("C"),
                new Tile("D"),
                new Tile("E"),
                new Tile("F"),
                new Tile("G")
            };

            // Act
            r.AddTiles(tiles);

            // Assert
            // start square correctly set
            Assert.NotNull(r.GetTiles());
            Assert.Equal(7, r.TileCount);
        }
    public void CmdRequestTileBagShuffle()
    {
        // TODO: Validate...

        TileBag tileBag = FindObjectOfType <TileBag>();

        tileBag.ShuffleTilesInBag();
    }
Esempio n. 5
0
        public void TileBagCorrect()
        {
            // Arrange

            var tb = new TileBag();

            // Assert
            // tiles generated
            Assert.Equal(100, tb.count);
            Assert.Equal(6, tb.tiles.FindAll(t => t.Letter == "R").Count);
        }
Esempio n. 6
0
        public void TileBag_DrawTiles(int tilesToDraw, int expectedResult, int expectedDrawnTiles)
        {
            // Arrange
            var tileBag = new TileBag();

            // Act
            var drawnTiles = tileBag.DrawTiles(tilesToDraw);

            // Assert
            Assert.AreEqual(expectedResult, tileBag.Tiles.Count);
            Assert.AreEqual(expectedDrawnTiles, drawnTiles.Count);
        }
Esempio n. 7
0
        public void TileBag_Constructor_ShufflesTiles()
        {
            // Act
            var tileBag  = new TileBag();
            var tileBag2 = new TileBag();

            var tiles  = tileBag.Tiles;
            var tiles2 = tileBag2.Tiles;

            // Assert
            Assert.IsFalse(tiles.SequenceEqual(tiles2));
        }
Esempio n. 8
0
        public void TileBag_Constructor_PopulatesWithTiles_Defaults3Copies()
        {
            // Act
            var tileBag = new TileBag();
            var tiles   = tileBag.Tiles;

            // Assert
            Assert.AreEqual(108, tiles.Count);
            var tileTypes = tiles.GroupBy(x => new { x.Shape, x.Color });

            Assert.AreEqual(36, tileTypes.Distinct().Count());
            Assert.IsTrue(tileTypes.All(x => x.Count() == 3));
        }
Esempio n. 9
0
        public void PlayerInitialRack()
        {
            // Arrange
            var p  = new Player("player 1");
            var tb = new TileBag();

            // Act
            p.DrawTiles(tb);


            // Assert
            Assert.Equal(7, p.rack.TileCount);
        }
Esempio n. 10
0
        public void TileBag_Constructor_PopulatesWithTiles_CustomNumberOfCopies()
        {
            // Arrange
            var copies = 6;

            // Act
            var tileBag = new TileBag(copies);
            var tiles   = tileBag.Tiles;

            // Assert
            Assert.AreEqual(copies * 36, tiles.Count);
            var tileTypes = tiles.GroupBy(x => new { x.Shape, x.Color });

            Assert.AreEqual(36, tileTypes.Distinct().Count());
            Assert.IsTrue(tileTypes.All(x => x.Count() == copies));
        }
    public void CmdRequestFlipAllTiles()
    {
        TileBag tileBag = FindObjectOfType <TileBag>();

        tileBag.FlipAllTilesInBag();
    }