def test_do_drop(self): game = GitCrystalsCmd() line = 'take No Trespassing Sign' stop = game.onecmd(line) game.postcmd(stop, line) line = 'drop No Trespassing Sign' stop = game.onecmd(line) game.postcmd(stop, line) actual_inventory = game.player.js_inventory.data inventory_list = [("Basic Clothes", 1), ("Distress Note", 1), ("Git Gem", 1)] expected_inventory = OrderedDict(inventory_list) self.assertEqual(actual_inventory, expected_inventory)
def test_go(self): G.change_location_file("Mountain Gate") game = GitCrystalsCmd() line = 'go north' stop = game.onecmd(line) game.postcmd(stop, line) expected_location = "Git Crystal" player_location = game.player.location json_file = JsonData(G.repodir, "location") file_location = json_file.data['location'] self.assertEqual(player_location, expected_location) self.assertEqual(file_location, expected_location) G.change_location_file("Mountain Gate")
def test_do_perilious_search(self): G.change_location_file("Abandoned Treasury") game = GitCrystalsCmd() line = 'search' stop = game.onecmd(line) game.postcmd(stop, line) expected = """In Abandoned Treasury you see... Charcoal Treasure Chest Key """ output = game.output alive = game.player.js_alive.data['alive'] game.do_checkoutfile('alive.json') game.do_checkoutfile('location.json') self.assertEqual(expected, output) self.assertFalse(alive)
def test_do_perilious_search_with_others(self): G.change_location_file("Abandoned Treasury") G.change_character_info('princess', 'location', 'Abandoned Treasury') game = GitCrystalsCmd() line = 'search' stop = game.onecmd(line) game.postcmd(stop, line) output = game.output alive = game.player.js_alive.data['alive'] princess_alive = game.characters['princess'].js_alive.data['alive'] expected = """In Abandoned Treasury you see... Charcoal Treasure Chest Key\n""" game.do_checkoutfile('alive.json') game.do_checkoutfile('location.json') game.do_checkoutfile('princess/location.json') self.assertEqual(expected, output) self.assertFalse(alive) self.assertFalse(princess_alive)