JonC 101 / Dungeons & Dragons: Shadow Over Mystara / JavaScript: Name to Item Calculator

Shortly after beginning a game, you will be asked to enter your character's name. Based on what you choose, you will be given a free item. For the details of how the naming system works, read the excerpt from the players guide below. Otherwise just use the keypad interface to type in a name, or enter the name directly into the text field, then the class type and free item will automatically be calculated and displayed above.

Note: Entering directly into the text field, and backspacing has problems when dealing with the roman numeral characters so it's best to avoid using those functions with them.

0 1 2 3 4 5 6 7 8 9
Name to Item Calculation Explanation
Chapter 3 - Player Types

Types ranging from A to J will be assigned to players after they've
entered their names.  Each type will grant the player a different type
of item upon the name is entered.  Here are the player types in

Type  Item given
 A      Medal
 B      Boots of Speed
 C      Helmet, cap, hat, circlet, depending on character
 D      Ring of Protection
 E      Ring of Fire Resistance
 F      Ring of Spell Turning
 G      Gauntlets of Ogre Power
 H      Anklet (Fighter,Drawf) Brooch (Cleric,Thief)
        Earring (Elf) Rod of Fire (Magic User)
 I      Bracelet, Rod of Cold (Magic User)
 J      Orb, Necklace (Elf), Rod of Lightning Bolt (Magic User)

To calculate your user type, use the following equation:

0 1 2 3 4  5 6 7 8 9  values

a b c d e  0 1 2 3 4
f g h i j  5 6 7 8 9
k l m n o  1 2 3 4 5 <-- Roman Numerals
p q r s t  . &   - !
u v w x y          ?

Values owned by each letter/number/symbol is added together, and if
there are two digits, the digits will be added together so the result
will not exceed 10.  (54 means 5+4=9) 5+5=10 is treated as a zero.

In your result, 0 grants you type A, 1 grants type B, etc.
For example:

2+0+0+2+4+2 = 10 = 1 + 0 = 1 (Type B)