Exemple #1
0
 public void checkOffer(int slot)
 {
     this.currentOffer = Server.getGrandExchange().getOfferForSlot(p, slot);
     if (currentOffer != null)
     {
         ItemData.ItemPrice price = currentOffer.getItemPrice();
         p.getPackets().sendConfig(1109, currentOffer.getItem());
         p.getPackets().sendConfig(1110, currentOffer.getTotalAmount());
         p.getPackets().sendConfig(1111, currentOffer.getPriceEach());
         p.getPackets().sendConfig(1112, currentOffer.getSlot());
         p.getPackets().sendConfig(1113, 0);
         p.getPackets().sendConfig(1114, price.getNormalPrice());
         p.getPackets().sendConfig(1116, price.getMaximumPrice());
         p.getPackets().sendConfig(1115, price.getMinimumPrice());
         Item slot1 = currentOffer.getSlot1();
         Item slot2 = currentOffer.getSlot2();
         if (currentOffer is BuyOffer)
         {
             //slot1 = currentOffer.getAmountTraded() == 0 ? null : new Item(currentOffer.getItem(), currentOffer.getAmountTraded());
             //slot2 = (currentOffer.getAmountTraded() == currentOffer.getTotalAmount()) ||  currentOffer.getAmountTraded() == 0 ? null : new Item(995, (currentOffer.getTotalAmount() - currentOffer.getAmountTraded()) * currentOffer.getPriceEach());
         }
         else
         {
             //slot1 = (currentOffer.getAmountTraded() == currentOffer.getTotalAmount()) ||  currentOffer.getAmountTraded() == 0 ? null : new Item(currentOffer.getUnNotedId(), currentOffer.getTotalAmount() - currentOffer.getAmountTraded());
             //slot2 = currentOffer.getAmountTraded() == 0 ? null : new Item(995, (currentOffer.getAmountTraded()) * currentOffer.getPriceEach());
         }
         Item[] items = { slot1, slot2 };
         currentOffer.setSlot1(slot1);
         currentOffer.setSlot2(slot2);
         p.getPackets().sendItems(-1, -1757, 523 + currentOffer.getSlot(), items);
     }
 }
Exemple #2
0
 public bool removeOffer(GEItem offer)
 {
     Dictionary<int, GEItem[]> offers = offer is BuyOffer ? buyOffers : sellOffers;
     lock (offers)
     {
         if (!offers.ContainsKey(offer.getDisplayItem()))
         {
             Misc.WriteError("Invalid GE item removal = Name: " + offer.getPlayerName() + " Item: " + offer.getItem() + " Amount: " + offer.getTotalAmount() + " Price: " + offer.getPriceEach());
             return false;
         }
         foreach (KeyValuePair<int, GEItem[]> eachOffer in offers)
         {
             if (eachOffer.Key == offer.getDisplayItem())
             {
                 for (int i = 0; i < eachOffer.Value.Length; i++)
                 {
                     if (eachOffer.Value[i] != null)
                     {
                         if (eachOffer.Value[i].Equals(offer))
                         {
                             eachOffer.Value[i] = null;
                             int entries = 0;
                             for (int j = 0; j < eachOffer.Value.Length; j++)
                             {
                                 if (eachOffer.Value[i] != null)
                                 {
                                     entries++;
                                 }
                             }
                             if (entries == 0)
                             {
                                 offers.Remove(offer.getDisplayItem());
                             }
                             return true;
                         }
                     }
                 }
                 return false;
             }
         }
     }
     return false;
 }
Exemple #3
0
        public bool removeOffer(GEItem offer)
        {
            Dictionary <int, GEItem[]> offers = offer is BuyOffer ? buyOffers : sellOffers;

            lock (offers)
            {
                if (!offers.ContainsKey(offer.getDisplayItem()))
                {
                    Misc.WriteError("Invalid GE item removal = Name: " + offer.getPlayerName() + " Item: " + offer.getItem() + " Amount: " + offer.getTotalAmount() + " Price: " + offer.getPriceEach());
                    return(false);
                }
                foreach (KeyValuePair <int, GEItem[]> eachOffer in offers)
                {
                    if (eachOffer.Key == offer.getDisplayItem())
                    {
                        for (int i = 0; i < eachOffer.Value.Length; i++)
                        {
                            if (eachOffer.Value[i] != null)
                            {
                                if (eachOffer.Value[i].Equals(offer))
                                {
                                    eachOffer.Value[i] = null;
                                    int entries = 0;
                                    for (int j = 0; j < eachOffer.Value.Length; j++)
                                    {
                                        if (eachOffer.Value[i] != null)
                                        {
                                            entries++;
                                        }
                                    }
                                    if (entries == 0)
                                    {
                                        offers.Remove(offer.getDisplayItem());
                                    }
                                    return(true);
                                }
                            }
                        }
                        return(false);
                    }
                }
            }
            return(false);
        }