private void OnReady(Trader trader, bool isready)
        {
            InventoryHandler.SendExchangeIsReadyMessage(Crafter.Character.Client,
                                                        trader, isready);
            InventoryHandler.SendExchangeIsReadyMessage(Receiver.Character.Client,
                                                        trader, isready);

            if (Receiver.Kamas > Receiver.Character.Inventory.Kamas)
            {
                InventoryHandler.SendExchangeCraftResultMessage(Clients, ExchangeCraftResultEnum.CRAFT_FAILED);
                return;
            }

            if (Crafter.ReadyToApply && Receiver.ReadyToApply)
            {
                ApplyAllRunes();

                if (Receiver.Kamas > 0)
                {
                    Crafter.Character.Inventory.AddKamas(-Receiver.Character.Inventory.SubKamas((int)Receiver.Kamas));
                    Receiver.SetKamas(0);
                }

                ContextRoleplayHandler.SendJobExperienceOtherPlayerUpdateMessage(Receiver.Character.Client, Crafter.Character, Job);
            }

            else if (trader == Receiver && !isready) // stop the trade
            {
                foreach (var item in Crafter.Items.OfType <PlayerTradeItem>().ToArray())
                {
                    if (Crafter.Character == item.Owner)
                    {
                        Crafter.MoveItemToInventory(item, 0);
                    }
                    else if (item.Owner == Receiver.Character)
                    {
                        RuneCrafter.MoveItemFromBag(item.PlayerItem, Receiver, 0);
                    }
                }

                /*
                 * if (Rune != null && Rune.Trader == Receiver)
                 *  Rune.Trader.MoveItem(Rune.Guid, (int) -Rune.Stack);
                 *
                 * var itemToImprove = ItemToImprove;
                 * Crafter.MoveItem(itemToImprove.Guid, (int) -itemToImprove.Stack);
                 * Receiver.MoveItem(itemToImprove.Guid, (int) itemToImprove.Stack);*/
            }
        }
        public void MoveItemFromBag(int id, int quantity)
        {
            if (!Receiver.ReadyToApply)
            {
                return;
            }

            var item = Receiver.Character.Inventory[id];

            if (item != null)
            {
                RuneCrafter.MoveItemFromBag(item, Receiver, quantity);
                Receiver.MoveItem(id, -quantity);
            }
        }
        public override void Close()
        {
            foreach (var item in Crafter.Items.OfType <PlayerTradeItem>().ToArray())
            {
                if (Crafter.Character == item.Owner)
                {
                    Crafter.MoveItemToInventory(item, 0);
                }
                else if (item.Owner == Receiver.Character)
                {
                    RuneCrafter.MoveItemFromBag(item.PlayerItem, Receiver, 0);
                }
            }

            Crafter.Character.ResetDialog();
            Receiver.Character.ResetDialog();
            InventoryHandler.SendExchangeLeaveMessage(Clients, DialogType, false);
        }
Exemple #4
0
 public SingleRuneMagicCraftDialog(Character character, InteractiveObject interactive, Skill skill)
     : base(interactive, skill, character.Jobs[skill.SkillTemplate.ParentJobId])
 {
     Crafter = new RuneCrafter(this, character);
     Clients = new WorldClientCollection(character.Client);
 }