As some of you may know, part of creating, or leveling up a character in almost any game is ability score increases. In this example, the character has six abilities with preassigned scores: strength, dexterity, intelligence, wisdom, charisma, and constitution. Users of the code have the option of choosing to level up one score by 2 points, or two different scores by one each.
The code I have works, and it works well, however, I realize that it's bulky, ugly, and probably a sin for python to be running it. Can you help me simplify/streamline it? Thank you
def ability(self):
choice = raw_input("leveling up: do you want to increase 'one' score by two, or 'two' scores by one each?")
if choice == "one":
score = raw_input("which ability do you want to increase by two?")
if score == "strength":
self.strength = self.strength + 2
elif score == "dexterity":
self.dexterity = self.dexterity + 2
elif score == "intelligence":
self.intelligence = self.intelligence + 2
elif score == "wisdom":
self.wisdom = self.wisdom + 2
elif score == "charisma":
self.charisma = self.charisma + 2
else:
self.constitution = self.constitution + 2
else:
score = raw_input("which ability do you want to increase by one?")
if score == "strength":
self.strength = self.strength + 1
elif score == "dexterity":
self.dexterity = self.dexterity + 1
elif score == "intelligence":
self.intelligence = self.intelligence + 1
elif score == "wisdom":
self.wisdom = self.wisdom + 1
elif score == "charisma":
self.charisma = self.charisma + 1
else:
self.constitution = self.constitution + 1
score_two = raw_input("which second ability do you want to increase?")
if score_two == "strength":
self.strength = self.strength + 1
elif score_two == "dexterity":
self.dexterity = self.dexterity + 1
elif score_two == "intelligence":
self.intelligence = self.intelligence + 1
elif score_two == "wisdom":
self.wisdom = self.wisdom + 1
elif score_two == "charisma":
self.charisma = self.charisma + 1
else:
self.constitution = self.constitution + 1