Exercism/bash/dnd-character
David Doblas Jiménez 09bf8bc515 Solution to DnD character in Bash 2023-07-01 16:56:11 +02:00
..
.exercism Solution to DnD character in Bash 2023-07-01 16:56:11 +02:00
HELP.md Solution to DnD character in Bash 2023-07-01 16:56:11 +02:00
README.md Solution to DnD character in Bash 2023-07-01 16:56:11 +02:00
bats-extra.bash Solution to DnD character in Bash 2023-07-01 16:56:11 +02:00
dnd_character.bats Solution to DnD character in Bash 2023-07-01 16:56:11 +02:00
dnd_character.sh Solution to DnD character in Bash 2023-07-01 16:56:11 +02:00

README.md

D&D Character

Welcome to D&D Character on Exercism's Bash Track. If you need help running the tests or submitting your code, check out HELP.md.

Instructions

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:

  • 5, 3, 1, 6: You discard the 1 and sum 5 + 3 + 6 = 14, which you assign to strength.
  • 3, 2, 5, 3: You discard the 2 and sum 3 + 5 + 3 = 11, which you assign to dexterity.
  • 1, 1, 1, 1: You discard the 1 and sum 1 + 1 + 1 = 3, which you assign to constitution.
  • 2, 1, 6, 6: You discard the 1 and sum 2 + 6 + 6 = 14, which you assign to intelligence.
  • 3, 5, 3, 4: You discard the 3 and sum 5 + 3 + 4 = 12, which you assign to wisdom.
  • 6, 6, 6, 6: You discard the 6 and sum 6 + 6 + 6 = 18, which you assign to charisma.

Because constitution is 3, the constitution modifier is -4 and the hitpoints are 6.

Notes

Most programming languages feature (pseudo-)random generators, but few programming languages are designed to roll dice. One such language is Troll.

Source

Created by

  • @glennj

Contributed to by

  • @guygastineau
  • @IsaacG

Based on

Simon Shine, Erik Schierboom - https://github.com/exercism/problem-specifications/issues/616#issuecomment-437358945