public SokobanGameEngine(IRenderer passedRenderer, IGameEvents passedGameEvents)
 {
     this.renderer         = passedRenderer;
     this.gameEvents       = passedGameEvents;
     this.sokobanGameLogic = new SokobanGameLogic();
     this.level1           = new SokobanGameLevel1();
 }
Exemple #2
0
        public static bool CheckSolution(Puzzle puzzle, Path path, out string desc)
        {
            if (path == null)
            {
                desc = "Invalid path";
                return(false);
            }

            var game = new SokobanGameLogic(puzzle);
            var cc   = 0;

            foreach (var step in path)
            {
                var m = game.Move(step);
                if (m == MoveResult.Win)
                {
                    desc = null;
                    return(true);
                }

                if (m != MoveResult.Ok)
                {
                    desc = $"Move #{cc} of {path.Count} dir:{step} state not OK, but was {m}\n{game.Current}";
                    return(false);
                }

                cc++;
            }

            desc = "Path complete; but it did not state in a Solution. Final Position was:\n" + game.Current;
            return(false);
        }