def spawn_boss_test(): # Test if boss is spawned in correct location a_map = map_gen.new_map() # check if lair and boss's scene names agree ok_(a_map.boss_scene_name == a_map.lair_scene_name) # check if boss is actually in scene sc = a_map.scenes[a_map.boss_scene_name] ok_(sc.flags['encounter']) # check if the boss is in the lair lair = sc.get_lair() ok_(lair.has_boss)
def prepare_canvas_test(): # Test if links are drawn properly ### Simple test ### a_map = map_.Map('story') # create scenes with location data s1 = map_gen.new_scene(a_map, None, (1, 1)) s2 = map_gen.new_scene(a_map, None, (2, 1)) s3 = map_gen.new_scene(a_map, None, (1, 2)) s4 = map_gen.new_scene(a_map, None, (2, 2)) # set scene names s1.name = 'scene1' s2.name = 'scene2' s3.name = 'scene3' s4.name = 'scene4' # update exits s1.exits.update({'se': 'scene4'}) s4.exits.update({'nw': 'scene1'}) s2.exits.update({'sw': 'scene3'}) s3.exits.update({'ne': 'scene2'}) # add scenes to map a_map.add_scene(s1) a_map.add_scene(s2) a_map.add_scene(s3) a_map.add_scene(s4) # prepare canvas canvas = draw_map.prepare_canvas(a_map, (1, 1)) draw_map.print_canvas(canvas) # tests ok_(canvas[1][1] == 'X') ### Automated tests on procedurally generated maps ### for x in range(1, 101): a_map = map_gen.new_map() # prepare canvas canvas = draw_map.prepare_canvas(a_map, None) draw_map.print_canvas(canvas) # for each scene for sc in a_map.scenes.values(): # for each exit for ex in sc.exits.keys(): # calculate canvas position of the link canvas_x, canvas_y = draw_map.get_canvas_link_location( sc.location, ex) # check if link is the correct symbol print "{}: {}".format(sc.location, sc.exits) ok_(canvas[canvas_x][canvas_y] == draw_map.SYMBOL_LINK[ex] or \ canvas[canvas_x][canvas_y] == 'X')
""" This is entry point of the game. Usage: $ python game.py """ import engine import map_gen import arena print "Wecome!" print " 1. Story" print " 2. Arena" while True: action = raw_input("Choose a number: ") if action == "1": a_map = map_gen.new_map() a_map.add_characters() a_game = engine.Engine() a_game.add_map(a_map) a_game.play_story() elif action == "2": a_arena = arena.Arena() a_game = engine.Engine() a_game.add_arena(a_arena) a_game.play_arena() else: print "Please enter either '1' or '2'."