import random class Character(): ''' a game character with a name and a random strength value from 1-10''' def __init__(self, name): self.name = name self.strength = random.randint(1,10) self.weapons = [] def __str__(self): strength = str(self.strength) return self.name+":"+strength def showinfo(self): print("\n") print(self.name) print("="*len(self.name)) print("Strength: ","*"*self.strength) print("Weapons : ",self.weapons) print("\n") def setweapon(self, choice): if choice == "A": self.weapons.append("axe") self.strength = self.strength+5 self.showinfo() def fight(self, other, choice): if choice == "1": if self.strength > other.strength: print("you win!") else: print("you lose!") return True if choice == "0": print("you run away!") return False def reset(self): self.strength = random.randint(1,10) self.weapons = [] monster = Character("Gorgatron") yourname = input("enter your name: ") hero = Character(yourname) print("PREPARE FOR BATTLE") print(hero) print(monster) more = True while more == True: print("PREPARE FOR BATTLE") hero.showinfo() monster.showinfo() print("select a weapon") print("A: Axe (increases strength by 5)") print("X: no weapon") choice = input() hero.setweapon(choice) input() print("select mode of combat") print("1 - test of strength") print("0 - run away") choice = input() more = hero.fight(monster,choice) hero.reset()