Esempio n. 1
0
 public void RequestForge(RealmTime time, RequestTradePacket pkt)
 {
     if (tradeTarget != null)
     {
         SendError("You're already trading!");
         tradeTarget = null;
         return;
     }
     trade = new bool[12];
     tradeAccepted = false;
     forging = true;
     ForgeList f = new ForgeList();
     foreach (var i in f.combos)
     {
         for (var x = 0; x < i.Key.Length; x++)
         {
             requestedItems.Add(i.Key[x]);
         }
         for (var x = 0; x < Inventory.Length; x++)
         {
             if (Inventory[x] != null)
             {
                 playerItems.Add(Inventory[x].ObjectId);
             }
         }
         for (var x = 0; x < playerItems.Count; x++)
         {
             for (var y = 0; y < requestedItems.Count; y++)
             {
                 if (requestedItems[y] == playerItems[x])
                 {
                     requestedItems.RemoveAt(y);
                     break;
                 }
             }
         }
         if (requestedItems.Count == 0)
         {
             var icdatas = new Dictionary<string, short>(db.data.XmlDatas.IdToType, StringComparer.OrdinalIgnoreCase);
             short objType;
             icdatas.TryGetValue(i.Value, out objType);
             forgableItems.Add(objType);
         }
     }
     if (forgableItems.Count < Inventory.Length)
     {
         for (var i = forgableItems.Count; i < Inventory.Length; i++)
         {
             forgableItems.Add(-1);
         }
     }
     var my = new TradeItem[Inventory.Length];
     for (var i = 0; i < Inventory.Length; i++)
     {
         my[i] = new TradeItem
         {
             Item = forgableItems[i],
             SlotType = SlotTypes[0],
             Included = false,
             Tradeable = forgableItems[i] != -1
         };
     }
     var your = new TradeItem[12];
     for (var i = 0; i < Inventory.Length; i++)
         your[i] = new TradeItem
         {
             Item = Inventory[i] == null ? -1 : Inventory[i].ObjectType,
             SlotType = SlotTypes[i],
             Included = false,
             Tradeable = false
         };
     psr.SendPacket(new TradeStartPacket
     {
         MyItems = my,
         YourName = "Items",
         YourItems = your
     });
 }
Esempio n. 2
0
        public void RequestForge(RealmTime time, RequestTradePacket pkt)
        {
            if (tradeTarget != null)
            {
                SendError("You're already trading!");
                tradeTarget = null;
                return;
            }
            trade         = new bool[12];
            tradeAccepted = false;
            forging       = true;
            ForgeList f = new ForgeList();

            foreach (var i in f.combos)
            {
                for (var x = 0; x < i.Key.Length; x++)
                {
                    requestedItems.Add(i.Key[x]);
                }
                for (var x = 0; x < Inventory.Length; x++)
                {
                    if (Inventory[x] != null)
                    {
                        playerItems.Add(Inventory[x].ObjectId);
                    }
                }
                for (var x = 0; x < playerItems.Count; x++)
                {
                    for (var y = 0; y < requestedItems.Count; y++)
                    {
                        if (requestedItems[y] == playerItems[x])
                        {
                            requestedItems.RemoveAt(y);
                            break;
                        }
                    }
                }
                if (requestedItems.Count == 0)
                {
                    var   icdatas = new Dictionary <string, short>(db.data.XmlDatas.IdToType, StringComparer.OrdinalIgnoreCase);
                    short objType;
                    icdatas.TryGetValue(i.Value, out objType);
                    forgableItems.Add(objType);
                }
            }
            if (forgableItems.Count < Inventory.Length)
            {
                for (var i = forgableItems.Count; i < Inventory.Length; i++)
                {
                    forgableItems.Add(-1);
                }
            }
            var my = new TradeItem[Inventory.Length];

            for (var i = 0; i < Inventory.Length; i++)
            {
                my[i] = new TradeItem
                {
                    Item      = forgableItems[i],
                    SlotType  = SlotTypes[0],
                    Included  = false,
                    Tradeable = forgableItems[i] != -1
                };
            }
            var your = new TradeItem[12];

            for (var i = 0; i < Inventory.Length; i++)
            {
                your[i] = new TradeItem
                {
                    Item      = Inventory[i] == null ? -1 : Inventory[i].ObjectType,
                    SlotType  = SlotTypes[i],
                    Included  = false,
                    Tradeable = false
                }
            }
            ;
            psr.SendPacket(new TradeStartPacket
            {
                MyItems   = my,
                YourName  = "Items",
                YourItems = your
            });
        }