player.py 1.07 KB
Newer Older
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
54
55
56
57
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 18 18:34:40 2018

@author: Antoine Lima, Leo Reynaert, Domitille Jehenne
"""

import logging
from enum import Enum

class Side(Enum):
	Undef = 0
	Left  = 1
	Right = 2

class Player():
	def __init__(self, id):
		fname, lname, pic_url = '','','' # Replace with DB calls
		self.__init__(id, fname, lname, pic_url)

	def __init__(self, id, fname, lname, pic_path):
		self.id = id
		self.fname = fname
		self.lname = lname
		self.pic_path = pic_path
		self.stats = Stat(id)
	
	def save(self):
		'''
		Update or create the player in database
		'''
		# TODO
		pass
	
	@property
	def name(self):
		return self.lname.upper() + self.fname
	
	@property
	def pic(self):
		return QPixmap(self.pic_path)

class Stat():
	def __init__(self, player_id):
		self.victories    = 0
		self.time_played  = 0
		self.games_played = 0
		self.goals_scored = 0
		
		if player_id >= 0:
			self.victories    = 0
			self.time_played  = 0
			self.games_played = 0
			self.goals_scored = 0

PlayerGuest = Player(-1, 'Guest', '', ':ui/img/placeholder_head.jpg')