Durance has found a magic book in one of his adventures and decided to learn how to enchant his weapons. Due to the unstable nature of magic, he is not sure of what kind of magical things will happen, he might even lose previous enchantments! (That happens every 1/10th of the time) Let’s try to help him.
Create an application that allows Durance to enchant his weapon.
For this version of the kata, only one enchantment is allowed. We might re-roll an existing enchantment but there is a 1/10 that we might lose all current enchantments on the weapon.
Example:
Dagger of the Nooblet
5 - 10 attack damage
1.2 attack speed
After enchanting it, Durance rolled the Fire enchantment!
Inferno Dagger of the Nooblet
5 - 10 attack damage
1.2 attack speed
+5 fire damage
Not satisfied, he enchanted it again and this time he got the Agility enchantment
Quick Dagger of the Nooblet
5 - 10 attack damage
1.2 attack speed
+5 agility
He felt confident thinking that he could get something better and tried again, sadly, he lost his enchantment!
Dagger of the Nooblet
5 - 10 attack damage
1.2 attack speed
An enchantment adds different attributes to a weapon, for this kata, we can choose among the following:
{
"ice": {
"prefix": "Icy",
"attribute": "+5 ice damage"
},
"fire": {
"prefix": "Inferno",
"attribute": "+5 fire damage"
},
"lifesteal": {
"prefix": "Vampire",
"attribute": "+5 lifesteal"
},
"agility": {
"prefix": "Quick",
"attribute": "+5 agility"
},
"strength": {
"prefix": "Angry",
"attribute": "+5 strength"
}
}
HDurance{
Weapon weapon;
MagicBook magicBook;
public void enchant(){
// Implement here...
}
public String describeWeapon(){
// Implement here...
}
}
public interface Weapon{
String stats();
}
Durance can now carry more weapons and each one can have up to 3 unique enchantments, he is also worried about dealing the most damage possible, so DPS (Damage per second) should be displayed as well.
We take the agility attribute into account, converting it to an attack speed increase equal to: attack speed + agility points / 10
DPS is calculated as: ((Min Weapon Damage + Max Weapon Damage) / 2) / Weapon Speed