Need to complete the following python shell code:
import pygame
import random
# RESOURCES
def drawBoards(screen, board1, board2):
[login to view URL](screen, 40, 80, 25)
[login to view URL](screen, 350, 80, 25)
[login to view URL]()
def convertToBoard(pos):
x = int((pos[0] - 350) / 25)
y = int((pos[1] - 80) / 25)
return (x, y)
class Board:
def __init__(self):
[login to view URL] = [[0 * 10] * 10 for x in range(10)];
def drawSelf(self, screen, x, y, tileSize):
for r in range(len([login to view URL])):
for c in range(len([login to view URL][r])):
if [login to view URL][r][c] == 0: # blank water = blue
drawColor = (0, 0, 255)
elif [login to view URL][r][c] == 1: # unhit ship = light blue
drawColor = (150, 150, 255)
elif [login to view URL][r][c] == 2: # miss = yellow
drawColor = (255, 255, 0)
elif [login to view URL][r][c] == 3: # hit ship = red
drawColor = (255, 0, 0)
[login to view URL](screen, drawColor, [login to view URL](x + c * tileSize, y + r * tileSize, tileSize, tileSize))
for r in range(len([login to view URL])):
[login to view URL](screen, (0, 0, 0), (x + r * tileSize, y), (x + r * tileSize, y + len([login to view URL]) * tileSize))
[login to view URL](screen, (0, 0, 0), (x, y + r * tileSize), (x + len([login to view URL]) * tileSize, y + r * tileSize))
def setValue(self, x, y, value):
[login to view URL][y][x] = value
def getValue(self, x, y):
return [login to view URL][y][x]
def enemyAttack(player):
# DO STUFF HERE
# /DO STUFF HERE
return False
def playerAttack(enemy, seenEnemy, x, y):
# DO STUFF HERE
# /DO STUFF HERE
return False
def placeShip(board, shipSize):
# DO STUFF HERE
# /DO STUFF HERE
pass
# /RESOURCES
screen = pygame.display.set_mode((640, 480))
playersTurn = True
# TODO: set up player, enemy, and seenEnemy boards
# DO STUFF HERE
# place ships
# /DO STUFF HERE
while True:
evt = [login to view URL]()
if [login to view URL] == [login to view URL]:
break
if playersTurn and [login to view URL] == [login to view URL]:
# process mouse actions
coord = convertToBoard([login to view URL])
x = coord[0]
y = coord[1]
# TODO: process human input, fire at point (x, y)
# DO STUFF HERE
# /DO STUFF HERE
# process enemy attack
if not playersTurn:
if enemyAttack(player):
enemyHits += 1
playersTurn = True
# TODO: call drawBoards with appropriate input
# DO STUFF HERE
# /DO STUFF HERE
# after victory, wait for X button
while True and (playerHits == 17 or enemyHits == 17):
evt = [login to view URL]()
if [login to view URL] == [login to view URL]:
break
[login to view URL]()