Beispiel #1
0
        public void SolveTest()
        {
            //var moves = CubeHelpers.GetListNMoveAleatoire(paramSolver.Tt, 3);
            var moves = CubeHelpers.GetMoveWithTransoFromMove(
                new List <Move> {
                new Move {
                    Identifiant = 'F', Sens = Move.EnumSens.Normal
                },
                new Move {
                    Identifiant = 'R', Sens = Move.EnumSens.Normal
                },
                new Move {
                    Identifiant = 'B', Sens = Move.EnumSens.Normal
                },
            }
                , paramSolver.Tt);

            var cubeInit = CubeHelpers.ApplyMovesToCube(paramSolver.Tr, moves);
            var solver   = (Solver) new SolverFirstResultLargeur(paramSolver, cubeInit);
            var sols     = solver.Solve().Result;

            Console.WriteLine(string.Join(string.Empty, moves.Select(m => m.Key)));
            var formatter = new SolutionsConsoleFormater(sols);
            var strHumain = formatter.Format();

            Console.WriteLine(strHumain);
            Console.WriteLine("Hello World!");
            Assert.IsTrue(sols.Contains(CubeHelpers.Reverse(paramSolver.Reverses,
                                                            moves.Select(kv => kv.Key)).ToList(),
                                        new ArrayHelpers.EqualityComparer <List <Move> >((t1, t2) => t1.SequenceEqual(t2))));
        }
Beispiel #2
0
        public void IsEqualTest()
        {
            var listmoves1WithTransfo = CubeHelpers.GetMoveWithTransoFromMove(move1(), paramSolver.Tt);
            var listmoves2WithTransfo = CubeHelpers.GetMoveWithTransoFromMove(move2(), paramSolver.Tt);

            var cubeApresTransfoMove1 = CubeHelpers.ApplyMovesToCube(
                paramSolver.Tr, listmoves1WithTransfo);
            var cubeApresTransfoMove2 = CubeHelpers.ApplyMovesToCube(
                paramSolver.Tr, listmoves2WithTransfo);

            Assert.IsTrue(Enumerable.SequenceEqual(cubeApresTransfoMove1, cubeApresTransfoMove2));
        }
        public async Task <bool> PerformTownTasks(Client client, TownManagementOptions options)
        {
            var game         = client.Game;
            var movementMode = GetMovementMode(game);

            game.CleanupCursorItem();
            InventoryHelpers.CleanupPotionsInBelt(game);

            if (client.Game.Me.Class == CharacterClass.Paladin && client.Game.Me.HasSkill(Skill.Vigor))
            {
                client.Game.ChangeSkill(Skill.Vigor, Hand.Right);
            }

            if (!await GeneralHelpers.PickupCorpseIfExists(client, _pathingService))
            {
                Log.Error($"{client.Game.Me.Name} failed to pickup corpse");
                return(false);
            }

            if (client.Game.Act != options.Act)
            {
                var targetTownArea     = WayPointHelpers.MapTownArea(options.Act);
                var pathToTownWayPoint = await _pathingService.ToTownWayPoint(client.Game, movementMode);

                if (!await MovementHelpers.TakePathOfLocations(client.Game, pathToTownWayPoint, movementMode))
                {
                    Log.Warning($"Teleporting to {client.Game.Act} waypoint failed");
                    return(false);
                }

                var townWaypoint = client.Game.GetEntityByCode(client.Game.Act.MapTownWayPointCode()).Single();
                Log.Information($"Taking waypoint to {targetTownArea}");
                if (!GeneralHelpers.TryWithTimeout((_) =>
                {
                    client.Game.TakeWaypoint(townWaypoint, options.Act.MapTownWayPoint());
                    return(GeneralHelpers.TryWithTimeout((_) => client.Game.Area == targetTownArea, TimeSpan.FromSeconds(2)));
                }, TimeSpan.FromSeconds(5)))
                {
                    Log.Information($"Moving to {options.Act} failed");
                    return(false);
                }
            }

            var townArea = WayPointHelpers.MapTownArea(game.Act);

            if (!await IdentifyItems(game, movementMode))
            {
                return(false);
            }

            if (!await RefreshAndSellItems(game, movementMode, options))
            {
                return(false);
            }

            if (!await RepairItems(game, movementMode))
            {
                return(false);
            }

            if (InventoryHelpers.HasAnyItemsToStash(client.Game))
            {
                var pathStash = await _pathingService.GetPathToObject(game.MapId, Difficulty.Normal, townArea, game.Me.Location, EntityCode.Stash, movementMode);

                if (!await MovementHelpers.TakePathOfLocations(game, pathStash, movementMode))
                {
                    Log.Warning($"{movementMode} failed at location {game.Me.Location}");
                }

                var stashItemsResult = InventoryHelpers.StashItemsToKeep(game, _externalMessagingClient);
                if (stashItemsResult != Enums.MoveItemResult.Succes)
                {
                    Log.Warning($"Stashing items failed with result {stashItemsResult}");
                }
            }

            if (CubeHelpers.AnyGemsToTransmuteInStash(client.Game))
            {
                var pathStash = await _pathingService.GetPathToObject(game.MapId, Difficulty.Normal, townArea, game.Me.Location, EntityCode.Stash, movementMode);

                if (!await MovementHelpers.TakePathOfLocations(game, pathStash, movementMode))
                {
                    Log.Warning($"{movementMode} failed at location {game.Me.Location}");
                }
                CubeHelpers.TransmuteGems(client.Game);
            }

            if (!await GambleItems(client, movementMode))
            {
                return(false);
            }

            return(true);
        }