Пример #1
0
        protected override void InterpretRow(Dictionary<string, string> fields)
        {
            int stationId = ParseId(fields["stationID"]);
            int stationTypeId = ParseId(fields["stationTypeID"]);
            string name = fields["stationName"];
            int systemId = ParseId(fields["solarSystemID"]);

            SolarSystem system = map.GetSystem(systemId);
            if (system != null)
            {
                Station station = new Station(stationId, stationTypeId, name, system);
                stationsById.Add(stationId, station);
            }
        }
Пример #2
0
        public SingleTrip(Map map, Station source, Station destination)
        {
            this.map = map;
            this.source = source;
            this.destination = destination;

            jumpsSecure = map.DistanceBetween(source.System, destination.System, true);
            jumpsShortest = map.DistanceBetween(source.System, destination.System, false);

            if ((jumpsSecure == jumpsShortest) && (jumpsSecure != int.MaxValue))
            {
                security = SecurityStatus.Level.HighSec;
            }
            else if ((jumpsSecure > jumpsShortest) && (jumpsSecure != int.MaxValue))
            {
                security = SecurityStatus.Level.LowSecShortcut;
            }
            else if ((jumpsSecure == int.MaxValue) && (jumpsShortest != int.MaxValue))
            {
                security = SecurityStatus.Level.LowSecOnly;
            }
            else
            {
                security = SecurityStatus.Level.Isolated;
            }
        }
Пример #3
0
        public string Info(Station station, SolarSystem from, string postfix)
        {
            string result = Info(station);
            if (finder != null && station != null && from != null)
            {
                int jumpsSecure = finder.map.DistanceBetween(from, station.System, true);
                int jumpsShortest = finder.map.DistanceBetween(from, station.System, false);
                SecurityStatus.Level security = finder.map.RouteSecurity(from, station.System);

                if (security == SecurityStatus.Level.LowSecShortcut)
                {
                    result += " <FONT COLOR=\"#00ff33\">(" + jumpsSecure + " " + Pluralize("jump", "jumps", jumpsSecure) + ")</FONT>";
                    result += "/<FONT COLOR=\"#ff0033\">(" + jumpsShortest + " " + Pluralize("jump", "jumps", jumpsShortest) + ")</FONT>" + postfix;
                }
                else if (security == SecurityStatus.Level.HighSec)
                {
                    result += " <FONT COLOR=\"#00ff33\">(" + jumpsSecure + " " + Pluralize("jump", "jumps", jumpsSecure) + ")</FONT>" + postfix; ;
                }
                else
                {
                    result += " <FONT COLOR=\"#ff0033\">(" + jumpsShortest + " " + Pluralize("jump", "jumps", jumpsShortest) + ")</FONT>" + postfix;
                }
            }
            return result;
        }
Пример #4
0
 public string Info(Station station, SolarSystem from)
 {
     return Info(station, from, string.Empty);
 }
Пример #5
0
 public string Info(Station station, string here)
 {
     string result = string.Empty;
     if (finder != null && station != null)
     {
         SolarSystem system = finder.map.GetSystem(here);
         if (system != null)
         {
             result = Info(station, system, "");
         }
     }
     return result;
 }
Пример #6
0
 public string Info(Station station)
 {
     // Changed in latest build (showinfo:// to CCPEVE.showInfo) -- Terry
     string result = "<button type='button' onclick='CCPEVE.showInfo(" + station.TypeId + "," + station.Id + ")'>" + station.System.Name + "</button> <a href='javascript:CCPEVE.setDestination(" + station.System.Id + ")'>Set</a>";
     return result;
 }
Пример #7
0
        public SingleTrip GetBestSingleTrip(Station source, Station destination)
        {
            // single trips must be sorted (and iterated) in order of decreasing profit per warp
            foreach (SingleTrip trip in singleTrips)
            {
                if (trip.Source == source && trip.Destination==destination)
                {
                    return trip;
                }
            }

            return new SingleTrip(map, source, destination);
        }
Пример #8
0
        internal SingleTrip GetBestTrade(Station source, Station destination, TransactionList tradeList)
        {
            SingleTrip trade = new SingleTrip(map, source, destination);
            float iskLeft = parameters.Isk;
            float cargoSpaceLeft = parameters.CargoSpace;

            foreach (Transaction t in tradeList)
            {
                Transaction addTransaction = t.GetTransactionByLimits(iskLeft, cargoSpaceLeft);

                if (addTransaction != null)
                {
                    iskLeft -= addTransaction.Cost;
                    cargoSpaceLeft -= addTransaction.Volume;

                    trade.AddPurchase(addTransaction);
                }

                // We'll break out when isk or cargo is low (but not zero), to prevent looking for filler cargo.
                if ((cargoSpaceLeft == 3.0f) || (iskLeft == 10.0f))
                {
                    break;
                }
            }

            trade.Compress();

            return trade;
        }
Пример #9
0
        internal TransactionList GetItemTransactionList(Station source, Station destination, ItemType type)
        {
            TransactionList list = new TransactionList();

            Trade[] forSale = source.ItemsForSale[type].ToArray();
            Trade[] wanted = destination.ItemsWanted[type].ToArray();

            int buyIndex = 0;
            int sellIndex = 0;
            int buyAmount = 0;
            int sellAmount = 0;
            TransactionItem purchase = null;
            TransactionItem sale = null;
            Transaction currentTransaction = null;
            bool finished = false;
            int minQtyNeeded = 0;

            while (!finished)
            {
                // Source station has more than destination wants
                if ((forSale[buyIndex].Quantity - buyAmount) > (wanted[sellIndex].Quantity - sellAmount))
                {
                    // Set the amount (qty) of the transaction
                    int amount = (wanted[sellIndex].Quantity - sellAmount); 

                    // Create trades
                    purchase = new TransactionItem(forSale[buyIndex], amount);
                    if (minQtyNeeded > 0)
                    {
                        minQtyNeeded -= amount;
                    }
                    else
                    {
                        if (wanted[sellIndex].MinQuantity > amount)
                        {
                            sale = new TransactionItem(wanted[sellIndex]);
                            minQtyNeeded = wanted[sellIndex].MinQuantity - amount; 
                        }
                        else
                        {
                            sale = new TransactionItem(wanted[sellIndex], amount);
                        }
                    }

                    // Set the buy amount up by the amount that can be sold
                    buyAmount += amount;
                    // reset the sell amount
                    sellAmount = 0;
                    sellIndex++;
                }
                    // Source station has less than destination wants
                else if ((forSale[buyIndex].Quantity - buyAmount) < (wanted[sellIndex].Quantity - sellAmount))
                {
                    // Set the amount (qty) of the transaction
                    int amount = (forSale[buyIndex].Quantity - buyAmount);

                    // Create trades
                    purchase = new TransactionItem(forSale[buyIndex], amount);
                    if (minQtyNeeded > 0)
                    {
                        minQtyNeeded -= amount;
                    }
                    else
                    {
                        if (wanted[sellIndex].MinQuantity > amount)
                        {
                            sale = new TransactionItem(wanted[sellIndex]);
                            minQtyNeeded = wanted[sellIndex].MinQuantity - amount; 
                        }
                        else
                        {
                            sale = new TransactionItem(wanted[sellIndex], amount);
                        }
                    }

                    // Set the buy amount up by the amount that can be sold
                    sellAmount += amount;
                    // reset the buy amount
                    buyAmount = 0;
                    buyIndex++;
                }
                else
                {
                    // Set the amount (qty) of the transaction
                    int amount = (wanted[sellIndex].Quantity - sellAmount);

                    // Create trades
                    purchase = new TransactionItem(forSale[buyIndex], amount);
                    if (minQtyNeeded > 0)
                    {
                        minQtyNeeded -= amount;
                    }
                    else
                    {
                        if (wanted[sellIndex].MinQuantity > amount)
                        {
                            sale = new TransactionItem(wanted[sellIndex]);
                            minQtyNeeded = wanted[sellIndex].MinQuantity - amount;
                        }
                        else
                        {
                            sale = new TransactionItem(wanted[sellIndex], amount);
                        }
                    }


                    // Reset both buy and sell amount
                    buyAmount = 0;
                    sellAmount = 0;
                    buyIndex++;
                    sellIndex++;
                }

                if (currentTransaction == null)
                {
                    currentTransaction = new Transaction(purchase, sale);
                }
                else
                {
                    currentTransaction.AddPurchase(purchase);
                    if (sale != null)
                    {
                        currentTransaction.AddSale(sale);
                    }
                }

                purchase = null;
                sale = null;

                if ((wanted.Length <= sellIndex) ||
                    (forSale.Length <= buyIndex) ||
                    (wanted[sellIndex].UnitPrice <= forSale[buyIndex].UnitPrice))
                {
                    finished = true;
                }

                // If minimum quantity is achieved, add the transaction
                if ((finished) ||
                    ((minQtyNeeded <= 0) && 
                    (!((wanted[sellIndex].UnitPrice == wanted[Math.Max(sellIndex-1, 0)].UnitPrice) && 
                    (forSale[buyIndex].UnitPrice == forSale[Math.Max(buyIndex-1, 0)].UnitPrice)))
                    ))
                {
                    if (currentTransaction.Profit >= 0.0f)
                    {
                        list.Add(currentTransaction);
                    }
                    currentTransaction = null;
                    minQtyNeeded = 0;
                }

            }

            return list;
        }
Пример #10
0
        internal TransactionList GetProfitableTransactions(Station source, Station destination)
        {
            TransactionList list = new TransactionList();

            foreach (KeyValuePair<ItemType, TradeList> element in source.ItemsForSale)
            {
                if (destination.ItemsWanted.ContainsKey(element.Key))
                {
                    // Element 0 should have the highest buy price and lowest sell price respectively
                    if (destination.ItemsWanted[element.Key][0].UnitPrice > source.ItemsForSale[element.Key][0].UnitPrice)
                    {
                        // Get all the transactions for this item and station pair
                        list.AddRange(GetItemTransactionList(source, destination, element.Key));
                    }
                }
            }

            return list;
        }
Пример #11
0
        protected override void InterpretRow(Dictionary <string, string> fields)
        {
            float       price       = float.Parse(fields["price"], System.Globalization.CultureInfo.InvariantCulture);
            int         quantity    = (int)float.Parse(fields["volRemaining"], System.Globalization.CultureInfo.InvariantCulture);
            int         minQuantity = (int)float.Parse(fields["minVolume"], System.Globalization.CultureInfo.InvariantCulture);
            int         typeId      = int.Parse(fields["typeID"]);
            int         range       = int.Parse(fields["range"]);
            int         regionId    = int.Parse(fields["regionID"]);
            int         stationId   = int.Parse(fields["stationID"]);
            int         systemId    = int.Parse(fields["solarSystemID"]);
            string      isWanted    = fields["bid"];
            SolarSystem s           = map.GetSystem(systemId);
            Station     station     = map.GetStation(stationId);
            ItemType    type        = itemDatabase.GetItemType(typeId);

            if (s != null && type != null && station != null)
            {
                Trade trade = new Trade(type, price, quantity, minQuantity);
                if (isWanted == "True")
                {
                    // Range is in station only
                    if (range == -1)
                    {
                        station.AddItemWanted(trade);
                        if (!stationsWithItemsWanted.Contains(station))
                        {
                            stationsWithItemsWanted.Add(station);
                        }
                    }
                    // Range it either system or greater
                    else if ((range > -1) & (range < 32767))
                    {
                        foreach (SolarSystem sAtRange in s.Region.Systems)
                        {
                            if (map.DistanceBetween(s, sAtRange, false) <= range)
                            {
                                sAtRange.AddItemWanted(trade);
                                foreach (Station remoteStation in sAtRange.Stations)
                                {
                                    if (!stationsWithItemsWanted.Contains(remoteStation))
                                    {
                                        stationsWithItemsWanted.Add(remoteStation);
                                    }
                                }
                            }
                        }
                    }
                    // Range is regional
                    else if (range == 32767)
                    {
                        s.Region.AddItemWanted(trade);
                        foreach (SolarSystem system in s.Region.Systems)
                        {
                            foreach (Station remoteStation in system.Stations)
                            {
                                if (!stationsWithItemsWanted.Contains(remoteStation))
                                {
                                    stationsWithItemsWanted.Add(remoteStation);
                                }
                            }
                        }
                    }
                }
                else
                {
                    station.AddItemForSale(trade);
                    if (!stationsWithItemsForSale.Contains(station))
                    {
                        stationsWithItemsForSale.Add(station);
                    }
                }
            }
        }