コード例 #1
0
ファイル: Merchant.cs プロジェクト: hybrasyl/server
 public MerchantInventoryItem(Xml.Item item, uint onHand, uint restockAmount, int restockInterval, DateTime lastRestock)
 {
     Item            = item;
     OnHand          = onHand;
     RestockAmount   = restockAmount;
     RestockInterval = restockInterval;
     LastRestock     = lastRestock;
 }
コード例 #2
0
    public new static ChatCommandResult Run(User user, params string[] args)
    {
        if (args.Length < 4)
        {
            return(Fail($"Wrong number of arguments supplied."));
        }
        ushort sprite;
        ushort displaysprite;

        if (!ushort.TryParse(args[2], out sprite))
        {
            return(Fail($"Sprite must be a number."));
        }
        if (!ushort.TryParse(args[3], out displaysprite))
        {
            return(Fail($"Displaysprite must be a number."));
        }
        switch (args[0].ToLower())
        {
        case "armor":
        {
            var item = new Xml.Item()
            {
                Name       = "GeneratedArmor" + GeneratedId,
                Properties = new Xml.ItemProperties()
                {
                    Stackable = new Xml.Stackable()
                    {
                        Max = 1
                    },
                    Physical = new Xml.Physical()
                    {
                        Durability = 1000,
                        Value      = 1,
                        Weight     = 1
                    },
                    Restrictions = new Xml.ItemRestrictions()
                    {
                        Gender = (Xml.Gender)Enum.Parse(typeof(Xml.Gender), args[1]),
                        Level  = new Xml.RestrictionsLevel()
                        {
                            Min = 1
                        }
                    },
                    Appearance = new Xml.Appearance()
                    {
                        BodyStyle     = (Xml.ItemBodyStyle)Enum.Parse(typeof(Xml.ItemBodyStyle), args[1]),
                        Sprite        = sprite,
                        DisplaySprite = displaysprite
                    },
                    Equipment = new Xml.Equipment()
                    {
                        Slot = Xml.EquipmentSlot.Armor
                    }
                }
            };
            Game.World.WorldData.SetWithIndex <Xml.Item>(item.Id, item, item.Name);
            user.AddItem(item.Name, 1);
        }
        break;

        case "coat":
        {
            var item = new Xml.Item()
            {
                Name       = "GeneratedArmor" + GeneratedId,
                Properties = new Xml.ItemProperties()
                {
                    Stackable = new Xml.Stackable()
                    {
                        Max = 1
                    },
                    Physical = new Xml.Physical()
                    {
                        Durability = 1000,
                        Value      = 1,
                        Weight     = 1
                    },
                    Restrictions = new Xml.ItemRestrictions()
                    {
                        Gender = (Xml.Gender)Enum.Parse(typeof(Xml.Gender), args[1]),
                        Level  = new Xml.RestrictionsLevel()
                        {
                            Min = 1
                        }
                    },
                    Appearance = new Xml.Appearance()
                    {
                        BodyStyle     = (Xml.ItemBodyStyle)Enum.Parse(typeof(Xml.ItemBodyStyle), args[1]),
                        Sprite        = sprite,
                        DisplaySprite = displaysprite
                    },
                    Equipment = new Xml.Equipment()
                    {
                        Slot = Xml.EquipmentSlot.Trousers
                    }
                }
            };
            Game.World.WorldData.SetWithIndex <Xml.Item>(item.Id, item, item.Name);
            user.AddItem(item.Name, 1);
        }
        break;
        }
        GeneratedId++;
        return(Success($"GeneratedArmor{GeneratedId -1} added to World Data."));
    }