def create_player(mode, race, char_name): """ Create the player's character """ if mode == 2: if race == 1: player = character.Goblin(char_name, app) elif race == 2: player = character.Orc(char_name, app) elif race == 3: player = character.Uruk(char_name, app) elif race == 4: player = character.Wizard(char_name, app) else: player = character.Haradrim(char_name, app) else: if race == 1: player = character.Elf(char_name, app) elif race == 2: player = character.Dwarf(char_name, app) elif race == 3: player = character.Human(char_name, app) elif race == 4: player = character.Hobbit(char_name, app) elif race == 5: player = character.Wizard(char_name, app) elif race == 6: player = character.Dunedain(char_name, app) elif race == 7: player = character.Crusader(char_name, app) return player #Tells you your name & race e.g. "Gimli the Dwarf"
def create_player(mode, race, char_name): """ Create the player's character """ # Evil if mode == 2: if race == 1: player = character.Goblin(char_name, 1, app) elif race == 2: player = character.Orc(char_name, 1, app) elif race == 3: player = character.Uruk(char_name, 1, app) else: player = character.Wizard(char_name, 1, app) # Good else: if race == 1: player = character.Human(char_name, 1, app) elif race == 2: player = character.Wizard(char_name, 1, app) elif race == 3: player = character.Warrior(char_name, 1, app) """elif race == 4: player = character.Hobbit(char_name, 1, app) elif race == 6: player = character.Bishop(char_name, 1, app) else: player = character.Wizard(char_name, 1, app)""" return player
def create_enemies(mode, difficulty): """ Create the enemies """ roll = random.randint(0, 2) if mode == 2: if difficulty == 'm': enemies = [character.Hobbit("Peregrin", app), character.Hobbit("Meriadoc", app), character.Human("Eowyn", app)] elif difficulty == 'h': enemies = [character.Dwarf("Gimli", app), character.Elf("Legolas", app), character.Human("Boromir", app)] elif difficulty == 'l': enemies = [character.Human("Faramir", app), character.Human("Aragorn", app), character.Wizard("Gandalf", app)] elif difficulty == 'un': enemies = [character.Elf("Galadriel", app), character.Human("Treebeard", app), character.Uruk("Beorn", app)] elif difficulty == 'b': enemies = [character.Hobbit("Bilbo", app)] else: enemies = [character.Hobbit("Frodo", app), character.Hobbit("Sam", app)] else: if difficulty == 'm': enemies = [character.Goblin("Azog", app), character.Goblin("Gorkil", app), character.Orc("Sharku", app)] elif difficulty == 'h': enemies = [character.Orc("Shagrat", app), character.Orc("Gorbag", app), character.Uruk("Lurtz", app)] elif difficulty == 'l': enemies = [character.Orc("Grishnakh", app), character.Uruk("Lurtz", app), character.Wizard("Saruman", app)] elif difficulty == 'un': if roll == 0: enemies = [character.Nazgul("Witch-king of Angmar", app)] elif roll == 1: enemies = [character.Dragon("Smaug", app)] elif roll == 2: enemies = [character.Spider("Shelob", app)] elif difficulty == 'b': enemies = [character.Human("Grima", app)] else: enemies = [character.Goblin("Azog", app), character.Goblin("Gorkil", app)] return enemies
#!/usr/bin/env python # In this simple RPG game, the hero fights the goblin. He has the options to: # 1. fight goblin # 2. do nothing - in which case the goblin will attack him anyway # 3. flee import character dude=character.Hero() bad_dude=character.Goblin() def main(): # hero_health = dude.health # hero_power = dude.power # goblin_health = bad_dude.health # goblin_power = bad_dude.power while bad_dude.health > 0 and dude.health > 0: print("You have {} health and {} power.".format(dude.health, dude.power)) print("The goblin has {} health and {} power.".format(bad_dude.health, bad_dude.power)) print() print("What do you want to do?") print("1. fight goblin") print("2. do nothing") print("3. flee") print("> ", end=' ') raw_input = input() if raw_input == "1":