コード例 #1
0
ファイル: RealmParser.cs プロジェクト: T4NK/SunDofus
        private void ExchangeBuy(string packet)
        {
            if (!Client.Player.State.onExchange)
            {
                Client.Send("OBE");
                return;
            }

            var datas = packet.Split('|');
            var itemID = 0;
            var quantity = 1;

            if (!int.TryParse(datas[0], out itemID) || int.TryParse(datas[1], out quantity))
                return;

            var item = Entities.Cache.ItemsCache.ItemsList.First(x => x.ID == itemID);
            var NPC = Client.Player.GetMap().Npcs.First(x => x.ID == Client.Player.State.actualNPC);

            if (quantity <= 0 || !NPC.Model.SellingList.Contains(itemID))
            {
                Client.Send("OBE");
                return;
            }

            var price = item.Price * quantity;

            if (Client.Player.Kamas >= price)
            {
                var newItem = new SunDofus.World.Realm.Characters.Items.CharacterItem(item);
                newItem.GeneratItem(4);
                newItem.Quantity = quantity;

                Client.Player.Kamas -= price;
                Client.Send("EBK");
                Client.Player.ItemsInventary.AddItem(newItem, false);
            }
            else
                Client.Send("OBE");
        }
コード例 #2
0
ファイル: RealmClient.cs プロジェクト: T4NK/SunDofus
        public void SendGifts()
        {
            Infos.ParseGifts();

            foreach (var gift in Infos.Gifts)
            {
                if (Entities.Cache.ItemsCache.ItemsList.Any(x => x.ID == gift.ItemID) == false)
                    return;

                var item = new SunDofus.World.Realm.Characters.Items.CharacterItem(Entities.Cache.ItemsCache.ItemsList.First(x => x.ID == gift.ItemID));

                item.GeneratItem();

                gift.Item = item;

                this.Send(string.Format("Ag1|{0}|{1}|{2}|{3}|{4}~{5}~{6}~~{7};", gift.ID, gift.Title, gift.Message, (gift.Image != "" ? gift.Image : "http://s2.e-monsite.com/2009/12/26/04/167wpr7.png"),
                   Utilities.Basic.DeciToHex(item.Model.ID), Utilities.Basic.DeciToHex(item.Model.ID), Utilities.Basic.DeciToHex(item.Quantity), item.EffectsInfos()));
            }
        }
コード例 #3
0
ファイル: RealmCommand.cs プロジェクト: T4NK/SunDofus
        private void ParseCommandItem(string[] datas)
        {
            try
            {
                var item = Entities.Cache.ItemsCache.ItemsList.First(x => x.ID == int.Parse(datas[1]));

                if (datas.Length == 2)
                {
                    var newItem = new SunDofus.World.Realm.Characters.Items.CharacterItem(item);
                    newItem.GeneratItem();

                    Client.Player.ItemsInventary.AddItem(newItem, false);
                    Client.SendConsoleMessage("Item Added !", 0);
                }

                else if (datas.Length == 3)
                {
                    var newItem = new SunDofus.World.Realm.Characters.Items.CharacterItem(item);
                    newItem.GeneratItem(int.Parse(datas[2]));

                    Client.Player.ItemsInventary.AddItem(newItem, false);
                    Client.SendConsoleMessage("Item Added !", 0);
                }

                else
                    Client.SendConsoleMessage("Invalid Syntax !");
            }
            catch
            {
                Client.SendConsoleMessage("Cannot parse your AdminCommand !");
                Client.SendConsoleMessage("Use the command 'Help' for more informations !");
            }
        }