public void shouldGetOrbitAndVehicleWithShortestTravelTimeSuitableToWeather()
        {
            Mock <Vehicle> bikeMock = new Mock <Vehicle>(MockBehavior.Strict);

            bikeMock.Setup(_ => _.getVehicleType()).Returns(VehicleType.Bike);
            bikeMock.Setup(_ => _.canTravel(It.IsAny <Weather>())).Returns(true);
            bikeMock.Setup(_ => _.getTravelTime(It.Is <Orbit>(o => o.getDescription() == orbit1.getDescription()), It.IsAny <Weather>()))
            .Returns(2);
            bikeMock.Setup(_ => _.getTravelTime(It.Is <Orbit>(o => o.getDescription() == orbit2.getDescription()), It.IsAny <Weather>()))
            .Returns(1.5);
            bikeMock.Setup(_ => _.ToString()).Returns(bikeMock.Object.getVehicleType().ToString());

            Mock <Vehicle> superCarMock = new Mock <Vehicle>(MockBehavior.Strict);

            superCarMock.Setup(_ => _.getVehicleType()).Returns(VehicleType.SuperCar);
            superCarMock.Setup(_ => _.canTravel(It.IsAny <Weather>())).Returns(false);
            superCarMock.Setup(_ => _.getTravelTime(It.Is <Orbit>(o => o.getDescription() == orbit1.getDescription()), It.IsAny <Weather>()))
            .Returns(1.7);
            superCarMock.Setup(_ => _.getTravelTime(It.Is <Orbit>(o => o.getDescription() == orbit2.getDescription()), It.IsAny <Weather>()))
            .Returns(1.4);
            superCarMock.Setup(_ => _.ToString()).Returns(superCarMock.Object.getVehicleType().ToString());

            var helper = new TravelHelper(new Orbit[] { orbit1, orbit2 },
                                          new Vehicle[] { bikeMock.Object, superCarMock.Object },
                                          WeatherType.Rainy);
            var expectedOutput = "Vehicle " + bikeMock.Object.getVehicleType().ToString() + " on " + orbit2.getDescription();

            var shortestTrip = helper.getTripWithShortestTravelTime();

            Assert.AreEqual(expectedOutput, shortestTrip.ToString());
        }
Exemplo n.º 2
0
        public static int SortTravelHelperByCostDesc(TravelHelper a, TravelHelper b)
        {
            if (a._difference == b._difference)
            {
                return(0);
            }
            if (a._difference < b._difference)
            {
                return(1);
            }

            return(-1);
        }
Exemplo n.º 3
0
    public string version = "0.1.81"; // Must match version in Version.txt

    public void Initialize()
    {
        try
        {
            Directory.CreateDirectory(Application.StartupPath + "\\Profiles\\Wholesome Professions\\");
            WholesomeProfessionsSettings.Load();
            WholesomeProfessionsSave.Load();
            TravelHelper.AddAllOffmeshConnections();
            Logger.Log($"{productName} version {version} loaded");
        }
        catch (Exception e)
        {
            Logging.WriteError("Main > Initialize(): " + e);
        }
    }
Exemplo n.º 4
0
        public void TestSampleArgs()
        {
            TravelCard card1;

            card1.CityFrom = "Мельбурн";
            card1.CityTo   = "Кельн";
            TravelCard card2;

            card2.CityFrom = "Москва";
            card2.CityTo   = "Париж";
            TravelCard card3;

            card3.CityFrom = "Кельн";
            card3.CityTo   = "Москва";
            TravelCard[] cards = { card1, card2, card3 };
            TravelHelper.Sort(cards);
        }
Exemplo n.º 5
0
        public void TestInvalidArgs()
        {
            TravelCard card1;

            card1.CityFrom = "Мельбурн";
            card1.CityTo   = "Кельн";
            TravelCard card2;

            card2.CityFrom = "Москва";
            card2.CityTo   = "Париж";
            TravelCard card3;

            card3.CityFrom = "Кельн";
            card3.CityTo   = "Москва";
            TravelCard card4;

            card4.CityFrom = "Рига";
            card4.CityTo   = "Москва";
            TravelCard[] cards = { card1, card2, card3, card4 };
            TravelHelper.Sort(cards);
        }
        public void MethodOne()
        {
            Console.WriteLine("Integeration test 1:");
            Orbit[] orbits = new Orbit[]
            {
                new Orbit("Orbit1", 12, 20, 18),
                new Orbit("Orbit2", 10, 10, 20)
            };

            Vehicle[] vehicles = new Vehicle[]
            {
                new Vehicle(VehicleType.Bike, 10, 2, new WeatherType[] { WeatherType.Sunny, WeatherType.Windy }, 1),
                new Vehicle(VehicleType.TukTuk, 12, 1, new WeatherType[] { WeatherType.Sunny, WeatherType.Rainy }, 2),
                new Vehicle(VehicleType.SuperCar, 20, 3, new WeatherType[] { WeatherType.Sunny, WeatherType.Windy, WeatherType.Rainy }, 3)
            };
            TravelHelper helper       = new TravelHelper(orbits, vehicles, WeatherType.Sunny);
            var          shortestTrip = helper.getTripWithShortestTravelTime();

            Console.WriteLine("Input: Weather is Sunny");
            Console.WriteLine("Input: Orbit1 traffic speed is 12 megamiles/hour");
            Console.WriteLine("Input: Orbit2 traffic speed is 10 megamiles/hour");
            Console.WriteLine("Output: " + shortestTrip.ToString());
            Console.WriteLine();
        }
    public static void LoadNewProfile(string profession, string profileName)
    {
        Profile = new GrinderProfile();
        string filePath = Application.StartupPath + "\\Profiles\\Wholesome Professions\\" + profileName;

        Bot.ProfileName = profileName;

        // If grinder School Load Profile
        if (!string.IsNullOrWhiteSpace(profileName) && File.Exists(filePath))
        {
            Profile = XmlSerializer.Deserialize <GrinderProfile>(filePath);
            if (Profile.GrinderZones.Count <= 0)
            {
                Logger.Log($"Profile '{filePath}' seems incorrect. Please use a Grinder profile.");
                UnloadCurrentProfile();
                return;
            }
            else
            {
                Logger.Log("Profile loaded");
            }
        }
        else
        {
            Logger.LogLineBroadcastImportant($"Profile file '{filePath}' not found");
            UnloadCurrentProfile();
            return;
        }

        SelectZone();

        // Black List:
        var blackListDic =
            Profile.GrinderZones.SelectMany(zone => zone.BlackListRadius).ToDictionary(b => b.Position,
                                                                                       b => b.Radius);

        //wManager.wManagerSetting.AddRangeBlackListZone(blackListDic);

        // Add Npc
        foreach (var zone in Profile.GrinderZones)
        {
            NpcDB.AddNpcRange(zone.Npc);
        }

        // Go to first hotspot or travel
        if (Profile.GrinderZones.Count > 0)
        {
            string zoneName    = Profile.GrinderZones[ZoneIdProfile].Name;
            int    continentId = TravelHelper.GetContinentFromZoneName(zoneName);
            Logger.LogDebug($"Zone {zoneName} is on continent {continentId.ToString()}");
            if (continentId == -1)
            {
                Logger.LogLineBroadcastImportant($"ERROR : The zone name {zoneName} from your profile is incorrect. Please use default zone names.");
                UnloadCurrentProfile();
                return;
            }

            if (continentId != Usefuls.ContinentId)
            {
                Logger.Log($"{Profile.GrinderZones[ZoneIdProfile].Name} is on another continent ({continentId}). Launching traveler.");
                Bot.SetContinent((ContinentId)continentId);
                return;
            }

            Bot.ProfileProfession = profession;
            Logger.Log($"Heading to first spot {Profile.GrinderZones[ZoneIdProfile].Vectors3[0]} in {Profile.GrinderZones[ZoneIdProfile].Name}");
            Broadcaster.autoBroadcast = false;
            Broadcaster.BroadCastSituation();
            GoToTask.ToPosition(Profile.GrinderZones[ZoneIdProfile].Vectors3[0], 50);
            Broadcaster.autoBroadcast = true;
        }
        else
        {
            Logger.LogDebug("No grinder zone found");
            UnloadCurrentProfile();
        }
    }
Exemplo n.º 8
0
        public override void Run()
        {
            Logger.LogDebug("************ RUNNING TRAVEL STATE ************");
            Broadcaster.autoBroadcast = false;

            ContinentId destinationContinent = Bot.Continent;

            // HORDE
            if (ToolBox.IsHorde())
            {
                // From EK
                if ((ContinentId)Usefuls.ContinentId == ContinentId.Azeroth)
                {
                    // To Kalimdor
                    if (destinationContinent == ContinentId.Kalimdor)
                    {
                        Logger.Log("Traveling to Kalimdor");
                        TravelHelper.HordeEKToKalimdor();
                    }
                    // To Outlands
                    if (destinationContinent == ContinentId.Expansion01)
                    {
                        Logger.Log("Traveling to Outland");
                        TravelHelper.HordeEKToOutland();
                    }
                    // To Northrend
                    if (destinationContinent == ContinentId.Northrend)
                    {
                        Logger.Log("Traveling to Northrend");
                        TravelHelper.HordeEKToKalimdor();
                    }
                }

                // From Kalimdor
                if ((ContinentId)Usefuls.ContinentId == ContinentId.Kalimdor)
                {
                    // To EK
                    if (destinationContinent == ContinentId.Azeroth)
                    {
                        Logger.Log("Traveling to Eastern Kingdoms");
                        TravelHelper.HordeKalimdorToEK();
                    }
                    // To Outlands
                    if (destinationContinent == ContinentId.Expansion01)
                    {
                        Logger.Log("Traveling to Outland");
                        TravelHelper.HordeKalimdorToEK();
                    }
                    // To Northrend
                    if (destinationContinent == ContinentId.Northrend)
                    {
                        Logger.Log("Traveling to Northrend");
                        TravelHelper.HordeKalimdorToNorthrend();
                    }
                }

                // From Outlands
                if ((ContinentId)Usefuls.ContinentId == ContinentId.Expansion01)
                {
                    // To Kalimdor
                    if (destinationContinent == ContinentId.Kalimdor)
                    {
                        Logger.Log("Traveling to Kalimdor");
                        TravelHelper.HordeOutlandToKalimdor();
                    }
                    // To EK
                    if (destinationContinent == ContinentId.Azeroth)
                    {
                        Logger.Log("Traveling to Eastern Kingdoms");
                        TravelHelper.HordeOutlandToKalimdor();
                    }
                    // To Northrend
                    if (destinationContinent == ContinentId.Northrend)
                    {
                        Logger.Log("Traveling to Northrend");
                        TravelHelper.HordeOutlandToKalimdor();
                    }
                }

                // From Northrend
                if ((ContinentId)Usefuls.ContinentId == ContinentId.Northrend)
                {
                    // To Kalimdor
                    if (destinationContinent == ContinentId.Kalimdor)
                    {
                        Logger.Log("Traveling to Kalimdor");
                        TravelHelper.HordeNorthrendToKalimdor();
                    }
                    // To EK
                    if (destinationContinent == ContinentId.Azeroth)
                    {
                        Logger.Log("Traveling to Eastern Kingdoms");
                        TravelHelper.HordeNorthrendToEK();
                    }
                    // To Outland
                    if (destinationContinent == ContinentId.Expansion01)
                    {
                        Logger.Log("Traveling to Outland");
                        TravelHelper.HordeNorthrendToOutland();
                    }
                }
            }
            Broadcaster.autoBroadcast = true;
        }