示例#1
0
        private void TransferItems()
        {
            if (_cleanuped)
            {
                return;
            }
            if (ItemsTransfered)
            {
                return;
            }
            ItemsTransfered = true;
            var firstCharItemsCount =
                FirstCharacterItems.Count(i => i != null && i.Item != null && i.Item.ItemId != 20551);
            var secondCharItemsCount =
                SecondCharacterItems.Count(i => i != null && i.Item != null && i.Item.ItemId != 20551);

            if (TradeType == Asda2TradeType.RedularTrade)
            {
                if (SecondChar.Asda2Inventory.FreeRegularSlotsCount < firstCharItemsCount || FisrtChar.Asda2Inventory.FreeRegularSlotsCount < secondCharItemsCount)
                {
                    FisrtChar.SendSystemMessage("Check free space in inventory!.");
                    SecondChar.SendSystemMessage("Check free space in inventory!.");
                    CancelTrade();
                    return;
                }
            }
            else
            {
                if (SecondChar.Asda2Inventory.FreeShopSlotsCount < firstCharItemsCount || FisrtChar.Asda2Inventory.FreeShopSlotsCount < secondCharItemsCount)
                {
                    FisrtChar.SendSystemMessage("Check free space in inventory!.");
                    SecondChar.SendSystemMessage("Check free space in inventory!.");
                    CancelTrade();
                    return;
                }
            }
            var newItemsOfSecond = Transfer(FirstCharacterItems, SecondChar);
            var newItemsOfFirst  = Transfer(SecondCharacterItems, FisrtChar);

            if (TradeType == Asda2TradeType.RedularTrade)
            {
                Asda2TradeHandler.SendRegularTradeCompleteResponse(FisrtChar.Client, newItemsOfFirst);
                Asda2TradeHandler.SendRegularTradeCompleteResponse(SecondChar.Client, newItemsOfSecond);
            }
            else
            {
                Asda2TradeHandler.SendShopTradeCompleteResponse(FisrtChar.Client, newItemsOfFirst);
                Asda2TradeHandler.SendShopTradeCompleteResponse(SecondChar.Client, newItemsOfSecond);
            }
            FisrtChar.SendMoneyUpdate();
            SecondChar.SendMoneyUpdate();
        }
示例#2
0
        private void TransferItems()
        {
            if (this._cleanuped || this.ItemsTransfered)
            {
                return;
            }
            this.ItemsTransfered = true;
            int num1 = ((IEnumerable <Asda2ItemTradeRef>) this.FirstCharacterItems).Count <Asda2ItemTradeRef>(
                (Func <Asda2ItemTradeRef, bool>)(i =>
            {
                if (i != null && i.Item != null)
                {
                    return(i.Item.ItemId != 20551);
                }
                return(false);
            }));
            int num2 = ((IEnumerable <Asda2ItemTradeRef>) this.SecondCharacterItems).Count <Asda2ItemTradeRef>(
                (Func <Asda2ItemTradeRef, bool>)(i =>
            {
                if (i != null && i.Item != null)
                {
                    return(i.Item.ItemId != 20551);
                }
                return(false);
            }));

            if (this.TradeType == Asda2TradeType.RedularTrade)
            {
                if (this.SecondChar.Asda2Inventory.FreeRegularSlotsCount < num1 ||
                    ((IEnumerable <Asda2Item>) this.FisrtChar.Asda2Inventory.RegularItems).Count <Asda2Item>(
                        (Func <Asda2Item, bool>)(i => i == null)) < num2)
                {
                    this.FisrtChar.SendSystemMessage("Check free space in inventory!.");
                    this.SecondChar.SendSystemMessage("Check free space in inventory!.");
                    this.CancelTrade();
                    return;
                }
            }
            else if (((IEnumerable <Asda2Item>) this.SecondChar.Asda2Inventory.ShopItems).Count <Asda2Item>(
                         (Func <Asda2Item, bool>)(i => i == null)) < num1 ||
                     ((IEnumerable <Asda2Item>) this.FisrtChar.Asda2Inventory.ShopItems).Count <Asda2Item>(
                         (Func <Asda2Item, bool>)(i => i == null)) < num2)
            {
                this.FisrtChar.SendSystemMessage("Check free space in inventory!.");
                this.SecondChar.SendSystemMessage("Check free space in inventory!.");
                this.CancelTrade();
                return;
            }

            Asda2Item[] items1 =
                this.Transfer((IEnumerable <Asda2ItemTradeRef>) this.FirstCharacterItems, this.SecondChar);
            Asda2Item[] items2 =
                this.Transfer((IEnumerable <Asda2ItemTradeRef>) this.SecondCharacterItems, this.FisrtChar);
            if (this.TradeType == Asda2TradeType.RedularTrade)
            {
                Asda2TradeHandler.SendRegularTradeCompleteResponse(this.FisrtChar.Client, items2);
                Asda2TradeHandler.SendRegularTradeCompleteResponse(this.SecondChar.Client, items1);
            }
            else
            {
                Asda2TradeHandler.SendShopTradeCompleteResponse(this.FisrtChar.Client, items2);
                Asda2TradeHandler.SendShopTradeCompleteResponse(this.SecondChar.Client, items1);
            }

            this.FisrtChar.SendMoneyUpdate();
            this.SecondChar.SendMoneyUpdate();
        }
示例#3
0
        private void TransferItems()
        {
            if (_cleanuped || ItemsTransfered)
            {
                return;
            }
            ItemsTransfered = true;
            int num1 = FirstCharacterItems.Count(
                i =>
            {
                if (i != null && i.Item != null)
                {
                    return(i.Item.ItemId != 20551);
                }
                return(false);
            });
            int num2 = SecondCharacterItems.Count(
                i =>
            {
                if (i != null && i.Item != null)
                {
                    return(i.Item.ItemId != 20551);
                }
                return(false);
            });

            if (TradeType == Asda2TradeType.RedularTrade)
            {
                if (SecondChar.Asda2Inventory.FreeRegularSlotsCount < num1 ||
                    FisrtChar.Asda2Inventory.RegularItems.Count(
                        i => i == null) < num2)
                {
                    FisrtChar.SendSystemMessage("Check free space in inventory!.");
                    SecondChar.SendSystemMessage("Check free space in inventory!.");
                    CancelTrade();
                    return;
                }
            }
            else if (SecondChar.Asda2Inventory.ShopItems.Count(
                         i => i == null) < num1 ||
                     FisrtChar.Asda2Inventory.ShopItems.Count(
                         i => i == null) < num2)
            {
                FisrtChar.SendSystemMessage("Check free space in inventory!.");
                SecondChar.SendSystemMessage("Check free space in inventory!.");
                CancelTrade();
                return;
            }

            Asda2Item[] items1 =
                Transfer(FirstCharacterItems, SecondChar);
            Asda2Item[] items2 =
                Transfer(SecondCharacterItems, FisrtChar);
            if (TradeType == Asda2TradeType.RedularTrade)
            {
                Asda2TradeHandler.SendRegularTradeCompleteResponse(FisrtChar.Client, items2);
                Asda2TradeHandler.SendRegularTradeCompleteResponse(SecondChar.Client, items1);
            }
            else
            {
                Asda2TradeHandler.SendShopTradeCompleteResponse(FisrtChar.Client, items2);
                Asda2TradeHandler.SendShopTradeCompleteResponse(SecondChar.Client, items1);
            }

            FisrtChar.SendMoneyUpdate();
            SecondChar.SendMoneyUpdate();
        }