I have not made quite as good of progress as he, although I am slowly making it through it. I’m spending most of my time attempting to make the kata purely functional with no side effects of any kind.
can get and set Name So, I have already decided to violate/change the requirements of Feature 1. I to not like the idea of a character possession the ability to change their name. I am deciding to prevent the ability to change your name.
can get and set alignment alignments are Good, Evil and Neutral I decided to create a ‘sealed trait’ for Alignment with the possible values of Good, Bad and Neutral.
I like the idea of not seeing string values within the code. This also makes it very clear when reading the code and prevents others from accidentally creating unwanted ‘Alignments’.
I have decided to default a newly created character to an alignment of ‘Neutral’. I have not provided a constructor for anything other than Neutral. If the character is to be anything other than Neutral, then setting after creation will be required.
has an Armor Class that defaults to 10 has 5 Hit Points by default Nothing crazy here… I just followed the directions.
roll a 20 sided die (don’t code the die) roll must meet or beat opponents armor class to hit I created an Attack ‘sealed trait’ that will confine the possible Attack types to ‘Hit’ and ‘Miss’.
When a character attacks an opponent, the roll (1-20) is used to determine if the opponents hit points and the roll constitute an attack of ‘hit’.
If attack is successful, other character takes 1 point of damage when hit If a roll is a natural 20 then a critical hit is dealt and the damage is doubled when hit points are 0 or less, the character is dead I am debating if the ‘attack’ should be part of the character. It seems like it should be a separate class that takes two opponents and a role value… and returns the result. This way the opponent is not required to own the attack logic.
Abilities are Strength, Dexterity, Constitution, Wisdom, Intelligence, Charisma Abilities range from 1 to 20 and default to 10 Abilities have modifiers according to the following table: