Exemplo n.º 1
0
 protected GalaxyObject(int id, string name, Position position, Metal metal, Crystal crystal, Deuterium deuterium)
 {
     Id        = id;
     Name      = name;
     Position  = position;
     Metal     = metal;
     Crystal   = crystal;
     Deuterium = deuterium;
 }
Exemplo n.º 2
0
 private OGameFleetSender(OGameHttpClient client, Planet source, Planet destination, FleetSpeed speed, List <ShipBase> ships,
                          MissionType missionType, Metal metal = null, Crystal crystal = null, Deuterium deuterium = null)
 {
     _client      = client;
     _source      = source;
     _destination = destination;
     _metal       = metal;
     _crystal     = crystal;
     _deuterium   = deuterium;
     _speed       = speed;
     _ships       = ships;
     _missionType = missionType;
 }
Exemplo n.º 3
0
        public static async Task <MissionBase> SaveFleet(OGameHttpClient client, int savePlanetId)
        {
            var planetToSave = ObjectContainer.Instance.PlayerPlanets.First(p => p.Id == savePlanetId);
            var saveLocation = ObjectContainer.Instance.PlayerPlanets.FirstOrDefault(p => p.Id != savePlanetId);

            if (saveLocation == null)
            {
                return(null);
            }

            await client.RefreshPlanet(planetToSave);

            var planetShips   = planetToSave.Ships;
            var shipsCapacity = planetShips.Sum(x => x.Capacity * x.Quantity) * 0.95;

            Metal     metalToSave;
            Crystal   crystalToSave;
            Deuterium deuteriumToSave;

            planetToSave.Deuterium.Amount = (int)(planetToSave.Deuterium.Amount * 0.95);

            if (shipsCapacity > planetToSave.TotalResources)
            {
                metalToSave     = planetToSave.Metal;
                crystalToSave   = planetToSave.Crystal;
                deuteriumToSave = planetToSave.Deuterium;
            }
            else
            {
                metalToSave     = new Metal((int)shipsCapacity * 1 / 6);
                crystalToSave   = new Crystal((int)shipsCapacity * 2 / 6);
                deuteriumToSave = new Deuterium((int)shipsCapacity * 3 / 6);
                if (metalToSave.Amount > planetToSave.Metal.Amount)
                {
                    metalToSave = planetToSave.Metal;
                }
                if (crystalToSave.Amount > planetToSave.Crystal.Amount)
                {
                    crystalToSave = planetToSave.Crystal;
                }
                if (deuteriumToSave.Amount > planetToSave.Deuterium.Amount)
                {
                    deuteriumToSave = planetToSave.Deuterium;
                }
            }


            return(await Stationize(client, planetToSave, saveLocation, FleetSpeed.Speed10, planetShips, metalToSave, crystalToSave, deuteriumToSave).SendFleet());
        }
Exemplo n.º 4
0
 public Planet(int id, string name, Position position, Metal metal, Crystal crystal, Deuterium deuterium) : base(id, name, position, metal, crystal, deuterium)
 {
 }
Exemplo n.º 5
0
 public PlayerPlanet(int id, string name, Position position, PlanetTemperature temperature, Metal metal, Crystal crystal, Deuterium deuterium) : base(id, name, position, metal, crystal, deuterium)
 {
     Temperature = temperature;
     Type        = PlanetType.Self;
 }
Exemplo n.º 6
0
 public static OGameFleetSender Stationize(OGameHttpClient client, Planet source, Planet destination, FleetSpeed speed,
                                           List <ShipBase> ships, Metal metal, Crystal crystal, Deuterium deuterium)
 {
     return(new OGameFleetSender(client, source, destination, speed, ships, MissionType.Stationize, metal,
                                 crystal,
                                 deuterium));
 }
Exemplo n.º 7
0
 public override string ToString()
 {
     return($"M: {Metal.ToString("N0")} C: {Crystal.ToString("N0")} D: {Deuterium.ToString("N0")} E: {Energy.ToString("N0")} DM: {Darkmatter.ToString("N0")}");
 }
        public HttpRequestMessage BuildFleetSendingRequest4(string token, Planet destination, List <ShipBase> ships, FleetSpeed speed, MissionType missionType, Metal metal, Crystal crystal, Deuterium deuterium)
        {
            var url    = $"{_client.ServerUrl}/game/index.php?page=movement";
            var values = new Dictionary <string, string>
            {
                { "token", token },
                { "galaxy", $"{destination.Position.Galaxy}" },
                { "system", $"{destination.Position.System}" },
                { "position", $"{destination.Position.Planet}" },
                { "type", "1" },
                { "speed", $"{(int)speed}" },
                { "holdingtime", "1" },
                { "mission", $"{(int)missionType}" },
                { "union2", "0" },
                { "holdingOrExpTime", "0" },
                { "prioMetal", "1" },
                { "prioCrystal", "2" },
                { "prioDeuterium", "3" },
                { "metal", $"{metal.Amount}" },
                { "crystal", $"{crystal.Amount}" },
                { "deuterium", $"{deuterium.Amount}" },
                { "ajax", "1" }
            };

            foreach (var ship in ships)
            {
                values.Add($"am{(int)ship.Type}", $"{ship.Quantity}");
            }

            var request = new PostHttpRequest().Create(url, values);

            request.Headers.Referrer = new Uri($"{_client.ServerUrl}/game/index.php?page=fleet3");
            request.Headers.Add("Connection", "keep-alive");
            return(request);
        }