def test_room_paths(): center= Room("Center", "Test room in the center.") north = Room("North", "Test room in the north.") south = Room("South", "Test room in the south.") center. add_paths({'north': north, 'south': south}) assert_equal(center.go('north'), north) assert_equal(center.go('south'), south)
def setUp(self): self.room1 = Room(0, 0, "Main room", "", ["north"]) self.room2 = Room(0, -1, "Second room", "", ["south"]) self.map = { (self.room1.x, self.room1.y): self.room1, (self.room2.x, self.room2.y): self.room2 } self.game = Game(self.map)
def test_room_paths(): center = Room("Center", "Test room in the center.") north = Room("North", "Test room in the north.") south = Room("South", "Test room in the south.") center.add_paths({"north": north, "south": south}) assert_equal(center.go("north"), north) assert_equal(center.go("south"), south)
def test_map(): start = Room("Start", "You can go west and down a hole.") west = Room("Trees", "There are trees here, you can go east.") down = Room("Dungeon", "It's dark down here, you can go up.") start.add_paths({'west': west, 'down': down}) west.add_paths({'east': start}) down.add_paths({'up': start}) assert_equal(start.go('west'), west) assert_equal(start.go('west').go('east'), start) assert_equal(start.go('down').go('up'), start)
def setUp(self): self.room1 = Room(0, 0, "Main room", "", ["north"]) self.room2 = Room(0, -1, "Second room", "", ["south", "east"]) self.room3 = Room(1, -1, 'Third room', '', ['west', 'north']) self.map = { (self.room1.x, self.room1.y): self.room1, (self.room2.x, self.room2.y): self.room2, (self.room3.x, self.room3.y): self.room3 } self.game = Game(self.map)
def test_map(): start = Room("Start", "You can go west and down a hole.") west = Room("Trees", "There are trees here, you can go east.") down = Room("Dungeon", "It's dark down here, you can up") start.add_paths({"west": west, "down": down}) west.add_paths({"east": start}) down.add_paths({"up": start}) assert_equal(start.go("west"), west) assert_equal(start.go("west").go("east"), start) assert_equal(start.go("down").go("up"), start)
def test_map(): start=Room("start", "you can go west and down a hole") west= Room("trees", "there are treest here ") down= Room("dungeon", "it is dark down here, you can go up") start.add_paths({'west': west, 'down': down}) west.add_paths({"east": start}) down.add_paths({'up': start}) assert_equalstart.go('west'), west) assert_equal(start.go('west').go('east'), start) assert_equal(start.go('down').go('up'), start)
def test_room(): gold = Room( "GoldRoom", """This room has gold in it you can grab. There's a door to the north.""" ) assert gold.name == "GoldRoom" assert gold.paths == {}
def test_room(): gold = Room("GoldRoom", """This room has gold in it you can grab. There's a door to the north.""") # assert equal assures that variables are the same assert_equal(gold.name, "GoldRoom") assert_equal(gold.paths, {})
def test_room(): gold = Room( "Gold Room", """This room has gold in it you can grab. There's a door to the north.""") assert_equal(gold.name, "GoldRoom") assert_equal(gold.paths, {})
def setUp(self): self.x = 5 self.y = 4 self.name = "Room to test your unit" self.description = "You see units standing, ready for test" self.exits = ['This way', 'That way'] self.room = Room(self.x, self.y, self.name, self.description, self.exits)
def setUp(self): self.x = 5 self.y = 4 self.name = "Room to test your unit" self.description = "You see units standing, ready for test." self.exits = ['north', 'south'] self.room = Room(self.x, self.y, self.name, self.description, self.exits)
def test_empty_container(self): container = Container.Container("test", ["keyword"], "Short desc", "Long desc", True, False, []) room = Room.Room("Test Room", "desc", {}, [container], []) player = Player.Player(room, []) actual = container.examine(player) expected = container.long_desc self.assertEqual(expected, actual)
def test_take_command_item_not_present(self): user_input = ["take", "test not present"] player = copy.copy(Test_Objects.TEST_PLAYER) room = Room.Room("Test Room", "This is a test room for testing.", {}, [Test_Objects.TEST_ITEM_ON_GROUND], []) item = copy.copy(Test_Objects.TEST_ITEM_NOT_PRESENT) self.assertTrue(item not in room.items) self.assertTrue(item not in player.inventory) actual = Commands.parse_take_command(user_input, player) self.assertTrue(item not in room.items) self.assertTrue(item not in player.inventory) self.assertEqual(Constants.ITEM_NOT_VISIBLE_STRING, actual)
def test_take_command_item_with_keyword(self): user_input = ["take", "keyword"] item = Item.Item("test 2", ["keyword"], "Short desc 2", "Long desc 2", True, True) room = Room.Room("Test Room", "This is a test room for testing.", {}, [item], []) player = Player.Player(room, [Test_Objects.TEST_ITEM_IN_INVENTORY]) self.assertTrue(item in room.items) self.assertTrue(item not in player.inventory) actual = Commands.parse_take_command(user_input, player) self.assertTrue(item not in room.items) self.assertTrue(item in player.inventory) self.assertEqual("You take the test 2.", actual)
def initData(self): self.registers({\ 1001 : self.arriveRoomHandler,\ 1002 : self.sendMessageHandler,\ 1003 : self.leaveRoomHandler,\ 1004 : self.takeChessHandler,\ 1005 : self.getReadyHandler,\ 1006 : self.disReadyHandler,\ 1007 : self.requestUndoHandler,\ 1008 : self.acceptUndoHandler,\ 1009 : self.notAcceptUndoHandler,\ 1010 : self.commitLostHandler,\ }) self.rooms = [] for i in xrange(31): self.rooms.append(Room(i,self))
def test_container_with_item(self): container = Container.Container("test", ["keyword"], "Short desc", "Long desc", True, False, [Test_Objects.TEST_ITEM_ON_GROUND]) room = Room.Room("Test Room", "desc", {}, [container], []) player = Player.Player(room, []) self.assertEqual(container.contains, [Test_Objects.TEST_ITEM_ON_GROUND]) self.assertEqual(room.items, [container]) actual = container.examine(player) expected = container.long_desc + '. ' + Constants.ITEM_REMOVED_FROM_CONTAINER_STRING +\ Test_Objects.TEST_ITEM_ON_GROUND.name + '.' self.assertEqual(expected, actual) self.assertEqual(container.contains, []) self.assertEqual(room.items, [container, Test_Objects.TEST_ITEM_ON_GROUND])
def test_room(): gold = Room("GoldRoom", """This room has gold in it.""") assert_equal(gold.name, "GoldRoom") assert_equal(gold.paths, [])
def test_room(): gold = Room("Goldroom", """ Testing shit """) assert_equal(gold.name, "Goldroom") assert_equal(gold.paths, {})
LOUNGE_ROOM_ENTRY_DESCRIPTION = "You are in the loungeroom after just entering the house. Sun streams in through the \n" \ "door, but the screen door is shut to keep the cats in. The room is a study in \n" \ "controlled chaos as various toys are scattered about the area. I wonder who could \n" \ "have done that? You see exits to the south, north, and east." LOUNGE_ROOM_EAST_DESCRIPTION = "You are in the loungeroom to the right of the door, near your and Nan's room. You \n" \ "see exits to the west, north, east, and south." FRONT_VERANDAH_ROOM_DESCRIPTION = "You are on the front verandah. A few of Gideon's cars are scattered about. You \n" \ "generally pick up after him, so he must have been here recently. You see exits \n" \ "to the north and south." NAN_ROOM_DESCRIPTION = "You are in Nan's room. There's not much to see here. You see an exit to the north." STUDY_ROOM_DESCRIPTION = "You are in the study. Various art and craft supplies cover the shelves. Fortunately, there \n" \ "are no key items here - the designer of this game isn't cruel enough to make you search \n" \ "all around this room! You see an exit to the west." # Instantiate rooms first, then create exits. A room must be instantiated to be pointed to as an exit. FRONT_YARD_ROOM = Room.Room("Front Yard", FRONT_YARD_DESCRIPTION, {}, [], []) SIDE_PATH_ROOM = Room.Room("Side Path", SIDE_PATH_DESCRIPTION, {}, [], []) ZOE_CAR_ROOM = Room.Room("Zoe's Car", ZOE_CAR_DESCRIPTION, {}, [], []) DRIVEWAY_ROOM = Room.Room("Driveway", DRIVEWAY_DESCRIPTION, {}, [], []) SHED_ROOM = Room.Room("Shed", SHED_DESCRIPTION, {}, [Items.BEAR_FIGURINE], [People.MOLLY]) BACK_GARDEN_ROOM = Room.Room("Back Garden", BACK_GARDEN_DESCRIPTION, {}, [], [People.NAN, People.ZOE]) BACK_VERANDAH_ROOM = Room.Room("Back Verandah", BACK_VERANDAH_DESCRIPTION, {}, [], []) LAUNDRY_ROOM = Room.Room("Laundry Room", LAUNDRY_DESCRIPTION, {}, [], []) BATHROOM = Room.Room("Bathroom", BATHROOM_DESCRIPTION, {}, [Items.MOUSE_FIGURINE], []) KITCHEN = Room.Room("Kitchen", KITCHEN_DESCRIPTION, {}, [Items.FRIDGE, Items.CHOCOLATE], []) GUEST_ROOM = Room.Room("Guest Room", GUEST_ROOM_DESCRIPTION, {},
def test_room(self): room = Room("a", "b") self.assertEqual("a", room.name)
from game import Room, Item knife = Item('knife', 'A pointy looking thing. Might be good att stabbing things', 3, 2) sword = Item('sword', 'A big bad sword', 4, 4) world = {} world['entrance'] = Room( 'entrance', 'You stand in the entrance of a big house. To the north is a door', ['n'], {'n': 'ballroom'}, [knife]) world['ballroom'] = Room( 'ballroom', 'You walk in to a big ballroom. In the middle of the room in the floor lies a blänkande svärd! \nThere is a door to the west, east and sout', ['s'], {'s': 'entrance'}, [sword, knife])
"Short desc", "Long desc", True, False, [TEST_ITEM_ON_GROUND]) TEST_CONTAINER_WITH_INVISIBLE_ITEM = Container.Container( "test", ["keyword"], "Short desc", "Long desc", True, False, [TEST_ITEM_NO_VIS]) # People TEST_PERSON = Person.Person("Testman", "You see a test man", True) TEST_INVISIBLE_PERSON = Person.Person("Testman", "You shouldn't see this test man", False) TEST_GIDEON = Gideon.Gideon("Gideon", "You see a Gideon", True) TEST_INVISIBLE_GIDEON = Gideon.Gideon("Gideon", "You should not see this Gideon", False) # Rooms TEST_ROOM = Room.Room("Test Room", "This is a test room for testing.", {}, [TEST_ITEM_ON_GROUND], []) TEST_ROOM_2 = Room.Room( "Test Room 2", "This is a test room 2 for testing.", {"s": TEST_ROOM}, [TEST_ITEM_ON_GROUND, TEST_ITEM_NO_GET, TEST_ITEM_NO_VIS], []) TEST_ROOM.exits = {"n": TEST_ROOM_2} TEST_ROOM_WITH_PERSON = Room.Room("Test Room With Person", "This is a test room for testing people.", {"n": TEST_ROOM_2}, [TEST_ITEM_ON_GROUND], [TEST_PERSON]) TEST_ROOM_WITH_INVISIBLE_PERSON = Room.Room( "Test Room With Invis Person", "This is a test room for testing people.", {"n": TEST_ROOM_2}, [TEST_ITEM_ON_GROUND], [TEST_INVISIBLE_PERSON]) TEST_ROOM_WITH_GIDEON = Room.Room("Test Room With Gideon", "This is a test room for testing Gideon.", {"n": TEST_ROOM_2}, [TEST_ITEM_ON_GROUND], [TEST_GIDEON])