American Young Coder (AYC)

AYC logo
Loading Events

« All Events

  • This event has passed.

6 PM – Python OOP – Darin

July 30 @ 6:00 pm - 7:00 pm

What We Did Today:

  1. Continued monster inheritance project
  2. Learnt about the concept of inheritance (we haven’t applied it yet)

Homework:

Continue in MonsterSystem.py and upload the file into the google drive when you are finished.

implement the else condition, and start by getting the Monster object from the dictionary with the key from variable “monster”, and then getting input from shell with the menu

This is what we have so far for the play method:

def play(self):
    self.player_name = input("Enter player name: ")
    self.player_health = int(input("Enter player health: "))

    print(f"\nWelcome to the AYCLOGIC adventure game, {self.player_name}")

    while True:
        print(f"{self.player_name}, you have {self.player_health} health remaining.")
        print("Please choose the monster to fight: ")
        self.listMonsters()
        monster = input("Enter the name of the monster to fight: ")

        if monster.lower() not in self.monsters.keys():
            print(f"{monster} does not exist in the system.")
        else:
            # getting the monster object using the key (monster)
            # print out "What do you want to do with the {monster}"
            # print out the menu below and get input with the variable named "selection"

            # create new menu called self.attack_menu
            """
            1. Magic attack
            2. Sword attack - 10 to 20 damage
            Enter your selection:
            """

Here is a sample of the output after completing the else condition:

Please select one of the following
1. Add Monster
2. List all monsters
3. Play Adventure
Enter your selection (Enter ‘exit’ to quit): 3
Enter player name: Darin
Enter player health: 100

Welcome to the AYCLOGIC adventure game, Darin

Darin, you have 100 health remaining.
Please choose the monster to fight:
DRAGON – 100 health remaining
TROLL – 80 health remaining
GOBLIN – 20 health remaining
Enter the name of the monster to fight: dragon

What do you want to do with the Dragon?
1. Magic attack
2. Sword attack – 10 to 20 damage
Enter your selection: 1

Notes:

If you have any questions, you can contact me at ddjapri@ayclogic.com

Details

Date:
July 30
Time:
6:00 pm - 7:00 pm
Event Categories:
,
Verified by MonsterInsights