D5 #100DaysOfCode Challenge

So I’ve been doing a fair bit of work on my adventure game and I noticed that I was using the classes wrong… well I wasn’t even using them…

Now that I am using them correctly they are making more sense. I am finding it cleaner to create most of my program as functions and just link them to other functions when needed, this means I can call the ‘main()’ function, and away the program goes. It also allows me to make changes easier.

Here is a GIF of my current program.


    ## Game breakdown
    So at this moment you can choose two classes that have set stats, then your starting coin is based off a random int between 1 and 250, you start poor or rich.
    The Inns beers price is between 1 and 5 and each time you buy a beer you give away your coins (Coins will have more use later on). 
    If you don’t have another drink the Barkeep will ask you what you are doing, this will trigger the quest phase. 
    ## Current Code
    import random 
    import time
    # Hero aka the Player
    class Hero:
        def __init__(self, HeroName, HeroClass, HeroAttack, HeroHealth, HeroDefence, HeroCoin):
            self.HeroName = HeroName
            self.HeroClass = HeroClass
            self.HeroAttack = HeroAttack
            self.HeroHealth = HeroHealth
            self.HeroDefence = HeroDefence
            self.HeroCoin = HeroCoin
        def description(self):
            print(f"Hello {self.HeroName} you are a {self.HeroClass}. You have {self.HeroAttack} Attack Points, {self.HeroHealth} Health and {self.HeroDefence} Defence ")
    Player = Hero
    BeerCost = random.randint(1,5)
    # Player Classes
    class Archer():
            ArcherAttack = 6
            ArcherHealth = 8
            ArcherDefense = 3
    class Wizard():
            WizardAttack = 7
            WizardHealth = 8
            WizardDefense = 2
    #Player Classes end.
    def Coin():
        print("Time to see how much gold you start with!")
        print("Calculating some more!")
        Hero.HeroCoin = random.randint(1,250)
        print(f"You start with {Hero.HeroCoin} coin/s")
    def quest():
        print(f"Barkeep: So what big adventure are you preparing for {Player.HeroName}? *The Barkeep looks over to your backpack*")
        print("1. I'm going to go out to the Ethril Forests, heard there's a bounty for a few bandits out there")
        PlayerResponeBarkeep = input("Make a choice: 1 | 2")
        if PlayerResponeBarkeep == "1":
            print("Barkeep: Ethril aye, well you better get going soon then *The Barkeep looks out the Window at the sun as it lowers behind the trees*")
    def main():
    #Player Creation.
        Player.HeroName = input("Enter Player Name: ")
        while True:
            Player.HeroClass = input("Enter Class (Archer, Wizard)").capitalize()
            if Player.HeroClass == "Archer":
                Player.HeroAttack = Archer.ArcherAttack
                Player.HeroHealth = Archer.ArcherHealth
                Player.HeroDefence = Archer.ArcherDefense
            elif Player.HeroClass == "Wizard":
                Player.HeroAttack = Wizard.WizardAttack
                Player.HeroHealth = Wizard.WizardHealth
                Player.HeroDefence = Wizard.WizardDefense
            print("Please select a correct class")
        while True:
            beerChoice = input(f"Barkeep: Another round {Player.HeroName}? (1 = Yes, 2 = No, 3 = How much?):")
            if beerChoice == "1":     
            elif beerChoice =="2":
            elif beerChoice == "3":
                print(f"Barkeep: {BeerCost} coins")  
                print("Make a choice")
    def NewBeer():
        Player.HeroCoin >= BeerCost
        print(f"*You grab {BeerCost} coins out of your bag and slide them over to the Barkeep*")
        Player.HeroCoin -= BeerCost
        if Player.HeroCoin < BeerCost:
            print("You Don't have enough coins")
        print(f"You have {Player.HeroCoin} coins")
        print(f"*The Barkeep grabs your empty glass and begins cleaning it with a cloth tucked into his belt*")
        print(f'*The Barkeep fills the glass with beer, and wipes of the excess foam*')
        print("*You drink your beer")
        print("*You finish your beer*")
    if __name__ == "__main__":
Written on September 24, 2019