예제 #1
0
        public void Sell(uint uid, uint quantity)
        {
            CharacterItemRecord item = this.Character.Inventory.GetItem(uid);

            if (item != null && item.CanBeExchanged() && item.Quantity >= quantity)
            {
                int gained = (int)(((double)item.Template.GetPrice(this.LevelPrice) / (double)10) * quantity);

                if (gained >= item.Template.GetPrice(this.LevelPrice))
                {
                    return;
                }

                gained = gained == 0 ? 1 : gained;

                this.Character.Inventory.RemoveItem(uid, quantity);

                if (this.TokenId == 0)
                {
                    this.Character.AddKamas(gained);
                }
                else
                {
                    this.Character.Inventory.AddItem(this.TokenId, (uint)gained);
                }

                this.Character.Client.Send(new ExchangeSellOkMessage());
            }
        }
예제 #2
0
        public override void MoveItem(uint uid, int quantity)
        {
            if (quantity > 0)
            {
                CharacterItemRecord item = this.Character.Inventory.GetItem(uid);

                if (item != null && item.Quantity >= quantity && item.CanBeExchanged())
                {
                    BankItemRecord bankItem = item.ToBankItemRecord(this.Character.Client.Account.Id);
                    bankItem.Quantity = (uint)quantity;
                    this.Character.Inventory.RemoveItem(item.UId, (uint)quantity);
                    this.m_items.AddItem(bankItem);
                }
            }
            else
            {
                BankItemRecord item            = this.m_items.GetItem(uid);
                uint           removedQuantity = (uint)Math.Abs(quantity);

                if (item != null && item.Quantity >= removedQuantity)
                {
                    CharacterItemRecord characterItemRecord = item.ToCharacterItemRecord(this.Character.Id);
                    characterItemRecord.Quantity = removedQuantity;
                    this.m_items.RemoveItem(uid, removedQuantity);
                    this.Character.Inventory.AddItem(characterItemRecord);
                }
            }
        }
예제 #3
0
        public void MoveItemPriced(uint uid, int quantity, uint price)
        {
            CharacterItemRecord item = this.Character.Inventory.GetItem(uid);

            if (item != null && item.Quantity >= quantity && item.CanBeExchanged())
            {
                BidShopItemRecord selledItem = item.ToBidShopItemRecord(this.BidShop.Id, this.Character.Client.Account.Id, price);
                selledItem.Quantity = (uint)quantity;
                this.Character.Inventory.RemoveItem(item.UId, (uint)quantity);
                this.AddSelledItem(selledItem);
            }
        }
        private bool CanMoveItem(CharacterItemRecord item, int quantity)
        {
            if (item.PositionEnum != CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED || !item.CanBeExchanged())
            {
                return(false);
            }

            CharacterItemRecord exchanged = null;

            exchanged = this.ExchangedItems.GetItem(item.GId, item.Effects);

            if (exchanged != null && exchanged.UId != item.UId)
            {
                return(false);
            }

            exchanged = this.ExchangedItems.GetItem(item.UId);

            if (exchanged == null)
            {
                return(true);
            }

            if (exchanged.Quantity + quantity > item.Quantity)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }