本文整理汇总了C#中Dice.ChooseWithOdds方法的典型用法代码示例。如果您正苦于以下问题:C# Dice.ChooseWithOdds方法的具体用法?C# Dice.ChooseWithOdds怎么用?C# Dice.ChooseWithOdds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dice
的用法示例。
在下文中一共展示了Dice.ChooseWithOdds方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildAnimal
public static Animal BuildAnimal(string terrainType, string animalClassName = null, int evolutionRolls = 0)
{
var dice = new Dice();
//Options
var selectedTerrainType = TerrainTypeList.Single(x => x.Name == terrainType);
var terrainPenalty = 0;
if (animalClassName == null)
{
var animalClassNotes = dice.ChooseWithOdds(selectedTerrainType.AnimalClasses);
animalClassName = animalClassNotes.AnimalClass;
terrainPenalty = animalClassNotes.Penalty;
}
else
{
var animalClassNotes = selectedTerrainType.AnimalClasses.SingleOrDefault(ac => ac.AnimalClass == animalClassName);
if (animalClassNotes == null)
terrainPenalty = -5; //What is it doing here?
else
terrainPenalty = animalClassNotes.Penalty;
}
var animalClass = AnimalClassList.Single(x => x.Name == animalClassName);
//Type
var result = new Animal() { TerrainType = selectedTerrainType.Name, AnimalClass = animalClassName, EvolutionRolls = evolutionRolls };
var movement = dice.ChooseByRoll(selectedTerrainType.MovementChart, "D6");
result.Movement = !string.IsNullOrWhiteSpace(animalClass.Movement) ? animalClass.Movement : movement.Movement;
result.InitiativeDM += animalClass.InitiativeDM;
//Starting Skills
foreach (var skill in animalClass.Skills)
if (skill.ScoreSpecified)
result.Skills.Add(skill.Name, skill.Score);
else
result.Skills.Increase(skill.Name, skill.Bonus);
//Class features
if (animalClass.Features != null)
foreach (var feature in animalClass.Features)
result.Features.Add(feature.Text);
//Diet
var diet = dice.ChooseWithOdds(animalClass.Diets);
result.Diet = diet.Diet;
if (diet.Skills != null)
foreach (var skill in diet.Skills)
if (skill.ScoreSpecified)
result.Skills.Add(skill.Name, skill.Score);
else
result.Skills.Increase(skill.Name, skill.Bonus);
foreach (var att in diet.Attribute)
result.Increase(att.Name, dice.D(att.Bonus));
var weaponDM = 0;
switch (result.Diet)
{
case "Carnivore":
result.InitiativeDM += 1;
weaponDM = 8;
break;
case "Omnivore":
weaponDM = 4;
break;
case "Herbivore":
result.InitiativeDM += -1;
weaponDM = -6;
break;
}
//Behavior
var behaviorMeta = dice.ChooseByRoll(diet.Behaviors, "1D");
var behavior = BehaviorList.Single(x => x.Name == behaviorMeta.Behavior);
result.Behavior = behaviorMeta.Behavior;
result.Attack = behavior.Attack.ToIntOrNull();
result.Flee = behavior.Flee.ToIntOrNull();
result.InitiativeDM += behavior.InitiativeDM;
//subtract the reaction to make it act like a DM
result.Attack -= behaviorMeta.Reaction;
result.Flee -= behaviorMeta.Reaction;
AddBehavior(result, behavior, dice);
result.QuirkRolls += dice.D("D6") == 6 ? 1 : 0;
//We do this in a loop because each chart can add rolls to other charts
while (result.QuirkRolls > 0 || result.EvolutionRolls > 0 || result.PhysicalSkills > 0 || result.SocialSkills > 0 || result.EvolutionSkills > 0)
{
//Evolution Rolls
while (result.EvolutionRolls > 0)
{
result.EvolutionRolls -= 1;
if (dice.D(2) == 0)
RollOnChart(result, animalClass.Chart.Single(x => x.Name == "AdditionalSkills"), dice, $"1D6+{result.EvolutionDM}");
else
RollOnChart(result, animalClass.Chart.Single(x => x.Name == "OtherBenefits"), dice, $"1D6+{result.EvolutionDM}");
//.........这里部分代码省略.........