public void Setup() { mockTypeAndAmountPercentileSelector = new Mock <ITypeAndAmountPercentileSelector>(); alchemicalItemGenerator = new AlchemicalItemGenerator(mockTypeAndAmountPercentileSelector.Object); selection = new TypeAndAmountSelection(); itemVerifier = new ItemVerifier(); }
private TypeAndAmountSelection Parse(string entry) { var sections = TypeAndAmountHelper.Parse(entry); var selection = new TypeAndAmountSelection(); selection.Type = sections[0]; selection.Amount = dice.Roll(sections[1]).AsSum(); return(selection); }
public void Setup() { mockTypeAndAmountPercentileSelector = new Mock <ITypeAndAmountPercentileSelector>(); generator = new CoinGenerator(mockTypeAndAmountPercentileSelector.Object); selection = new TypeAndAmountSelection(); selection.Type = "coin type"; selection.Amount = 9266; mockTypeAndAmountPercentileSelector.Setup(p => p.SelectFrom(It.IsAny <string>())).Returns(selection); }
private Good GenerateGood(TypeAndAmountSelection quantity) { var valueTableName = string.Format(TableNameConstants.Percentiles.Formattable.GOODTYPEValues, quantity.Type); var descriptionTableName = string.Format(TableNameConstants.Collections.Formattable.GOODTYPEDescriptions, quantity.Type); var valueSelection = typeAndAmountPercentileSelector.SelectFrom(valueTableName); var good = new Good(); good.Description = collectionSelector.SelectRandomFrom(descriptionTableName, valueSelection.Type); good.ValueInGold = valueSelection.Amount; return(good); }
private RequiredSkillSelection ParseRequiredSkillData(TypeAndAmountSelection selection) { var splitData = SkillConstants.Parse(selection.Type); var requiredSkill = new RequiredSkillSelection(); requiredSkill.Skill = splitData[0]; requiredSkill.Ranks = selection.Amount; if (splitData.Length > 1) { requiredSkill.Focus = splitData[1]; } return(requiredSkill); }
public void SelectAdvancedChallengeRatingBySize(string originalSize, string advancedSize, string originalChallengeRating, string advancedChallengeRating) { SetUpAdvancement(advancedSize, 1); var typeAndAmount = new TypeAndAmountSelection(); typeAndAmount.Type = "creature type"; typeAndAmount.Amount = 2; mockTypeAndAmountSelector.Setup(s => s.SelectOne(TableNameConstants.TypeAndAmount.Advancements, "creature type")).Returns(typeAndAmount); var advancement = advancementSelector.SelectRandomFor("creature", creatureType, originalSize, originalChallengeRating); Assert.That(advancement.AdditionalHitDice, Is.EqualTo(1)); Assert.That(advancement.Size, Is.EqualTo(advancedSize)); Assert.That(advancement.AdjustedChallengeRating, Is.EqualTo(advancedChallengeRating)); }
private BonusSelection Parse(TypeAndAmountSelection input) { var selection = new BonusSelection(); selection.Bonus = input.Amount; var sections = input.Type.Split(BonusSelection.Divider); selection.Target = sections[0]; if (sections.Length > 1) { selection.Condition = sections[1]; } return(selection); }
public void SelectAdvancedChallengeRatingByHitDice(string challengeRating, int hitDice, int divisor, string advancedChallengeRating) { SetUpAdvancement(SizeConstants.Medium, hitDice); var typeAndAmount = new TypeAndAmountSelection(); typeAndAmount.Type = "creature type"; typeAndAmount.Amount = divisor; mockTypeAndAmountSelector.Setup(s => s.SelectOne(TableNameConstants.TypeAndAmount.Advancements, "creature type")).Returns(typeAndAmount); var advancement = advancementSelector.SelectRandomFor("creature", creatureType, SizeConstants.Medium, challengeRating); Assert.That(advancement.AdditionalHitDice, Is.EqualTo(hitDice)); Assert.That(advancement.Size, Is.EqualTo(SizeConstants.Medium)); Assert.That(advancement.AdjustedChallengeRating, Is.EqualTo(advancedChallengeRating)); }
public void GenerateAtLevel_ValueDeterminedByValueResult() { var secondValueResult = new TypeAndAmountSelection(); secondValueResult.Type = "second value"; secondValueResult.Amount = 90210; var tableName = string.Format(TableNameConstants.Percentiles.Formattable.GOODTYPEValues, selection.Type); mockTypeAndAmountPercentileSelector.SetupSequence(p => p.SelectFrom(tableName)).Returns(valueSelection).Returns(secondValueResult); var goods = generator.GenerateAtLevel(1); var firstGood = goods.First(); var secondGood = goods.Last(); Assert.That(firstGood.ValueInGold, Is.EqualTo(9266)); Assert.That(secondGood.ValueInGold, Is.EqualTo(90210)); }
private void SetUpAdvancement( string size, int additionalHitDice, double space = 0, double reach = 0) { var data = new string[3]; data[DataIndexConstants.AdvancementSelectionData.Reach] = reach.ToString(); data[DataIndexConstants.AdvancementSelectionData.Size] = size; data[DataIndexConstants.AdvancementSelectionData.Space] = space.ToString(); var typeAndAmountSelection = new TypeAndAmountSelection(); typeAndAmountSelection.Amount = additionalHitDice; typeAndAmountSelection.Type = string.Join(",", data); typesAndAmounts.Add(typeAndAmountSelection); }
public void Setup() { mockSpellsGenerator = new Mock <ISpellsGenerator>(); mockCollectionsSelector = new Mock <ICollectionSelector>(); mockAdjustmentsSelector = new Mock <IAdjustmentsSelector>(); mockTypeAndAmountSelector = new Mock <ITypeAndAmountSelector>(); magicGenerator = new MagicGenerator( mockSpellsGenerator.Object, mockCollectionsSelector.Object, mockAdjustmentsSelector.Object, mockTypeAndAmountSelector.Object); alignment = new Alignment(); abilities = new Dictionary <string, Ability>(); equipment = new Equipment(); arcaneSpellFailures = new Dictionary <string, int>(); classesThatPrepareSpells = new List <string>(); caster = new TypeAndAmountSelection(); caster.Type = "class name"; caster.Amount = 42; classesThatPrepareSpells.Add(caster.Type); classesThatPrepareSpells.Add("other class"); abilities["casting ability"] = new Ability("casting ability"); abilities["casting ability"].BaseScore = 11; abilities["other ability"] = new Ability("other ability"); abilities["other ability"].BaseScore = 11; mockTypeAndAmountSelector .Setup(s => s.Select(TableNameConstants.TypeAndAmount.Casters, "creature")) .Returns(new[] { caster }); mockAdjustmentsSelector .Setup(s => s.SelectFrom <int>(TableNameConstants.Adjustments.ArcaneSpellFailures, It.IsAny <string>())) .Returns((string table, string name) => arcaneSpellFailures[name]); mockCollectionsSelector .Setup(s => s.SelectFrom(TableNameConstants.Collection.CasterGroups, GroupConstants.PreparesSpells)) .Returns(classesThatPrepareSpells); mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Collection.AbilityGroups, $"{caster.Type}:Spellcaster")).Returns(new[] { "casting ability" }); }
public void Setup() { mockTypeAndAmountPercentileSelector = new Mock <ITypeAndAmountPercentileSelector>(); mockCollectionsSelector = new Mock <ICollectionSelector>(); mockReplacementSelector = new Mock <IReplacementSelector>(); potionGenerator = new PotionGenerator( mockTypeAndAmountPercentileSelector.Object, mockCollectionsSelector.Object, mockReplacementSelector.Object); itemVerifier = new ItemVerifier(); var result = new TypeAndAmountSelection(); result.Amount = 9266; result.Type = "potion"; power = "power"; var tableName = string.Format(TableNameConstants.Percentiles.Formattable.POWERITEMTYPEs, power, ItemTypeConstants.Potion); mockTypeAndAmountPercentileSelector.Setup(s => s.SelectFrom(tableName)).Returns(result); }
private TypeAndAmountSelection ParseResult(string percentileResult) { var result = new TypeAndAmountSelection(); if (string.IsNullOrEmpty(percentileResult)) { return(result); } if (!percentileResult.Contains(",")) { throw new FormatException($"{percentileResult} is not formatted for type and amount parsing"); } var parsedResult = percentileResult.Split(','); result.Type = parsedResult[0]; result.Amount = dice.Roll(parsedResult[1]).AsSum(); return(result); }
public void Setup() { mockTypeAndAmountSelector = new Mock <ITypeAndAmountSelector>(); mockPercentileSelector = new Mock <IPercentileSelector>(); mockCollectionSelector = new Mock <ICollectionSelector>(); advancementSelector = new AdvancementSelector(mockTypeAndAmountSelector.Object, mockPercentileSelector.Object, mockCollectionSelector.Object); typesAndAmounts = new List <TypeAndAmountSelection>(); creatureType = new CreatureType(); creatureType.Name = "creature type"; mockTypeAndAmountSelector.Setup(s => s.Select(TableNameConstants.TypeAndAmount.Advancements, "creature")).Returns(typesAndAmounts); creatureTypeDivisor = new TypeAndAmountSelection(); creatureTypeDivisor.Type = "creature type"; creatureTypeDivisor.Amount = 999999999; mockTypeAndAmountSelector.Setup(s => s.SelectOne(TableNameConstants.TypeAndAmount.Advancements, "creature type")).Returns(creatureTypeDivisor); mockCollectionSelector.Setup(s => s.SelectRandomFrom(It.IsAny <IEnumerable <TypeAndAmountSelection> >())) .Returns((IEnumerable <TypeAndAmountSelection> c) => c.First()); }
public Item Generate(string itemName, params string[] traits) { var selections = typeAndAmountPercentileSelector.SelectAllFrom(TableNameConstants.Percentiles.Set.AlchemicalItems); var selection = selections.FirstOrDefault(s => s.Type == itemName); if (selection == null) { selection = new TypeAndAmountSelection(); selection.Type = itemName; selection.Amount = 1; } var item = new Item(); item.Name = itemName; item.Quantity = selection.Amount; item.ItemType = ItemTypeConstants.AlchemicalItem; item.BaseNames = new[] { itemName }; item.Traits = new HashSet <string>(traits); return(item); }
public void Setup() { selection = new TypeAndAmountSelection(); mockJustInTimeFactory = new Mock <JustInTimeFactory>(); mockPercentileSelector = new Mock <ITreasurePercentileSelector>(); mockMagicalItemGenerator = new Mock <MagicalItemGenerator>(); mockTypeAndAmountPercentileSelector = new Mock <ITypeAndAmountPercentileSelector>(); mockMundaneItemGenerator = new Mock <MundaneItemGenerator>(); mockRangeDataSelector = new Mock <IRangeDataSelector>(); mockCollectionSelector = new Mock <ICollectionSelector>(); itemsGenerator = new ItemsGenerator( mockTypeAndAmountPercentileSelector.Object, mockJustInTimeFactory.Object, mockPercentileSelector.Object, mockRangeDataSelector.Object, mockCollectionSelector.Object); selection.Type = "power"; selection.Amount = 42; mockTypeAndAmountPercentileSelector.Setup(p => p.SelectFrom(It.IsAny <string>())).Returns(selection); mockPercentileSelector.Setup(p => p.SelectFrom(It.IsAny <string>())).Returns(ItemTypeConstants.WondrousItem); var dummyMagicalMock = new Mock <MagicalItemGenerator>(); dummyMagicalMock.Setup(m => m.GenerateRandom(It.IsAny <string>())).Returns(() => new Item { Name = "magical item" }); mockJustInTimeFactory.Setup(f => f.Build <MagicalItemGenerator>(It.IsAny <string>())).Returns(dummyMagicalMock.Object); var dummyMundaneMock = new Mock <MundaneItemGenerator>(); dummyMundaneMock.Setup(m => m.GenerateRandom()).Returns(() => new Item { Name = "mundane item" }); mockJustInTimeFactory.Setup(f => f.Build <MundaneItemGenerator>(It.IsAny <string>())).Returns(dummyMundaneMock.Object); }
public void Setup() { mockCollectionsSelector = new Mock <ICollectionSelector>(); mockTypeAndAmountPercentileSelector = new Mock <ITypeAndAmountPercentileSelector>(); mockChargesGenerator = new Mock <IChargesGenerator>(); mockSpellGenerator = new Mock <ISpellGenerator>(); mockReplacementSelector = new Mock <IReplacementSelector>(); selection = new TypeAndAmountSelection(); ringGenerator = new RingGenerator( mockCollectionsSelector.Object, mockSpellGenerator.Object, mockChargesGenerator.Object, mockTypeAndAmountPercentileSelector.Object, mockReplacementSelector.Object); power = "power"; itemVerifier = new ItemVerifier(); selection.Amount = 9266; selection.Type = "ring of ability"; var tableName = string.Format(TableNameConstants.Percentiles.Formattable.POWERITEMTYPEs, power, ItemTypeConstants.Ring); mockTypeAndAmountPercentileSelector.Setup(p => p.SelectFrom(tableName)).Returns(selection); }
public void Setup() { mockTypeAndAmountPercentileSelector = new Mock <ITypeAndAmountPercentileSelector>(); mockCollectionsSelector = new Mock <ICollectionSelector>(); generator = new GoodsGenerator(mockTypeAndAmountPercentileSelector.Object, mockCollectionsSelector.Object); selection = new TypeAndAmountSelection(); valueSelection = new TypeAndAmountSelection(); selection.Type = "type"; selection.Amount = 2; valueSelection.Type = "first value"; valueSelection.Amount = 9266; mockTypeAndAmountPercentileSelector.Setup(p => p.SelectFrom(It.IsAny <string>())).Returns(selection); var tableName = string.Format(TableNameConstants.Percentiles.Formattable.GOODTYPEValues, selection.Type); mockTypeAndAmountPercentileSelector.Setup(p => p.SelectFrom(tableName)).Returns(valueSelection); descriptions = new List <string> { "description 1", "description 2" }; tableName = string.Format(TableNameConstants.Collections.Formattable.GOODTYPEDescriptions, selection.Type); var count = 0; object testLock = new object(); mockCollectionsSelector .Setup(p => p.SelectRandomFrom(tableName, It.IsAny <string>())) .Returns(() => { lock (testLock) { return(descriptions[count++ % descriptions.Count]); } }); }
public void Setup() { selection = new TypeAndAmountSelection(); }
private AdvancementSelection GetAdvancementSelection(string creatureName, CreatureType creatureType, string originalSize, string originalChallengeRating, TypeAndAmountSelection typeAndAmount) { var selection = new AdvancementSelection(); selection.AdditionalHitDice = typeAndAmount.Amount; var sections = typeAndAmount.Type.Split(','); selection.Size = sections[DataIndexConstants.AdvancementSelectionData.Size]; selection.Space = Convert.ToDouble(sections[DataIndexConstants.AdvancementSelectionData.Space]); selection.Reach = Convert.ToDouble(sections[DataIndexConstants.AdvancementSelectionData.Reach]); selection.StrengthAdjustment = GetStrengthAdjustment(originalSize, selection.Size); selection.ConstitutionAdjustment = GetConstitutionAdjustment(originalSize, selection.Size); selection.DexterityAdjustment = GetDexterityAdjustment(originalSize, selection.Size); selection.NaturalArmorAdjustment = GetNaturalArmorAdjustment(originalSize, selection.Size); if (IsBarghest(creatureName)) { selection.StrengthAdjustment = selection.AdditionalHitDice; selection.ConstitutionAdjustment = selection.AdditionalHitDice; selection.NaturalArmorAdjustment = selection.AdditionalHitDice; selection.CasterLevelAdjustment = selection.AdditionalHitDice; } selection.AdjustedChallengeRating = AdjustChallengeRating(originalSize, selection.Size, originalChallengeRating, selection.AdditionalHitDice, creatureType.Name); return(selection); }