def testRadiusZombie(self):
     example = [[Tile((i, j)) for i in range(3)] for j in range(3)]
     example[0][0].add_character(Player(1, 0, "name"))
     adverse = AdversaryDriver("Jeff", "zombie", 1, [])
     adverse.gameState = example
     result = adverse.ring((0, 0), (2, 2))
     self.assertEqual([(0, 0)], result)
    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 #3
0
 def set_exit(self, pos):
     new_exit = ExitTile(pos)
     if self.exit is not None:
         old_exit_x, old_exit_y = self.exit.get_position()
         self.grid[old_exit_x][old_exit_y] = Tile((old_exit_x, old_exit_y))
         new_exit = self.exit.transfer_info(new_exit)
     oldTile = self.grid[pos[0]][pos[1]]
     self.grid[pos[0]][pos[1]] = new_exit
     new_exit = oldTile.transfer_info(new_exit)
     self.exit = new_exit
 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 testGhostPickMoves1(self):
     example = []
     for x in range(5):
         column = []
         for y in range(5):
             if x == 0:
                 column.append(WallTile((x, y)))
             else:
                 column.append(Tile((x, y)))
         example.append(column)
     gost = AdversaryDriver("Boo", "ghost", 2, [])
     gost.update_state(SimpleState(example), (2, 2))
     moves = gost.pick_moves()
     self.assertEqual([(2, 1), (1, 2)], moves)
 def testRadiusGhost2(self):
     example = []
     for x in range(5):
         column = []
         for y in range(5):
             if x == 0:
                 column.append(WallTile((x, y)))
             else:
                 column.append(Tile((x, y)))
         example.append(column)
     gost = AdversaryDriver("Boo", "ghost", 2, [])
     gost.gameState = example
     result = gost.ring((0, 0), (4, 4))
     self.assertEqual([(0, 0), (0, 4), (0, 3), (0, 2), (0, 1)], result)
     example[1][1].add_character(Player(1, 0, "name"))
     result = gost.ring((0, 0), (4, 4))
     self.assertEqual([(0, 0), (0, 4), (0, 3), (0, 2), (0, 1)], result)
Exemple #7
0
 def generate_tiles(self, tiles):
     grid = []
     x = len(tiles)
     y = len(tiles[0])
     offX = self.upperLeft[0]
     offY = self.upperLeft[1]
     for i in range(x):
         column = []
         for j in range(y):
             new_tile = None
             if tiles[i][j] == 0:
                 new_tile = WallTile((i + offX, j + offY))
             elif tiles[i][j] == 1:
                 new_tile = Tile((i + offX, j + offY))
             new_tile.set_room(self)
             column.append(new_tile)
         grid.append(column)
     return grid
Exemple #8
0
 def generate_tiles(self):
     tiles = []
     length = len(self.connectDots)
     beginning = self.connectDots[0]
     end = self.connectDots[len(self.connectDots) - 1]
     point = 0
     first = beginning
     dotCount = 0
     for dot in self.connectDots:
         if dotCount == 0 or dotCount == len(self.connectDots) - 1:
             dotCount = dotCount + 1
             continue
         til = Tile((dot[0], dot[1]))
         til.set_room(self)
         tiles.append(til)
         dotCount = dotCount + 1
     while point < length - 2:
         nextWay = self.connectDots[point + 1]
         point = point + 1
         startX = first[0]
         startY = first[1]
         nextX = nextWay[0]
         nextY = nextWay[1]
         if startY == nextY:
             lil = min(startX, nextX)
             big = max(startX, nextX)
             cursor = lil + 1
             while cursor < big:
                 hallTile = Tile((cursor, startY))
                 hallTile.set_room(self)
                 tiles.append(hallTile)
                 cursor = cursor + 1
         if startX == nextX:
             lil = min(startY, nextY)
             big = max(startY, nextY)
             cursor = lil + 1
             while cursor < big:
                 hallTile = Tile((startX, cursor))
                 hallTile.set_room(self)
                 tiles.append(hallTile)
                 cursor = cursor + 1
         first = nextWay
     nextWay = self.connectDots[len(self.connectDots) - 1]
     startX = first[0]
     startY = first[1]
     nextX = nextWay[0]
     nextY = nextWay[1]
     if startY == nextY:
         lil = min(startX, nextX)
         big = max(startX, nextX)
         cursor = lil + 1
         while cursor < big:
             hallTile = Tile((cursor, startY))
             hallTile.set_room(self)
             tiles.append(hallTile)
             cursor = cursor + 1
     if startX == nextX:
         lil = min(startY, nextY)
         big = max(startY, nextY)
         cursor = lil + 1
         while cursor < big:
             hallTile = Tile((startX, cursor))
             hallTile.set_room(self)
             tiles.append(hallTile)
             cursor = cursor + 1
     return (beginning, end, tiles)
Exemple #9
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()
Exemple #10
0
 def testTile(self):
     tile = Tile((1, 1))
     self.assertEqual((1, 1), tile.get_position())
     tile.add_item("Potion")