예제 #1
0
        public static void HandleShopUpdateItem(Character pCharacter, byte inv, short invslot, short bundle, short bundleamount, int price)
        {
            MiniRoomBase mrb = pCharacter.Room;

            if (pCharacter.AssertForHack(mrb.Users[0] != pCharacter,
                                         "PlayerShop hack: Tried to update shop item while not owner."))
            {
                return;
            }

            BaseItem tehItem = pCharacter.Inventory.GetItem(inv, invslot);

            if (tehItem == null)
            {
                //Doesn't have item in inventory
                ReportManager.FileNewReport("Tried adding an item into player shop without having it.", pCharacter.ID, 0);
                InventoryPacket.NoChange(pCharacter);
                return;
            }

            var newItem = tehItem.Duplicate();

            newItem.InventorySlot = invslot;

            if (newItem.Amount < bundle || bundle <= 0 || bundle > 100)
            {
                //Packet edits
                ReportManager.FileNewReport("Tried adding an item into player shop with an incorrect amount/incorrect itemid.", pCharacter.ID, 0);
                InventoryPacket.NoChange(pCharacter);
                return;
            }

            PlayerShopItem pst = new PlayerShopItem(newItem)
            {
                Price = price
            };

            pst.sItem.Amount = (short)(bundle * bundleamount);
            pst.Bundles      = bundle;
            pst.BundleAmount = bundleamount;
            mrb.AddItemToShop(pCharacter, pst);
            if (Constants.isStackable(pst.sItem.ItemID))
            {
                pCharacter.Inventory.TakeItemAmountFromSlot(inv, invslot, (short)(bundle * bundleamount), false);
            }
            else
            {
                pCharacter.Inventory.TakeItem(pst.sItem.ItemID, bundle);
            }

            ItemTransfer.PersonalShopPutUpItem(pCharacter.ID, pst.sItem.ItemID, pst.sItem.Amount, mrb.TransactionID, pst.sItem);

            InventoryPacket.NoChange(pCharacter); //-.-
        }
예제 #2
0
 public override void AddItemToShop(Character pCharacter, PlayerShopItem Item)
 {
     if (Items.Count == 0)
     {
         Items.Add(0, Item);
         Item.ShopSlot = 0;
     }
     else
     {
         Items.Add((byte)Items.Count, Item);
         Item.ShopSlot = (byte)Items.Count;
     }
     PlayerShopPackets.PersonalShopRefresh(pCharacter, this);
     base.AddItemToShop(pCharacter, Item);
 }
예제 #3
0
        public void BuyItem(Character pCharacter, byte slot, short quantity)
        {
            //This may seem confusing, but the client calculates the amount left itself.
            //The formula is bundles * bundleamount, so if you have 2 bundles with 25 in each, it will obviously show 50. If you have 100 items in 1 bundle, it will show you 100
            PlayerShopItem pst = Items[slot];
            PlayerShop     ps  = MiniRoomBase.PlayerShops[pCharacter.Room.ID];

            if (pst == null)
            {
                return;
            }

            if (pCharacter.AssertForHack(
                    quantity < 0,
                    $"PlayerShop hack: trying to buy negative amount. Requested {quantity}"
                    ))
            {
                return;
            }

            if (pst.sItem.Amount <= 0)
            {
                // TODO: Get packet?
                return;
            }


            var cost       = quantity * pst.Price;
            var realAmount = (short)(quantity * pst.BundleAmount);

            if (cost > pCharacter.Inventory.Mesos)
            {
                // TODO: Get packet?
                return;
            }

            if (pCharacter.AssertForHack(
                    pst.Bundles < quantity,
                    $"PlayerShop hack: buying more than there's in store. Bundle: {pst.Bundles}, requested {quantity}"
                    ))
            {
                return;
            }

            if (pCharacter.AssertForHack(
                    pst.sItem.Amount < realAmount,
                    $"PlayerShop hack: buying more than there's in store. Item amount: {pst.sItem.Amount}, requested {realAmount}"
                    ))
            {
                return;
            }


            pCharacter.Inventory.AddNewItem(pst.sItem.ItemID, realAmount);
            pCharacter.AddMesos(-cost);
            Owner.AddMesos(cost);

            MesosTransfer.PlayerBuysFromPersonalShop(pCharacter.ID, Owner.ID, cost, _transaction);
            ItemTransfer.PersonalShopBoughtItem(Owner.ID, pCharacter.ID, pst.sItem.ItemID, realAmount, TransactionID, pst.sItem);



            pst.Bundles      -= quantity;
            pst.sItem.Amount -= realAmount;

            PlayerShopPackets.PersonalShopRefresh(pCharacter, ps);
            PlayerShopPackets.SoldItemResult(Owner, pCharacter, slot, quantity);
        }
예제 #4
0
 public virtual void AddItemToShop(Character pCharacter, PlayerShopItem Item)
 {
 }