示例#1
0
        public void RestoreFromMemento(IGameMemento memento)
        {
            var newMemento = (GameMemento)memento;

            Playfield = newMemento.Playfield;
            Settings  = newMemento.Settings;
            Moves     = newMemento.Moves;
            NotifyOnPlayfieldChange?.Invoke(Playfield.Board);
        }
示例#2
0
        public bool MakeMove(IPlayfield playfield, Direction direction, bool withRandomMoves)
        {
            bool isMoveValid = MoveEmptyFrame(playfield, direction);

            if (isMoveValid)
            {
                if (withRandomMoves)
                {
                    Random random = new Random();
                    MakeRandomMoves(playfield, random.Next(1, 6)); // [1;6)
                }
                NotifyOnPlayfieldChange?.Invoke(playfield.Board);
            }
            return(isMoveValid);
        }
示例#3
0
        public void ShuffleBoard(IPlayfield playfield, Level level)
        {
            switch (level)
            {
            case Level.Easy:
                MakeRandomMoves(playfield, 5);
                break;

            case Level.Medium:
                MakeRandomMoves(playfield, 20);
                break;

            case  Level.Hard:
                MakeRandomMoves(playfield, 100);
                break;
            }
            NotifyOnPlayfieldChange?.Invoke(playfield.Board);
        }