-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathplayer.py
More file actions
28 lines (23 loc) · 900 Bytes
/
player.py
File metadata and controls
28 lines (23 loc) · 900 Bytes
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
import random
import uuid
class Player:
def __init__(self, name, starting_room, password_hash):
self.username = name
self.current_room = starting_room
self.auth_key = Player.__generate_auth_key()
self.password_hash = password_hash
self.uuid = uuid.uuid4
def __generate_auth_key():
digits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f']
auth_key_list = []
for i in range(40):
auth_key_list.append(random.choice(digits))
return "".join(auth_key_list)
def travel(self, direction, show_rooms = False):
next_room = self.current_room.get_room_in_direction(direction)
if next_room is not None:
self.current_room = next_room
return True
else:
print("You cannot move in that direction.")
return False