private Item GetItemDrop(MonsterDefinition monster, DropItemGroup selectedGroup) { if (selectedGroup != null) { if (selectedGroup.PossibleItems?.Count > 0) { var item = new TemporaryItem(); item.Definition = selectedGroup.PossibleItems.SelectRandom(this.randomizer); this.ApplyRandomOptions(item); return(item); } switch (selectedGroup.ItemType) { case SpecialItemType.Ancient: return(this.GetRandomAncient()); case SpecialItemType.Excellent: return(this.GetRandomExcellentItem((int)monster[Stats.Level])); case SpecialItemType.RandomItem: return(this.GetRandomItem((int)monster[Stats.Level], false)); case SpecialItemType.SocketItem: return(this.GetRandomItem((int)monster[Stats.Level], true)); } } return(null); }
/// <summary> /// Gets a random excellent item. /// </summary> /// <param name="monsterLvl">The monster level.</param> /// <returns>A random excellent item.</returns> protected Item GetRandomExcellentItem(int monsterLvl) { if (monsterLvl < 25) { return(null); } var possible = this.GetPossibleList(monsterLvl - 25); if (possible == null || !possible.Any()) { return(null); } var itemDef = possible.SelectRandom(this.randomizer); var item = new TemporaryItem(); item.Definition = itemDef; this.ApplyRandomOptions(item); if (itemDef.Skill != null && item.Definition.QualifiedCharacters.Any()) { item.HasSkill = true; // every excellent item got skill } this.AddRandomExcOptions(item); return(item); }
/// <summary> /// Gets a random item. /// </summary> /// <param name="monsterLvl">The monster level.</param> /// <param name="socketItems">if set to <c>true</c> [socket items].</param> /// <returns>A random item.</returns> protected Item GetRandomItem(int monsterLvl, bool socketItems) { var possible = this.GetPossibleList(monsterLvl).ToList(); if (!possible.Any()) { return(null); } var itemDef = possible.ElementAt(this.randomizer.NextInt(0, possible.Count)); var item = new TemporaryItem(); item.Definition = itemDef; item.Level = (byte)((monsterLvl - itemDef.DropLevel) / 3); this.ApplyRandomOptions(item); return(item); }
/// <summary> /// Gets a random ancient item. /// </summary> /// <returns>A random ancient item.</returns> protected Item GetRandomAncient() { Item item = new TemporaryItem(); item.Definition = this.ancientItems.SelectRandom(this.randomizer); this.ApplyRandomOptions(item); var itemDef = item.Definition; if (itemDef.Skill != null && item.Definition.QualifiedCharacters.Any()) { item.HasSkill = true; } var ancientSet = item.ItemSetGroups.Where(g => g.Options.Any(o => o.OptionType == ItemOptionTypes.AncientOption)).SelectRandom(this.randomizer); item.ItemSetGroups.Add(ancientSet); var bonusOption = ancientSet.Items.First(i => i.ItemDefinition == item.Definition).BonusOption; // for example: +5str or +10str var bonusOptionLink = new ItemOptionLink(); bonusOptionLink.ItemOption = bonusOption; bonusOptionLink.Level = bonusOption.LevelDependentOptions.Select(o => o.Level).SelectRandom(); item.ItemOptions.Add(bonusOptionLink); return(item); }