예제 #1
0
        public void collectSlot2()
        {
            /*
             * Collects money slot
             */
            if (currentOffer == null)
            {
                p.getPackets().sendMessage("[collectSlot2]: Nice try cheater!, If this is bug please report it.");
                return;
            }

            if (currentOffer.getSlot2() != null)
            {
                int playerInventoryGoldAmount = p.getInventory().getItemAmount(995);
                int grandExchangeSlot2GoldAmountToWithdraw = currentOffer.getSlot2().getItemAmount();

                if (playerInventoryGoldAmount >= Inventory.MAX_ITEM_AMOUNT)
                {
                    p.getPackets().sendMessage("You cannot collect anymore money, you have maximum money in inventory.");
                    return;
                }

                //if player's inventory gold + slot2 gold is more then you can hold for that inventory item.

                /*
                 * have to cast both amounts with (long)
                 * because the way they are both (int)'s, they might create a negitive number
                 * and that negitive number is less then MAX_ITEM_AMOUNT so it wont work properly.
                 */
                if (((long)playerInventoryGoldAmount + (long)grandExchangeSlot2GoldAmountToWithdraw) > Inventory.MAX_ITEM_AMOUNT)
                {
                    grandExchangeSlot2GoldAmountToWithdraw = (Inventory.MAX_ITEM_AMOUNT - playerInventoryGoldAmount);
                }

                /*
                 * Change Slot2's amount based on how much left over
                 * if any when added to inventory after max item amount check.
                 */
                if (p.getInventory().addItem(995, grandExchangeSlot2GoldAmountToWithdraw))
                {
                    currentOffer.getSlot2().setItemAmount(currentOffer.getSlot2().getItemAmount() - grandExchangeSlot2GoldAmountToWithdraw);
                }

                currentOffer.setAmountCollectedGold(currentOffer.getAmountCollectedGold() + grandExchangeSlot2GoldAmountToWithdraw);

                /*
                 * Clear Slot2's Gold Item, if gold item amount <=0
                 */
                if (currentOffer.getSlot2().getItemAmount() <= 0)
                {
                    currentOffer.setSlot2(null);
                }

                updateSlotStates();
            }
        }
예제 #2
0
        public void checkOffer(byte slot)
        {
            this.currentOffer = myGEItems[slot];

            /*
             * The line below always gets the GEItem by player and GE slot from database.
             * It's alot slower to keep retrieving it from database.
             * Line above this comment uses the preloaded GEItems
             * That should be the same thing, But faster.
             */
            //this.currentOffer = Server.getGrandExchange().getOfferByPlayerSlot(p, slot);

            if (currentOffer == null)
            {
                p.getPackets().sendMessage("[checkOffer]: Nice try cheater!, If this is bug please report it.");
                return;
            }

            ItemData.ItemPrice price = currentOffer.getItemPrice();
            ItemData.Item      def   = ItemData.forId(currentOffer.getItem());

            if (def == null)
            {
                p.getPackets().sendMessage("Item: " + currentOffer.getItem() + " cannot be found in item definitions, please report it.");
                return;
            }

            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());
            p.getPackets().modifyText(def.getExamine(), 105, 142); //item examine text.

            if (currentOffer is BuyOffer)
            {
                //A Buyer can have how much of the item's he bought shown even if they aborted the currentOffer.
                currentOffer.setSlot1((currentOffer.getAmountItemsLeftToCollect() > 0) ? new Item(currentOffer.getItem(), currentOffer.getAmountItemsLeftToCollect()) : null);

                /**If Buyer Aborted the item buying, it shows UnBought item gold + Overpay gold
                 * If Buyer doesn't abort the item it shows just Overpay gold.
                 */
                if (currentOffer.isAborted())
                {
                    currentOffer.setSlot2((currentOffer.getTotalAmountGoldLeftToCollect() > 0) ? new Item(995, currentOffer.getTotalAmountGoldLeftToCollect()) : null);
                }
                else
                {
                    currentOffer.setSlot2((currentOffer.getAmountCollectedGold() < currentOffer.getAmountOverpaid()) ? new Item(995, currentOffer.getAmountOverpaid()) : null);
                }
            }
            else if (currentOffer is SellOffer)
            {
                //If Seller Aborted the item selling, it shows UnSold items
                currentOffer.setSlot1((currentOffer.isAborted() && currentOffer.getTotalAmountItemsLeftToCollect() > 0) ? new Item(currentOffer.getItem(), currentOffer.getTotalAmountItemsLeftToCollect()) : null);

                //Always shows Seller Item Sold Gold + Overpay gold (shows how much money you made from sales + overpays.)
                currentOffer.setSlot2((currentOffer.getAmountGoldLeftToCollect() > 0) ? new Item(995, currentOffer.getAmountGoldLeftToCollect()) : null);
            }

            Item[] items = { currentOffer.getSlot1(), currentOffer.getSlot2() };
            p.getPackets().sendItems(-1, -1757, 523 + currentOffer.getSlot(), items);
        }