// Random generation private Fighter GenerateRandomFighter() { // level int level = 5; // HP int HPGrowth = 0; for (int i = 0; i < level; i++) { HPGrowth += _rng.d10(); } // Race Race race; switch (_rng.CustomDice(14)) { case 1: race = Race.HillDwarf; break; case 2: race = Race.MountainDwarf; break; case 3: race = Race.HighElf; break; case 4: race = Race.WoodElf; break; case 5: race = Race.DarkElf; break; case 6: race = Race.LightfootHalfling; break; case 7: race = Race.StoutHalfling; break; case 8: race = Race.Human; break; case 9: race = Race.Dragonborn; break; case 10: race = Race.ForestGnome; break; case 11: race = Race.RockGnome; break; case 12: race = Race.HalfElf; break; case 13: race = Race.HalfOrc; break; case 14: race = Race.Tiefling; break; default: race = Race.Human; break; } // Name Tuple <string, string> name = CharRace.GetRandomName(race, ref _rng); string shortName = name.Item1; string longName = name.Item2; // Background Background background; switch (_rng.CustomDice(13)) { case 1: background = Background.Acolyte; break; case 2: background = Background.Charlatan; break; case 3: background = Background.Criminal; break; case 4: background = Background.Entertainer; break; case 5: background = Background.FolkHero; break; case 6: background = Background.GuildArtisan; break; case 7: background = Background.Hermit; break; case 8: background = Background.Noble; break; case 9: background = Background.Outlander; break; case 10: background = Background.Sage; break; case 11: background = Background.Sailor; break; case 12: background = Background.Soldier; break; case 13: background = Background.Urchin; break; default: background = Background.Hermit; break; } // stats int[] stats = new int[] { 10, 10, 10, 10, 10, 10 }; for (int i = 0; i < 6; i++) { int[] dice = { _rng.d6(), _rng.d6(), _rng.d6(), _rng.d6() }; Array.Sort(dice); stats[i] = dice[3] + dice[2] + dice[1]; } // Ability Score Improvement int points = 0; if (level >= 4) { points += 2; } if (level >= 6) { points += 2; } if (level >= 8) { points += 2; } if (level >= 12) { points += 2; } if (level >= 14) { points += 2; } if (level >= 16) { points += 2; } if (level >= 19) { points += 2; } while (points > 0) { int index = _rng.d6(); if (stats[index - 1] < 20) { stats[index - 1]++; points--; } } // Finish HP int HPConGrowth = level * (stats[2] / 2 - 5); int maxHP = 10 + HPGrowth + HPConGrowth; // martial archetype MartialArchetype martialArchetype = MartialArchetype.Champion; // combat proficiencies bool[] combatProficiencies = new bool[6] { true, true, true, true, true, true }; // skill proficiencies bool[] skillProficiencies = new bool[18] { false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false }; int skill1 = _rng.d8(); int skill2 = _rng.d8(); while (skill2 == skill1) { skill2 = _rng.d8(); } switch (skill1) { case 1: skillProficiencies[1] = true; break; case 2: skillProficiencies[9] = true; break; case 3: skillProficiencies[0] = true; break; case 4: skillProficiencies[5] = true; break; case 5: skillProficiencies[10] = true; break; case 6: skillProficiencies[15] = true; break; case 7: skillProficiencies[12] = true; break; case 8: skillProficiencies[13] = true; break; } switch (skill2) { case 1: skillProficiencies[1] = true; break; case 2: skillProficiencies[9] = true; break; case 3: skillProficiencies[0] = true; break; case 4: skillProficiencies[5] = true; break; case 5: skillProficiencies[10] = true; break; case 6: skillProficiencies[15] = true; break; case 7: skillProficiencies[12] = true; break; case 8: skillProficiencies[13] = true; break; } // save proficiencies bool[] saveProficiencies = new bool[6] { true, false, true, false, false, false }; // fighting styles bool[] fightingStyles = new bool[6] { false, false, false, false, false, false }; int style1 = _rng.d6(); fightingStyles[style1 - 1] = true; // Second fighting style if (martialArchetype == MartialArchetype.Champion && level >= 10) { int style2 = _rng.d6(); while (style2 == style1) { style2 = _rng.d6(); } fightingStyles[style2 - 1] = true; } Fighter fighter = new Fighter(ref _rng, shortName, longName, level, maxHP, maxHP, race, background, stats, combatProficiencies, skillProficiencies, saveProficiencies, fightingStyles, martialArchetype); return(fighter); }
public int RollHitDice() => _rng.d10();