|
5年前 | |
---|---|---|
.. | ||
DndCharacter.fs | 5年前 | |
DndCharacter.fsproj | 5年前 | |
DndCharacterTests.fs | 5年前 | |
README.md | 5年前 |
For a game of Dungeons & Dragons, each player starts by generating a character they can play with. This character has, among other things, six abilities; strength, dexterity, constitution, intelligence, wisdom and charisma. These six abilities have scores that are determined randomly. You do this by rolling four 6-sided dice and record the sum of the largest three dice. You do this six times, once for each ability.
Your character’s initial hitpoints are 10 + your character’s constitution modifier. You find your character’s constitution modifier by subtracting 10 from your character’s constitution, divide by 2 and round down.
Write a random character generator that follows the rules above.
For example, the six throws of four dice may look like:
Because constitution is 3, the constitution modifier is -4 and the hitpoints are 6.
Most programming languages feature (pseudo-)random generators, but few programming languages are designed to roll dice. One such language is Troll.
To run the tests, run the command dotnet test
from within the exercise directory.
F# source code can be formatted with the Fantomas tool.
After installing it with dotnet tool restore
, run dotnet fantomas .
to format code within the current directory.
For more detailed information about the F# track, including how to get help if you’re having trouble, please visit the exercism.io F# language page.
Simon Shine, Erik Schierboom https://github.com/exercism/problem-specifications/issues/616#issuecomment-437358945