Beispiel #1
0
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)
Beispiel #2
0
class TestRoom(unittest.TestCase):
    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_str(self):
        expected = f'{self.name}\n{self.description}'
        result = self.room.__str__()
        self.assertEqual(expected, result)

    def test_check_exit_positive(self):
        result = self.room._check_exit('north')
        self.assertTrue(result)

    def test_check_exit_negative(self):
        directions = ['west', 'North', 'vostok']
        for direction in directions:
            with self.subTest(direction):
                result = self.room._check_exit(direction)
                self.assertFalse(result)
 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)
Beispiel #4
0
 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)
Beispiel #5
0
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)
Beispiel #6
0
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.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)
Beispiel #8
0
 def test_add_item(self):
     rock = Item("rock")
     room = Room()
     before = len(room.items)
     self.assertNotIn(rock, room.items)
     room.add_item(rock)
     self.assertEqual(len(room.items), before + 1)
     self.assertIn(rock, room.items)
Beispiel #9
0
 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)
Beispiel #10
0
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 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, {})
Beispiel #12
0
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 == {}
Beispiel #13
0
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, {})
Beispiel #14
0
 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_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)
class TestRoom(unittest.TestCase):
    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 test_str(self):
        result = self.room.__str__()
        self.assertIs(type(result), str)
    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)
Beispiel #19
0
 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))
Beispiel #20
0
    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])
                                               "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])
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)
Beispiel #23
0
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, {},
Beispiel #24
0
 def test_room(self):
     room = Room("a", "b")
     self.assertEqual("a", room.name)
Beispiel #25
0
def test_map():
    start = Room("Start", "There is a path to the west.")
    west = Room("Trees", "There are trees here, the only path is to the 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)
Beispiel #26
0
 def test_show_no_items(self):
     room = Room()
     room.items = []
     self.assertEqual(room.show_items(), "")
Beispiel #27
0
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 test_room():
    gold = Room("GoldRoom", """This room has gold in it.""")
    assert_equal(gold.name, "GoldRoom")
    assert_equal(gold.paths, [])
Beispiel #29
0
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_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})

    print(id(west))
    print(id(start.go('west')))
    assert start.go('west') is west
    assert start.go('west').go('east') == start
    assert start.go('down').go('up') == start
Beispiel #31
0
import datetime
import logic
from game import Room
from random import randint
from sys import exit

now = datetime.datetime.now()
future_year = int(now.year) + 63

intro = Room("being stubborn. Just do what the game asks.",
"""The year is %i. The secrets of interstellar transport was discovered 25 years
ago. Mega-corporations reveled at the chance to dip their vile and slimy
hands into the stakes for the moon, then mars, then entire solar systems; Space
was colonized in under 10 years. The human civilization flourished while others
were crushed under the ruthless conviction of manifest destiny. Technological
advancements expanded like never before, and the Earthling Human of over half
a century ago was no more...""" % future_year, "Press Enter to Continue...")

character = Room("not reading the instructions are you? Just do what the game asks",
"""You are Klae LosForeve: Orphan. Hacker. Derelict.
A 28 year old genius who spent most his life dedicated to one thing - an oddity
in this world of up-to-the-millisecond updates of information and communication.
However, your skills are second to none when it comes to anything electronic.
Naturally, this has allowed you to build a respectable corporation known for
the sales of star-vessel necessities and arms, despite your growing agoraphobia
and despite the fact that some of these sales sometimes blurred the line between
right and wrong...""", "Press Enter to Continue...")

articles = randint(550, 780) # Why? Pure randomness, that's why!
apartment = Room("in your Apartment",
"""You emerge from your bedroom in the spacious living room of your \'sky-rise\'
Beispiel #32
0
def test_room():
    gold = Room("Goldroom", """ Testing shit """)
    assert_equal(gold.name, "Goldroom")
    assert_equal(gold.paths, {})
Beispiel #33
0
 def test_show_items(self):
     room = Room()
     room.items = [Item("rock"), Item("egg"), Item("gun")]
     self.assertIn("rock", room.show_items())
     self.assertIn("egg", room.show_items())
     self.assertIn("gun", room.show_items())
Beispiel #34
0
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])