Ejemplo n.º 1
0
        protected override CommandQueueElement RunInternal()
        {
            _oneWayTrip = TimeSpan.FromSeconds((ReturnTime - DateTimeOffset.Now).TotalSeconds / 2);

            using (BotDb db = new BotDb())
                using (Client.EnterPlanetExclusive(this))
                {
                    var resp = Client.IssueRequest(Client.RequestBuilder.GetPage(PageType.Fleet, PlanetId));
                    var info = resp.GetParsedSingle <OgamePageInfo>();

                    FleetComposition fleet = FleetComposition.FromDetected(resp.GetParsed <DetectedShip>());
                    if (!fleet.Ships.ContainsKey(ShipType.Recycler))
                    {
                        Logger.Instance.Log(LogLevel.Error, "Planet does not have a recycler, cannot fleetsave");
                        return(null);
                    }
                    fleet.Resources = resp.GetParsedSingle <PlanetResources>().Resources;

                    PlayerResearch research   = db.Players.Where(p => p.PlayerId == info.PlayerId).Select(p => p.Research).First();
                    int            fleetSpeed = fleet.Speed(research);

                    Coordinate      here      = info.PlanetCoord;
                    FleetSaveTarget candidate = CandidateFromSystem(db, here, fleetSpeed) ?? CandidateFromGalaxy(db, here, fleetSpeed);

                    if (candidate != null)
                    {
                        Logger.Instance.Log(LogLevel.Success, $"Best candidate for fleetsave is {candidate.Target} at speed {candidate.Speed}; one way trip {candidate.Duration}");

                        new SendFleetCommand()
                        {
                            PlanetId    = PlanetId,
                            Destination = Coordinate.Create(candidate.Target, CoordinateType.DebrisField),
                            Speed       = candidate.Speed,
                            Mission     = MissionType.Recycle,
                            Fleet       = fleet
                        }.Run();
                    }
                    else
                    {
                        Logger.Instance.Log(LogLevel.Error, $"Could not find a good candidate for fleetsave");
                    }
                }
            return(null);
        }
Ejemplo n.º 2
0
 public int GetSpeed(PlayerResearch research)
 {
     return(GetSpeed(((Dictionary <ResearchType, int>)research)[_speedResearch]));
 }
Ejemplo n.º 3
0
 public Player()
 {
     Research = new PlayerResearch();
 }
Ejemplo n.º 4
0
 public int Speed(PlayerResearch research)
 {
     return(Ships.Keys.Min(s => ((Ship)s).GetSpeed(research)));
 }