Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Character:
- def __init__ (self, char_name, char_description):
- self.name = char_name
- self.description = char_description
- self.conversation = None
- def describe(self):
- print(self.name + " is here! ")
- print(self.description)
- def set_weakness(self):
- print(self.name + " has no weakness ")
- def fight(self):
- print(self.name + " doesn't want to fight with you")
- def talk(self):
- for loop in range(1):
- print("Hi i'm Dave")
- question1 = input("How are you? ")
- if question1 == "Good" or question1 == "good":
- print("OK nice")
- elif question1 == "Bad" or question1 == "bad":
- print("I'm sorry to hear that")
- else:
- print("I'm sorry i don't understand")
- class Enemy(Character):
- def __init__ (self, char_name, char_description):
- super(). __init__(char_name, char_description)
- self.weakness = None
- def set_weakness(self, weakness):
- self.weakness = weakness
- def get_weakness(self):
- return self.weakness
- def fight(self):
- combat_item = input("What will you fight with? ")
- if combat_item == self.weakness:
- print("You fend " + self.name + " off with the " + combat_item)
- return True
- else:
- print(self.name + " crushes you, puny adventurer")
- return False
- ----------------------------------------------------
- from character import Character
- from character import Enemy
- dave = Enemy("Dave", "A smelly zombie")
- dave.describe()
- dave.talk()
- dave.set_weakness("cheese")
- dave.fight()
- dennis = Character("Dennis", "A friendly skeleton")
- dennis.describe()
- dennis.talk()
- dennis.fight()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement