-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.py
51 lines (40 loc) · 1.61 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
from random import randint, choice
from os import listdir
from uuid import uuid4
first_names: dict[str, list[str]] = {}
last_names: dict[str, list[str]] = {}
for file in listdir("prenoms"):
with open("prenoms/" + file, 'r', encoding="utf-8") as f:
content = f.read().split("\n")
first_names[file] = content
# print(first_names)
for file in listdir("noms"):
with open("noms/" + file, 'r', encoding="utf-8") as f:
content = f.read().split("\n")
last_names[file] = content
class Player:
def __init__(self, team, nationality, birth_date, post):
self.id = str(uuid4())
self.nationality = nationality
self.birth_date = birth_date # 17 à 35 ans
self.current_club = team.id_team
self.post = post
self.first_name = ""
self.last_name = ""
if self.nationality == team.championship.country.id_nationality and randint(1, 20) <= 17:
self.first_name = choice(first_names[self.nationality])
self.last_name = choice(last_names[self.nationality])
else:
nn = list(first_names.keys())
nn.remove(team.championship.country.id_nationality)
nn = choice(nn)
self.first_name = choice(first_names[nn])
self.last_name = choice(last_names[nn])
def get_post(self):
return self.post
def get_id(self):
return self.id
def __hash__(self):
return hash(self.id)
def __str__(self):
return self.first_name + ' ' + self.last_name.upper() + ' ' + str(self.birth_date) + ' ' + self.post