D4 #100DaysOfCode Challenge

New project time!

So I wanted to tackle Python classes, so why not make a text based adventure game!

So far it does not have a name or a story, but it does have classes! Check out the below GIF to see it in action.

code-capture

So below is my current code for my game.

    class Archer():
            ArcherAttack = 6
            ArcherHealth = 8
            ArcherDefense = 3
    
    class Wizard():
            WizardAttack = 7
            WizardHealth = 8
            WizardDefense = 2
    
    # Hero aka the Player
    class Hero:
        def __init__(self, HeroName, HeroClass, HeroAttack, HeroHealth, HeroDefence):
            self.HeroName = HeroName
            self.HeroClass = HeroClass
            self.HeroAttack = HeroAttack
            self.HeroHealth = HeroHealth
            self.HeroDefence = HeroDefence
        
        def description(self):
            print(f"Hello {self.HeroName} you are an {self.HeroClass}. You have {self.HeroAttack} Attack Points, {self.HeroAttack} Health and {self.HeroDefence} Defence ")
    
    PlayerName = input("Enter Player Name: ")
    PlayerClass = "NoClass"
    while True:
        PlayerClass = "NoClass"
        PlayerClass = input("Enter Class (Archer, Wizard)")
        if PlayerClass == "Archer":
            PlayerAttack = Archer.ArcherAttack
            PlayerHealth = Archer.ArcherHealth
            PlayerDefence = Archer.ArcherDefense
            Player = Hero(PlayerName, PlayerClass, PlayerAttack, PlayerHealth, PlayerDefence)
            Player.description()
            break
        elif PlayerClass == "Wizard":
            PlayerAttack = Wizard.WizardAttack
            PlayerHealth = Wizard.WizardHealth
            PlayerDefence = Wizard.WizardDefense
            Player = Hero(PlayerName, PlayerClass, PlayerAttack, PlayerHealth, PlayerDefence)
            Player.description()
            break
        else:
            print("Please select a correct class")
Written on September 23, 2019