public IEntity CreateItem(int itemLevel, IRandom random, ItemClassPicker itemClassPicker, RarityPicker rarityPicker)
        {
            IEntity   selectedItem;
            ItemClass itemClass;

            if (itemClassPicker == null)
            {
                selectedItem = random.PickOne(_itemList);
                itemClass    = ItemClassHelper.Classify(selectedItem);
            }
            else
            {
                itemClass = itemClassPicker.ItemClass;

                var itemsInClass = _itemsByClass[itemClass];

                selectedItem = random.PickOne(itemsInClass);
            }
            var item = _systemContainer.PrototypeSystem.Get(selectedItem);

            ApplyItemClassSpecificChanges(item, itemClass, itemLevel, random);

            if (IsEnchantable(item, itemClass))
            {
                Enchant(item, itemClass, itemLevel, random, rarityPicker);
            }

            SetItemPrice(item);

            return(item);
        }
Beispiel #2
0
        public bool Apply(EventType type, IEntity sender, object eventData)
        {
            if (sender.Has <Equipped>() && sender.Has <Challenge>())
            {
                var equippedItems = systemContainer.EquipmentSystem.GetEquippedItems(sender);
                var level         = sender.Get <Challenge>().ChallengeRating;

                var gen = new EnchantedItemGenerator(systemContainer, new List <IEntity>());

                foreach (var item in equippedItems)
                {
                    var rarity = systemContainer.Random.PickOne(RarityPicker.RarityPickers);

                    gen.Enchant(item, ItemClassHelper.Classify(item), level, systemContainer.Random, rarity);
                }
            }

            return(true);
        }
        public static string Describe(IEntity item)
        {
            StringBuilder sb = new StringBuilder();

            var itemClass = ItemClassHelper.Classify(item);
            var stats     = item.Components.OfType <Stat>();

            switch (itemClass)
            {
            case ItemClass.Other:
                break;

            case ItemClass.Shield:
            case ItemClass.Amulet:
            case ItemClass.Ring:
            case ItemClass.Boots:
            case ItemClass.Gloves:
                AppendStandardLines(itemClass.ToString(), item, sb, stats);
                break;

            case ItemClass.HeavyWeapon:
                AppendStandardLines("Heavy Weapon", item, sb, stats);
                break;

            case ItemClass.LightWeapon:
                AppendStandardLines("Light Weapon", item, sb, stats);
                break;

            case ItemClass.RangedWeapon:
                AppendStandardLines("Ranged Weapon", item, sb, stats);
                break;

            case ItemClass.MagicWeapon:
                AppendStandardLines("Magic Weapon", item, sb, stats);
                break;

            case ItemClass.Head:
                AppendStandardLines("Head Armour", item, sb, stats);
                break;

            case ItemClass.Body:
                AppendStandardLines("Body Armour", item, sb, stats);
                break;

            case ItemClass.Legs:
                AppendStandardLines("Leg Armour", item, sb, stats);
                break;

            case ItemClass.Ammunition:
                var ammunition = item.Get <Ammunition>();
                var stackable  = item.Get <Stackable>();
                sb.AppendLine("Ammunition");
                sb.AppendLine($"Ammunition Type: {ammunition.AmmunitionType}");
                sb.AppendLine($"Amount: {stackable.StackSize}");
                break;

            case ItemClass.Potion:
                sb.AppendLine("Potion");
                break;

            case ItemClass.SkillBook:
                var skill = item.Get <KnownSkill>();
                sb.AppendLine("Skill Book");
                sb.AppendLine("Teaches " + skill.Skill);
                break;

            case ItemClass.Wealth:
                var wealth = item.Get <Wealth>();
                sb.AppendLine("Wealth");
                sb.AppendLine($"Value: {wealth.Amount} {wealth.Currency}");
                break;

            default:
                throw new ApplicationException($"Can't describe item: unknown item class {itemClass}");
            }

            return(sb.ToString());
        }