示例#1
0
文件: BaseZone.cs 项目: elavanis/Mud
        public T CreateItem <T>()
        {
            Type  type = typeof(T);
            IItem item = null;

            if (type == typeof(IItem) ||
                type == typeof(Item))
            {
                item = new Item();
            }
            else if (type == typeof(Fountain))
            {
                item = new Fountain();
            }
            else if (type == typeof(IRecallBeacon) ||
                     type == typeof(RecallBeacon))
            {
                item = new RecallBeacon();
            }
            else if (type == typeof(IContainer) ||
                     type == typeof(Container))
            {
                item = new Container();
            }
            else if (type == typeof(IEnchantery) ||
                     type == typeof(Enchantery))
            {
                item = new Enchantery();
            }
            else if (type == typeof(IMoney) ||
                     type == typeof(Money))
            {
                item = new Money();
            }

            if (item == null)
            {
                throw new Exception($"Unsupported type {type.ToString()}");
            }
            else
            {
                item.Id   = ItemId++;
                item.Zone = Zone.Id;
            }

            return((T)item);
        }
示例#2
0
        public void Setup()
        {
            enchantery   = new Enchantery();
            weapon       = new Mock <IWeapon>();
            armor        = new Mock <IArmor>();
            random       = new Mock <IRandom>();
            defaults     = new Mock <IDefaultValues>();
            tagWrapper   = new Mock <ITagWrapper>();
            enchantments = new List <IEnchantment>();

            weapon.Setup(e => e.Enchantments).Returns(enchantments);
            armor.Setup(e => e.Enchantments).Returns(enchantments);
            random.Setup(e => e.PercentDiceRoll(100)).Returns(true);
            random.Setup(e => e.PercentDiceRoll(1)).Returns(false);
            defaults.Setup(e => e.DiceForWeaponLevel(0)).Returns(new Dice(1, 2));


            GlobalReference.GlobalValues.Random        = random.Object;
            GlobalReference.GlobalValues.DefaultValues = defaults.Object;
            GlobalReference.GlobalValues.TagWrapper    = tagWrapper.Object;
        }