Ejemplo n.º 1
0
 public SokobanGameEngine(IRenderer passedRenderer, IGameEvents passedGameEvents)
 {
     this.renderer         = passedRenderer;
     this.gameEvents       = passedGameEvents;
     this.sokobanGameLogic = new SokobanGameLogic();
     this.level1           = new SokobanGameLevel1();
 }
Ejemplo n.º 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);
        }