Dungeon Master was one of the first ever real-time role-playing games, originally released in 1987 on the Atari ST. Among other exciting things for the time, it offered a rather sophisticated spell system based on runes.
Your task today is to write a program or function that evaluates the number of Mana points required to cast a given spell in Dungeon Master.
The 'spell cast' system is the top right cyan box in the above picture.
Spells, runes and Mana
Dungeon Master spells are composed of 2 to 4 runes, picked among the following categories, in this exact order:
- Power (mandatory)
- Elemental Influence (mandatory)
- Form (optional)
- Class / Alignment (optional)
It means that valid spells are either:
- Power + Elemental Influence
- Power + Elemental Influence + Form
- Power + Elemental Influence + Form + Class / Alignment
Each category contains 6 runes, and each rune has an associated base Mana cost:
=============================================================================
| Power | Rune | Lo | Um | On | Ee | Pal | Mon |
| +-----------+------+------+------+------+------+------+
| | Base cost | 1 | 2 | 3 | 4 | 5 | 6 |
=============================================================================
| Elemental Influence | Rune | Ya | Vi | Oh | Ful | Des | Zo |
| +-----------+------+------+------+------+------+------+
| | Base cost | 2 | 3 | 4 | 5 | 6 | 7 |
=============================================================================
| Form | Rune | Ven | Ew | Kath | Ir | Bro | Gor |
| +-----------+------+------+------+------+------+------+
| | Base cost | 4 | 5 | 6 | 7 | 7 | 9 |
=============================================================================
| Class / Alignment | Rune | Ku | Ros | Dain | Neta | Ra | Sar |
| +-----------+------+------+------+------+------+------+
| | Base cost | 2 | 2 | 3 | 4 | 6 | 7 |
=============================================================================
Evaluating the Mana cost
The Mana cost of the spell is the sum of the Mana cost of all runes:
The cost of the Power rune always equals its base cost (from 1 to 6).
For the other runes, the following formula applies:
where power is the base cost of the Power rune.
Examples
Spell: Lo Ful
Cost : 1 + floor((1 + 1) * 5 / 2) = 1 + 5 = 6
Spell: Um Ful
Cost : 2 + floor((2 + 1) * 5 / 2) = 2 + 7 = 9
Spell: Pal Vi Bro
Cost : 5 + floor((5 + 1) * 3 / 2) + floor((5 + 1) * 7 / 2) = 5 + 9 + 21 = 35
Clarifications and rules
- Your input will consist of 2 to 4 strings designating the runes of the spell. You can take them in any reasonable format, such as 4 distinct parameters, an array of strings (e.g.
['Lo', 'Ful']
), or just one string with a single-character separator of your choice (e.g.'Lo Ful'
). Please specify the selected input format in your answer. - The runes are guaranteed to be valid.
- The order of the categories must be respected. Unused categories may be either missing or replaced with some falsy value.
- You can accept the runes in any of these formats: 1. A capital letter followed by lower case (
'Ful'
) 2. All lower case ('ful'
) 3. All upper case ('FUL'
). But you can't mix different formats. - Quite obviously, we do not care to know whether the spell actually has some effect in the game (for the curious, useful spells are listed here.)
- This is code-golf, so the shortest code in bytes wins.
- And remember: Lord Chaos is watching you!
Test cases
Spell | Output
---------------+-------
Lo Ful | 6
Um Ful | 9
On Ya | 7
Lo Zo Ven | 12
Pal Vi Bro | 35
Ee Ya Bro Ros | 31
On Ful Bro Ku | 31
Lo Zo Kath Ra | 20
On Oh Ew Sar | 35
Ee Oh Gor Dain | 43
Mon Zo Ir Neta | 68
Mon Des Ir Sar | 75