Exemple #1
0
 def testRegisterUsers(self):
     example = [[1 for i in range(10)] for j in range(10)]
     hall = Hallway((14, 5), (20, 5), [])
     zHall = Hallway((14, 14), (20, 10), [(17, 14), (17, 10)])
     room = Room(example, (5, 5))
     room2 = Room(example, (20, 5))
     floor = Floor([room, room2], [hall, zHall])
     game = GameState([floor])
     gm = GameManager(game)
     gm.register_player_user(self.LocalPlayer1)
     gm.register_player_user(self.LocalPlayer2)
     self.assertEqual(2, len(gm.ID_to_user_character))
Exemple #2
0
 def testUpdateUsers(self):
     example = [[1 for i in range(10)] for j in range(10)]
     hall = Hallway((14, 5), (20, 5), [])
     zHall = Hallway((14, 14), (20, 10), [(17, 14), (17, 10)])
     room = Room(example, (5, 5))
     room2 = Room(example, (20, 5))
     floor = Floor([room, room2], [hall, zHall])
     game = GameState([floor])
     gm = GameManager(game)
     gm.register_player_user(self.LocalPlayer1)
     gm.register_player_user(self.LocalPlayer2)
     gm.init_Rule_Checker()
     gm.take_turn(0)
     p1State = self.LocalPlayer1.gameState.grid
     p2State = self.LocalPlayer2.gameState.grid
     p1pos = self.LocalPlayer1.get_position()
     p2pos = self.LocalPlayer2.get_position()
     self.assertEqual(p1State, p2State)
     self.assertEqual((5, 6), p1pos)
     self.assertEqual((6, 5), p2pos)
Exemple #3
0
def roomMaker(room):
    origin = (room["origin"][1], room["origin"][0])
    rows = room["bounds"]["rows"]
    cols = room["bounds"]["columns"]
    layout = room["layout"]
    doors = []
    grid = []
    for col in range(cols):
        column = []
        for row in range(rows):
            if layout[row][col] == 2:
                column.append(1)
            else:
                column.append(layout[row][col])
        grid.append(column)

    final = Room(grid, origin)
    for door in doors:
        final.addDoor(door)

    return final
 def testZombieRequestMove1(self):
     room = Room([[]], (0, 0))
     example = []
     for x in range(5):
         column = []
         for y in range(5):
             if x == 0:
                 column.append(WallTile((x, y)))
             else:
                 t = Tile((x, y))
                 t.room = room
                 column.append(Tile((x, y)))
         example.append(column)
     # example[1][1].add_character(Player(1, 0, "reggie"))
     gost = AdversaryDriver("Boo", "zombie", 2, [])
     gost.update_state(SimpleState(example), (2, 2))
     moves = []
     moves.append(gost.request_move())
     moves.append(gost.request_move())
     moves.append(gost.request_move())
     moves.append(gost.request_move())
     moves.append(gost.request_move())
     expected = [(3, 2), (2, 1), (2, 3), (1, 2), (2, 2)]
     for ex in expected:
         self.assertTrue(ex in moves)
     room.addDoor(example[2][1], Hallway((0, 0), (2, 1), []))
     example[2][1].set_room(room)
     moves = []
     state = SimpleState(example)
     gost.update_state(state, (2, 3))
     state.get_tile_at((2, 1)).set_room(room)
     gost.update_state(state, (2, 2))
     moves.append(gost.request_move())
     moves.append(gost.request_move())
     moves.append(gost.request_move())
     moves.append(gost.request_move())
     expected = [(3, 2), (2, 3), (1, 2), (2, 2)]
     for ex in expected:
         self.assertTrue(ex in moves)
    def testZombiePickMoves1(self):
        room = Room([[]], (0, 0))
        example = []
        for x in range(5):
            column = []
            for y in range(5):
                if x == 0:

                    column.append(WallTile((x, y)))
                else:
                    t = Tile((x, y))
                    t.room = room
                    column.append(Tile((x, y)))
            example.append(column)
        example[1][1].add_character(Player(1, 0, "reggie"))
        gost = AdversaryDriver("Boo", "zombie", 2, [])
        gost.update_state(SimpleState(example), (2, 2))
        moves = gost.pick_moves()
        self.assertEqual([(2, 1)], moves)
Exemple #6
0
        return raw_tile.get_room()

    def reaches(self, structure):
        return structure.return_neighbors()

    def get_items(self):
        itemPosns = []
        for tile in self.itemTiles:
            pos = tile.get_position()
            items = tile.get_all_items()
            for item in items:
                itemPosns.append((item.get_name(), pos))
        return itemPosns

    def check_if_unlocked(self):
        itemPosns = self.get_items()
        for item in itemPosns:
            if item[0] == "key" or item[1] == "Key":
                return False
        return True


if __name__ == "__main__":
    example = [[Tile((i, j)) for i in range(10)] for j in range(10)]
    hall = Hallway((14, 5), (21, 5), [])
    zHall = Hallway((14, 14), (21, 10), [(17, 14), (17, 10)])
    room = Room(example, (5, 5))
    room2 = Room(example, (20, 5))
    floor = Floor([room, room2], [hall, zHall])
    floor.draw()