-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.py
53 lines (41 loc) · 1.4 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
50
51
52
53
"""Defines the player."""
from direction import Direction
class Player:
"""Defines the player."""
def __init__(self, name, startLocation):
"""Initialize the Player."""
self.__name = name
self.__location = startLocation
self.__facingDirection = Direction.NORTH
@property
def name(self):
"""Get the player's name."""
return self.__name
@property
def location(self):
"""Get the player's location."""
return self.__location
@location.setter
def location(self, value):
"""Set the player's location."""
self.__location = value
@property
def facingDirection(self):
"""Get the direction that the player is facing."""
return self.__facingDirection
@property
def facingDirectionName(self):
"""Get the name of the direction that the player is facing."""
return Direction.getName(value=self.facingDirection)
def turnLeft(self):
"""Make the player face to the direction to the left."""
if self.__facingDirection == 0:
self.__facingDirection = Direction.MAX
else:
self.__facingDirection -= 1
def turnRight(self):
"""Make the player face to the direction to the right."""
if self.__facingDirection == Direction.MAX:
self.__facingDirection = 0
else:
self.__facingDirection += 1