def main(): hero = Hero('Matt', 10, 5) goblin = Goblin('Goblin', 6, 2) while goblin.alive() and hero.alive(): print() print("What do you want to do?") print("1. fight %s" % (goblin.name)) print("2. do nothing") print("3. flee") print("> ", ) user_input = input() if user_input == "1": # Hero attacks enemy hero.attack(goblin) print("You do %d damage to the %s." % (hero.power, goblin.name)) if goblin.health <= 0: print("The %s is dead." % (goblin.name)) elif user_input == "2": goblin.attack(hero) hero.print_status() elif user_input == "3": print("Goodbye.") else: print("Invalid input %r" % user_input) if hero.health <= 0: print("You are dead.")
def init_monster_in_game(monster_name, monster_number, ground, lives, IA): list_monsters = ["ghost", "golem", "human", "goblin"] if ground == "1": start_x_monster_1 = 60 start_x_monster_2 = 850 end = 1210 elif ground == "2": start_x_monster_1 = 60 start_x_monster_2 = 740 end = 1100 else: start_x_monster_1 = 350 start_x_monster_2 = 650 end = 1050 if monster_number == 1: if monster_name == list_monsters[0]: monster = Ghost(start_x_monster_1, 417, end, lives, 0, IA, 1) elif monster_name == list_monsters[1]: monster = Golem(start_x_monster_1, 410, end, lives, 0, IA, 1) elif monster_name == list_monsters[2]: monster = Human(start_x_monster_1, 420, end, lives, 0, IA, 1) else: monster = Goblin(start_x_monster_1, 430, end, lives, 0, IA, 1) else: if monster_name == list_monsters[0]: monster = Ghost(start_x_monster_2, 417, end, lives, 0, IA, 1) elif monster_name == list_monsters[1]: monster = Golem(start_x_monster_2, 410, end, lives, 0, IA, -1) elif monster_name == list_monsters[2]: monster = Human(start_x_monster_2, 420, end, lives, 0, IA, -1) else: monster = Goblin(start_x_monster_2, 430, end, lives, 0, IA, -1) return monster
def main(): enemy = Goblin() hero = Hero() while enemy.alive() and hero.alive(): hero.print_status() enemy.print_status() print() print("What do you want to do?") print("1. fight enemy") print("2. do nothing") print("3. flee") print("> ", ) response = input() if response == "1": # Hero attacks enemy hero.attack(enemy) elif response == "2": pass elif response == "3": print("Goodbye.") break else: print("Invalid input %r" % input) if enemy.alive(): # enemy attacks hero enemy.attack(hero)
def app(gremlin_host, gremlin_port, event_loop, provider, aliases): app = event_loop.run_until_complete( Goblin.open(event_loop, provider=provider, aliases=aliases, hosts=[gremlin_host], port=gremlin_port)) app.register(Person, Place, Knows, LivesIn) return app
def main(): hero = Hero() goblin = Goblin() while hero.alive() and goblin.alive(): hero.print_status() goblin.print_status() print() print("What do you want to do?") print("1. fight goblin") print("2. do nothing") print("3. flee") print("> ", ) user_input = input() if user_input == "1": # Hero attacks goblin hero.attack(goblin) elif user_input == "2": pass elif user_input == "3": print("Goodbye.") break else: print("Invalid input %r. Enter 1, 2 or 3." % user_input) if goblin.health > 0: # Goblin attacks hero goblin.attack(hero)
def connect(self): """Connect to a graph database via a websocket, use GraphSONSerializersV2d0.""" loop = asyncio.get_event_loop() self.app = loop.run_until_complete( Goblin.open(loop, get_hashable_id=_get_hashable_id, hosts=self.hosts, port=self.port, serializer=self.serializer)) self.app.register(*tuple(ALL_MODELS))
def create(self, key, row, col): if key == "G": Goblin(row, col, self) elif key == "S": Snake(row, col, self) elif key == "#": Barrier(row, col, self) elif key == "P": Player(row, col, self) elif key == "T": Treasure(row, col, self)
def main(): hero = Hero(10, 5) goblin = Goblin(6, 2) # hero_health = 10 # hero_power = 5 # goblin_health = 6 # goblin_power = 2 while goblin.alive() and hero.alive(): #print("You have %d health and %d power." % (hero.health, hero.power)) hero.print_status() #print("The goblin has %d health and %d power." % (goblin.health, goblin.power)) goblin.print_status() print() print("What do you want to do?") print("1. fight goblin") print("2. do nothing") print("3. flee") print("> ", ) user_input = input() if user_input == "1": # Hero attacks goblin # goblin_health -= hero_power # print("You do %d damage to the goblin." % hero_power) hero.attack(goblin) if not goblin.alive(): print("The goblin is dead.") elif user_input == "2": pass elif user_input == "3": print("Goodbye.") break else: print("Invalid input %r" % user_input) if goblin.alive(): # Goblin attacks hero # hero_health -= goblin_power # print("The goblin does %d damage to you." % goblin_power) goblin.attack(hero) if not hero.alive(): print("You are dead.")
def generate_goblins(self): count = 0 while count < 5: x = random.randrange(1, 17) y = random.randrange(1, 17) if self.MyEnvironment.get_coord(x, y) not in [1, 2, 3, 4]: # generate a random goblin object at those coordinates goblin = Goblin.random_goblin(self, x, y) if not (self.MyEnvironment.type_exists(type(goblin)) ) or self.MyEnvironment.all_types_exist(Goblin): self.MyEnvironment.set_coord(x, y, 3) self.MyEnvironment.objects[(x, y)] = goblin count += 1 print(f"{goblin} at coordinates ({x},{y})")
def main(): my_hero = Hero() goblin = Goblin() zombie = Zombie() medic = Medic() shadow = Shadow() while (goblin.alive() or zombie.alive()) and my_hero.alive(): my_hero.print_status() print() print("What do you want to do?") print("1. fight goblin") print("2. fight zombie") print("3. fight medic") print("4. fight shadow") print("5. do nothing") print("6. flee") print("> ",) user_input = input() if user_input == "1": goblin.print_status() # my_hero attacks goblin my_hero.attack(goblin) if goblin.health > 0: # Goblin attacks my_hero goblin.attack(my_hero) elif user_input == "2": zombie.print_status() my_hero.attack(zombie) zombie.attack(my_hero) zombie.alive() elif user_input == "3": medic.print_status() my_hero.attack(medic) medic.attack(my_hero) medic.alive() elif user_input == "4": shadow.print_status() shadow.attack(my_hero) my_hero.attack(shadow) shadow.alive() elif user_input == "5": pass elif user_input == "6": print("Goodbye.") break else: print("Invalid input %r" % user_input)
def create_char(): character = random.choice( [Human(), Changeling(), Clockwork(), Dwarf(), Goblin(), Orc()]) character.generate_name() character.char_level = 0 character.generate_info("background", Roll.a_dice("1d20")) character.generate_info("personality", Roll.a_dice("3d6")) character.generate_profession(Roll.a_dice("1d20")) character.generate_personality(Roll.a_dice("1d20"), Roll.a_dice("1d20"), Roll.a_dice("1d20")) character.generate_interesting_things(Roll.a_dice("1d6"), Roll.a_dice("1d20")) character.generate_wealth(Roll.a_dice("3d6")) Printer.print_common_info(character) character.generate_extra_info(character, True) return render_template('index.html', character=character)
def generate_extra_info(self, char, print_extra_info): char.generate_info("apparent_ancestry", Roll.a_dice("3d6")) char.generate_info("apparent_gender", Roll.a_dice("1d6")) char.generate_info("true_age", Roll.a_dice("3d6")) char.generate_info("quirk", Roll.a_dice("1d20")) print("Apparent Ancestry: " + char.char_apparent_ancestry) print("Apparent Gender: " + char.char_apparent_gender) print("True Age: " + char.char_true_age) print("Quirk: " + char.char_quirk) if "human" in char.char_apparent_ancestry: apparent_Ancestry = Human() elif "dwarf" in char.char_apparent_ancestry: apparent_Ancestry = Dwarf() elif "goblin" in char.char_apparent_ancestry: apparent_Ancestry = Goblin() elif "orc" in char.char_apparent_ancestry: apparent_Ancestry = Orc() apparent_Ancestry.generate_extra_info(apparent_Ancestry, False) print("Apparent Age: " + apparent_Ancestry.char_age) print("Apparent Build: " + apparent_Ancestry.char_build) print("Apparent Appearence: " + apparent_Ancestry.char_appearence)
def __init__(self): loop = asyncio.get_event_loop() self.val = Goblin.open(loop, hosts=[Configuration.JANUSGRAPH_DB_SERVER], port=Configuration.JANUSGRAPH_DB_PORT, scheme=Configuration.JANUSGRAPH_DB_SCHEMA)
def main(): print(" A Grot's Life By T.K ") print("") time.sleep(1) print("You open your eyes and take your first breath ") time.sleep(1) print("You hear a voice in the darkness...") time.sleep(1) print("What is your name, you filthy Grot? ") gob_name = input("Name:") print(gob_name, ".. it suits you. Now, go do what grots do..") time.sleep(1) print("Kill, eat, sleep and get precious shinies !! ") time.sleep(1) print("And maybe a place where your grubby face can call home") time.sleep(2) gob = Goblin(gob_name, 0, 100, 0, 20) print(""" . . . . . . . . . . . . . . . . @%%@ . . . @%%@ X . . . . . . . @::8@t;::::;::;::::.:@S;::@ .X.X; . . . . .tt%X :S%tXSStXStX%8S@tt8X:: X .;X. . . . . . . .;88S:;;8@8X@8XX::;8... . X.::; X. . . . . 8:. 8:8. X:::;;: X . . . . . . 8:. @.8: . X::.:;::::X . . . . . . 8:. @.8. :@ . . . . . . .8.: S.8.. ..; :@ . . . . . . 8:: @.8: .: :@ . . . . . . .. :.tt8.::::::::::::Xt%t... ..;@ . . . ::.;X:.::t%%%%%%t%tS;tt:::X;X: . :@. . . . . . . S;;@@::8t:;:;:;:;:;t:;8::t8S:t .:@ . . . ;X8S@8;8.8: . . 8;;. ;X;t .;@. . . . . . XXS8% ;@.8. . . . 8;: @ 8:;@ . . :XXS :@.8. . 8;.. . 8:;@ . . . . . X;;@ . ;@.8: . . . . 8;: . .;@ . . . . ;@.:SXXXXXXXXXXXXX@:. . .:@ . . . . . . . ;X..::........::....... .;@ . . . . . XXS:::@X@@XXS.;8X@X@S . . ;8 . . . . . . .8;:.. . .;% . . . .;@ . . . . . 8;. ..t% . ..;@ . . . . . SS%S@X@8;: . . . X ; 8XSS . :@ . . . . . . . 8888888S ... 888888888 . :@ . . . . . . . . . . . . . . . . . . . . """) endgame = False choice = None while choice != "0": #os.system("cls") print("") print(" So... ", gob_name, " What is your action ?") print \ (""" 0 - Quit 1 - Status 2 - Eat 3 - Scavenge 4 - Explore 5 - Rest 6 - Craft """) choice = input("Choice: ") print() if choice == "0": print("Good-bye.") elif choice == "1": gob.status() elif choice == "2": gob.eat() elif choice == "3": gob.farm() elif choice == "4": gob.explore() elif choice == "5": gob.rest() elif choice == "6": gob.craft() else: print("\nSorry, but", choice, "isn't a valid choice.") if gob.hunger > 20: print( "You have gone too many days without food. You have died from hunger" ) input("press any button to continue") break if gob.health <= 0: print("You have suffered too many wounds, you have bled to death") input("press any button to continue") break if endgame == False: if ("Fish Bone Spear") in gob.goal and ( "Straw Bed") in gob.goal and ("Small Hut") in gob.goal: print( "You have built your home and prove you are a survivor, you win !!" ) con = input("Do you want to continue playing 1-yes, 2-no") if con == "1": endgame = True elif con == "2": print("Good bye") break else: pass else: pass else: pass
#Use the value "as-is" by default. result = val if isinstance(val, dict) and "@type" in val and "@value" in val: if val["@type"] == "janusgraph:RelationIdentifier": result = val["@value"]["value"] return result #eader = graphson.GraphSONReader({'g:Date': DateDeserializer()}) #writer = graphson.GraphSONWriter({datetime.datetime: DateSerializer()}) #message_serializer = serializer.GraphSONMessageSerializer(reader=reader, # writer=writer) goblin_app = loop.run_until_complete( Goblin.open(loop, get_hashable_id=get_hashable_id)) #, message_serializer=message_serializer)) #goblin_app = loop.run_until_complete(Goblin.open(loop, # hosts = ['localhost'], # port = '8182', # scheme = 'ws')) #list_of_vertices = Goblin.vertices goblin_app.register(User, Environment, Session, Browser, Device, OS, BelongsTo, CompatibleWith, AssignedTo, LogsIn, InstanceOf, ViewedOn, Exits, Accesses, Application, ApplicationInstance, Screen, ScreenInstance, Tenant, Company, CloudSuite, Launches, Enters, LogsOut, TimesOut, ConnectedWith, Operates, Hosts, Provisioned, Supports, RunsOn, Owns, Implemnts,
# os.system() will take any linux command and if python can run it, it will # from [file name] import [class] from hero import Hero # There can only be one hero from goblin import Goblin # There are many, many goblins! from vampire import Vampire hero_name = raw_input("What is your name? ") the_Hero = Hero(hero_name, 10) while the_Hero.is_alive: randMonster = randint(1,2) if randMonster ==1: monster = Goblin() else: monster = Vampire() while(the_Hero.is_alive() and monster.is_alive()): # main game loop print "Welcome %s, you steamy turd!" % hero_name print "You have encountered a %s" % monster.name # Run the game while BOTH the hero and the goblin have health > 0 while the_Hero.health > 0 and monster.health > 0: message = """ You have %d health and %d power. The monster has %d health and %d power. What do you want to do? 1. Fight! 2. Dance! 3. Fleeeeeeeeee! > """
startup = False elif new_game == "N": print "What a shame. Perhaps one day thou wilst become a hero.\n" else: print "That is not a valid input.\n" hero_name = raw_input("What is thy name, bold adventurer? \n") the_hero = Hero(hero_name) hero_home = raw_input("Whence dost thou hail, brave %s? \n") % the_hero.name print "Well, %s of %s, I hope you are prepared. \n" % (the_hero.name, the_hero.home) monsters = [] monsters.append(Goblin()) monsters.append(Vampire()) monsters.append(Ogre()) for monster in monsters: # print "1. 1 enemy" # print "2. 2 enemies" # print "3. 3 enemies" # enemies_num = raw_input("How many enemies do you want to fight? ") # if enemies_num == "1": # monsters[0] print "\n" print "Mighty hero %s, you have encountered a %s. \n" % (the_hero.name, monster.name) if monster == Ogre:
from hero import Hero from zombie import Zombie from goblin import Goblin from wizard import Wizard from battle import Battle from store import Store hero = Hero('Oakley') zombie = Zombie() enemies = [Goblin('Bob'), Wizard('Jethro')] battle_engine = Battle() shopping_engine = Store() for enemy in enemies: hero_won = battle_engine.do_battle(hero, enemy) if not hero_won: print("YOU LOSE!") exit(0) shopping_engine.do_shopping(hero) print("But not you Chris Aquino") print("YOU WIN!")
def level_2(self): gob1 = Goblin(LEFT + 200, DOWN - 200, (self.all_sprites, self.enemys), self.enemys) gob2 = Goblin(RIGHT - 200, UP + 200, (self.all_sprites, self.enemys), self.enemys) gob3 = Goblin(LEFT + 200, UP + 200, (self.all_sprites, self.enemys), self.enemys) gob4 = Goblin(RIGHT - 200, DOWN - 200, (self.all_sprites, self.enemys), self.enemys)
def main(): #init pygame pygame.init() # screen and size width = 512 height = 480 screen = pygame.display.set_mode((width, height)) # Load Images background_image = pygame.image.load( 'images/background.png').convert_alpha() heroine_fr = pygame.image.load('images/heroine_front.png').convert_alpha() heroine_bk = pygame.image.load('images/heroine_back.png').convert_alpha() heroine_r = pygame.image.load('images/heroine_right.png').convert_alpha() heroine_l = pygame.image.load('images/heroine_left.png').convert_alpha() monster_image = pygame.image.load('images/monster.png').convert_alpha() goblin_image = pygame.image.load('images/goblin.png').convert_alpha() # Create characters la_heroina = Heroine(heroine_fr, heroine_fr, heroine_bk, heroine_r, heroine_l, 250, 250) monster = Monster(monster_image, 100, 100) goblin = Goblin(goblin_image, 400, 400) # Make groups enemies = pygame.sprite.Group() enemies.add(monster, goblin) all_sprites = pygame.sprite.Group() all_sprites.add(la_heroina) # Game initialization game_on = True while game_on: for event in pygame.event.get(): # Event handling if event.type == pygame.QUIT: game_on = False # Game logic # Draw stuff screen.blit(background_image, [0, 0]) # la_heroina.render(screen) # la_heroina.draw(512, 480) pressed_keys = pygame.key.get_pressed() la_heroina.move(pressed_keys) monster.render(screen) monster.update(width, height) goblin.render(screen) goblin.update(width, height) enemies.update(width, height) for entity in all_sprites: screen.blit(entity.main_img, entity.rect) # let the chase begin (monster chase the heroine, sorry, heroine) if pygame.sprite.spritecollideany(la_heroina, enemies): la_heroina.kill() print("heroine: ", la_heroina.rect) print("monster: ", monster.rect) print("goblin: ", goblin.rect) pygame.quit() # killz = pygame.sprite.spritecollide(la_heroina, enemies, True) # if killz: # print('true') # Game display pygame.display.flip() pygame.quit()
import random from hero import Hero from goblin import Goblin from zombie import Zombie from medic import Medic from shadow import Shadow from ascii_art import character_list_art, options_list_art, goodbye, welcome hero = Hero(10, 5) goblin = Goblin(6, 2) zombie = Zombie(10, 1) medic = Medic(8, 2) shadow = Shadow(1, 4) characters = [hero, goblin, zombie, medic, shadow] store_items = [] def get_enemies(user_fighter_choice): enemies = [] for character in characters: if character.type != user_fighter_choice.type: enemies.append(character) return enemies def pause(): input("Press any key to continue...")
import time import math from hero import Hero from battle import Battle from goblin import Goblin from medic import Medic from sayan import Sayan from shadow import Shadow from store import Store from thief import Thief from wizard import Wizard from zombie import Zombie from mimic import Mimic hero = Hero('Oakley') enemies = [ Goblin('Bob'), Wizard('Jethro'), Medic('Mercy'), Thief('Barry'), Mimic('Harry'), Zombie('Rick'), Shadow('Matt'), Sayan('Goku') ] # enemies = [Thief('Barry')] Goblin('Bob'), Wizard('Jethro'), Medic('Mercy'), Thief('Barry'), Zombie('Rick'), Shadow('Matt'), Sayan('Goku'), battle_engine = Battle() shopping_engine = Store() for enemy in enemies: hero_won = battle_engine.do_battle(hero, enemy) if not hero_won:
def main(): # Initialize pygame pygame.init() # Importing image background_image = pygame.image.load(bg_image_path) # Importing and Intialize Sound pygame.mixer.init() bg_sound = pygame.mixer.Sound(bg_sound_path) lose_sound = pygame.mixer.Sound(lose_sound_path) win_sound = pygame.mixer.Sound(win_sound_path) # Set up the screen (drawing surface for the game) screen = pygame.display.set_mode((window_width, window_height)) # Game Window Title pygame.display.set_caption('Monster Game') # Calls the Clock object and sets it to variable clock (for shorthand purposes) clock = pygame.time.Clock() #################### Game initialization #################### # Created a monster instance game_monster = Monster(120, 120, 3, 3) game_hero = Hero(256, 240) game_goblin1 = Goblin(360, 360) game_goblin2 = Goblin(360, 360) game_goblin3 = Goblin(360, 360) # Sprite Groups monster_group = pygame.sprite.Group() monster_group.add(game_monster) hero_group = pygame.sprite.Group() hero_group.add(game_hero) goblin_group = pygame.sprite.Group() goblin_group.add(game_goblin1) goblin_group.add(game_goblin2) goblin_group.add(game_goblin3) # FPS settings FPS = 60 # Music Start bg_sound.play() #################### While loop used to have the game continuously run #################### stop_game = False while not stop_game: # Event is for user input such as keypress to clicks for event in pygame.event.get(): #Key Strokes Movement (Hero Movement and Enter Key) if event.type == pygame.KEYDOWN: if event.key == KEY_DOWN: if game_hero.dead == False: game_hero.dir_y = 3 elif event.key == KEY_UP: if game_hero.dead == False: game_hero.dir_y = -3 elif event.key == KEY_LEFT: if game_hero.dead == False: game_hero.dir_x = -3 elif event.key == KEY_RIGHT: if game_hero.dead == False: game_hero.dir_x = 3 elif event.key == KEY_ENTER: print("Enter Works") restart_level(game_monster, game_hero, game_goblin1, game_goblin2, game_goblin3) monster_group.add(game_monster) goblin_group.add(game_goblin1) goblin_group.add(game_goblin2) goblin_group.add(game_goblin3) bg_sound.play() if event.type == pygame.KEYUP: if event.key == KEY_DOWN: game_hero.dir_y = 0 elif event.key == KEY_UP: game_hero.dir_y = 0 elif event.key == KEY_LEFT: game_hero.dir_x = 0 elif event.key == KEY_RIGHT: game_hero.dir_x = 0 # Event that if user clicks exit if event.type == pygame.QUIT: stop_game = True # Game logic # Renders background, monster, and hero image screen.blit(background_image, [0, 0]) screen.blit(game_hero.image, [game_hero.x, game_hero.y]) screen.blit(game_monster.image, [game_monster.x, game_monster.y]) screen.blit(game_goblin1.image, [game_goblin1.x, game_goblin1.y]) screen.blit(game_goblin2.image, [game_goblin2.x, game_goblin2.y]) screen.blit(game_goblin3.image, [game_goblin3.x, game_goblin3.y]) # Hero Movement game_hero.character_movement() game_hero.character_fence(1) game_hero.rect_update() # Monster Movement game_monster.monster_random_movement() game_monster.character_movement() game_monster.character_fence(2) game_monster.rect_update() # Goblin Movement game_goblin1.monster_random_movement() game_goblin1.character_movement() game_goblin1.character_fence(2) game_goblin1.rect_update() game_goblin2.monster_random_movement() game_goblin2.character_movement() game_goblin2.character_fence(2) game_goblin2.rect_update() game_goblin3.monster_random_movement() game_goblin3.character_movement() game_goblin3.character_fence(2) game_goblin3.rect_update() # Sprite Collide collide_monster = pygame.sprite.spritecollide(game_hero, monster_group, True) collide_goblin = pygame.sprite.spritecollide(game_hero, goblin_group, True) if collide_monster: bg_sound.stop() game_hero.x = 230 game_hero.y = 200 game_monster.is_dead() win_sound.play() if collide_goblin: bg_sound.stop() game_monster.x = 500 game_monster.y = 500 game_hero.hero_dead() lose_sound.play() game_monster.dir_x = 0 game_monster.dir_y = 0 if game_monster.dead == True: font = pygame.font.Font(None, 20) play_again_text = font.render("Press `Enter` to Play Again!", True, (0, 0, 0)) screen.blit(play_again_text, [172, 220]) game_hero.x = 236 game_hero.y = 185 if game_hero.dead == True: font = pygame.font.Font(None, 20) play_again_text = font.render("Press `Enter` to Play Again!", True, (0, 0, 0)) screen.blit(play_again_text, [172, 220]) game_goblin1.x = 236 game_goblin1.y = 185 game_goblin2.x = 236 game_goblin2.y = 185 game_goblin3.x = 236 game_goblin3.y = 185 game_hero.dir_x = 0 game_hero.dir_y = 0 # Game display pygame.display.update() # Set the tick rate to 60 ms, which means the game runs at 60 FPS clock.tick(FPS) pygame.quit()
# -*- coding: utf-8 -*- from human import Human from changeling import Changeling from clockwork import Clockwork from dwarf import Dwarf from goblin import Goblin from orc import Orc from roll import Roll from printer import Printer import random character = random.choice( [Human(), Changeling(), Clockwork(), Dwarf(), Goblin(), Orc()]) character.generate_name() character.char_level = 0 character.generate_info("background", Roll.a_dice("1d20")) character.generate_info("personality", Roll.a_dice("3d6")) character.generate_profession(Roll.a_dice("1d20")) character.generate_personality(Roll.a_dice("1d20"), Roll.a_dice("1d20"), Roll.a_dice("1d20")) character.generate_interesting_things(Roll.a_dice("1d6"), Roll.a_dice("1d20")) character.generate_wealth(Roll.a_dice("3d6")) Printer.print_common_info(character) character.generate_extra_info(character, True) # to-dos # add seed database generator # add pdf cheet generator # add ancestry descriptions
from zrpc import rpc from zrpc import worker from smoke_test import constants, models logger = logging.getLogger(__name__) logging.basicConfig(format=constants.LOG_FORMAT, datefmt=constants.LOG_DATE_FORMAT, level=logging.DEBUG) # Setup loop = zmq_asyncio.ZMQEventLoop() asyncio.set_event_loop(loop) app = loop.run_until_complete(Goblin.open(loop)) app.register(models.Node, models.Edge) cluster = app._cluster # Service RPC method defintions async def echo(request, response): response.write_final(request) async def yield_edge(request, response): async with aiohttp.ClientSession(loop=loop) as client: edge = await client.get('http://localhost:8080/') payload = await edge.read() logger.info(payload)
print("What do you want to do?") for i in range(len(Store.items)): item = Store.items[i] print("{}. buy {} ({})".format(i + 1, item.name, item.cost)) print("10. leave") input1 = int(input("> ")) if input1 == 10: break else: if hero.coins >= item.cost: ItemToBuy = Store.items[input1 - 1] item = ItemToBuy() hero.buy(item) else: print("You don't have enough coins for that.") if __name__ == "__main__": hero = Hero() enemies = [Goblin(), Wizard(), Shadow()] battle_engine = Battle() shopping_engine = Store() for enemy in enemies: hero_won = battle_engine.do_battle(hero, enemy) if not hero_won: print("YOU LOSE!") exit(0) shopping_engine.do_shopping(hero) print("YOU WIN!")
def level_1(self): gob1 = Goblin(LEFT + 20, DOWN, (self.all_sprites, self.enemys), self.enemys) gob2 = Goblin(RIGHT - 20, UP + 350, (self.all_sprites, self.enemys), self.enemys) gob3 = Goblin(LEFT + 50, UP + 30, (self.all_sprites, self.enemys), self.enemys)
def create_goblins(self): self.goblins = [] for i in range(0, self.wins + 1): self.goblins.append( Goblin('images/goblin.png', random.randint(20, width - 20), random.randint(20, height - 20)))
from goblin import Goblin from monsters import Monster the_goblin = Goblin()