-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.py
49 lines (43 loc) · 1.26 KB
/
player.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""
Description: Class for player object
<pre>
Name: Gabriel Krishnadasan, Alizea Hinz, Aidan Rooney, Marissa Nicole Esteban (Pascal)
Course: COMP-305 FA22
Professor: A. Nuzen
</pre>
"""
from cell import cell
class player(object):
def __init__(self, playerNum, score:int, is_turn:bool)->None:
"""
Constructor for player object
"""
self.playerNum = playerNum
self.score = score
self.is_turn = is_turn
shipCells = []
for r in range(10):
row = []
for c in range(10):
row.append(cell(False, False, "NA", False))
shipCells.append(row)
attackingCells = []
for r in range(10):
row = []
for c in range(10):
row.append(cell(False, False, "NA", False))
attackingCells.append(row)
self.shipCells = shipCells
self.attackingCells = attackingCells
self.numOfHits = 0
self.playerShips = {}
def incrementHits(self)->None:
"""
Increment the number of hits that a player has made
"""
self.numOfHits += 1
def __str__(self)->str:
"""
String representation of the player object
"""
return ("Player %d", self.playerNum)