コード例 #1
0
        /// <summary>
        /// Creates copy of the game state.
        /// </summary>
        /// <returns>Copy of the game state.</returns>
        public GameState Copy()
        {
            var copy = new GameState();

            copy.CurrentCoords      = CurrentCoords;
            copy.CurrentPhase       = CurrentPhase;
            copy.CurrentPlayerIndex = CurrentPlayerIndex;
            copy.CurrentTile        = CurrentTile == null ? null : CurrentTile.Copy();
            copy.Params             = Params == null ? null : Params.Copy();
            copy.Scores             = new Dictionary <PlayerColor, int>(Scores);
            copy.TileSupplier       = TileSupplier.Copy();

            copy.Grid = new Dictionary <Coords, TilePlacement>();
            foreach (var c in Grid.Keys)
            {
                copy.Grid.Add(c, Grid[c].Copy());
            }

            copy.PlacedFollowers = new List <FollowerPlacement>();
            foreach (var fp in PlacedFollowers)
            {
                copy.PlacedFollowers.Add(fp.Copy());
            }

            return(copy);
        }
コード例 #2
0
        /// <summary>
        /// Creates copy of the supplier.
        /// </summary>
        /// <returns>Copy of the supplier.</returns>
        public ITileSupplier Copy()
        {
            var copy = new StandardTileSetSupplier();

            copy._RemainingTiles = new List <TileScheme>();
            foreach (var t in _RemainingTiles)
            {
                copy._RemainingTiles.Add(t.Copy());
            }

            copy._First = _First.Copy();

            copy._Rnd = new Random();

            return(copy);
        }