def getScoreOfKilledEnemies(self, killedEnemies): score = 0 multiplier = 1 for dist in range(len(killedEnemies)): list = killedEnemies[dist] sortedList = sorted(list) for enemy in sortedList: score += Enemy.getEnemy(enemy)['points'] * multiplier multiplier *= 2 return score
def moveEnemy(self, speed): for i in range(self.level.numberEnemies): if (Enemy.getEnemy(self.level.listEnemies[i][3])['speed'] == speed): curX = self.level.listEnemies[i][0] curY = self.level.listEnemies[i][1] tempDir = self.level.listEnemies[i][2] tempWP = Enemy.getEnemy(self.level.listEnemies[i][3])['wallpass'] tempIntel = Enemy.getEnemy(self.level.listEnemies[i][3])['intelligence'] newX = 0 newY = 0 randInt = 0 hasDied = False hasMoved = False if (tempIntel == 3): randInt = 2 elif (tempIntel == 2): randInt = 10 if (tempIntel == 2 or tempIntel == 3): if (self.level.board[curY+1][curX].peek() == Tile.Bomberman and hasMoved == False): newX = curX newY = curY + 1 tempDir = 0 hasMoved = True hasDied = True if (self.level.board[curY-1][curX].peek() == Tile.Bomberman and hasMoved == False): newX = curX newY = curY - 1 tempDir = 2 hasMoved = True hasDied = True if (self.level.board[curY][curX+1].peek() == Tile.Bomberman and hasMoved == False): newX = curX + 1 newY = curY tempDir = 1 hasMoved = True hasDied = True if (self.level.board[curY][curX-1].peek() == Tile.Bomberman and hasMoved == False): newX = curX - 1 newY = curY tempDir = 3 hasMoved = True hasDied = True tempTile = self.level.board[curY+1][curX].peek() if (tempTile != Tile.Bomb and ((tempTile == Tile.Brick and tempWP == True) or tempTile != Tile.Brick) and tempTile != Tile.Concrete and random.randint(1,randInt) == 1 and hasMoved == False): newX = curX newY = curY + 1 tempDir = 0 hasMoved = True tempTile = self.level.board[curY-1][curX].peek() if (tempTile != Tile.Bomb and ((tempTile == Tile.Brick and tempWP == True) or tempTile != Tile.Brick) and tempTile != Tile.Concrete and random.randint(1,randInt) == 1 and hasMoved == False): newX = curX newY = curY - 1 tempDir = 2 hasMoved = True tempTile = self.level.board[curY][curX+1].peek() if (tempTile != Tile.Bomb and ((tempTile == Tile.Brick and tempWP == True) or tempTile != Tile.Brick) and tempTile != Tile.Concrete and random.randint(1,randInt) == 1 and hasMoved == False): newX = curX + 1 newY = curY tempDir = 1 hasMoved = True tempTile = self.level.board[curY][curX-1].peek() if (tempTile != Tile.Bomb and ((tempTile == Tile.Brick and tempWP == True) or tempTile != Tile.Brick) and tempTile != Tile.Concrete and random.randint(1,randInt) == 1 and hasMoved == False): newX = curX - 1 newY = curY tempDir = 3 hasMoved = True if (hasMoved == True): self.level.listEnemies[i][0] = newX self.level.listEnemies[i][1] = newY self.level.listEnemies[i][2] = tempDir self.popTileAt(curX, curY) self.setTileAt(newX, newY, self.level.listEnemies[i][3]) if (hasDied == True): self.death() return False if (tempIntel == 1 or hasMoved == False): if (tempDir == 0): newX = curX newY = curY + 1 elif (tempDir == 1): newX = curX + 1 newY = curY elif (tempDir == 2): newX = curX newY = curY - 1 elif (tempDir == 3): newX = curX - 1 newY = curY tempTile = self.level.board[newY][newX].peek() if (tempTile == Tile.Bomb or (tempTile == Tile.Brick and tempWP == False) or tempTile == Tile.Concrete): if (tempDir == 0): newY -= 2 elif (tempDir == 1): newX -= 2 elif (tempDir == 2): newY += 2 elif (tempDir == 3): newX += 2 self.level.listEnemies[i][2] = (self.level.listEnemies[i][2] + 2) % 4 # tempTile = self.level.board[newY][newX].peek() # # if (tempTile == Tile.Bomb or tempTile == Tile.Brick or tempTile == Tile.Concrete): # self.level.listEnemies[i][2] = (self.level.listEnemies[i][2] + 1) % 4 tempTile = self.level.board[newY][newX].peek() if ((tempTile == Tile.Brick and tempWP == True) or (tempTile != Tile.Bomb and tempTile != Tile.Brick and tempTile != Tile.Concrete)): self.level.listEnemies[i][0] = newX self.level.listEnemies[i][1] = newY self.popTileAt(curX, curY) self.setTileAt(newX, newY, self.level.listEnemies[i][3]) if (tempTile == Tile.Bomberman): self.death() return False