auth.py 1.15 KB
Newer Older
Antoine Lima's avatar
Antoine Lima committed
1 2 3 4 5 6 7 8 9 10
#!/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

11
from PyQt5.QtCore import QTime, Qt
Antoine Lima's avatar
Antoine Lima committed
12 13

from module import Module
14
from player import Side
Antoine Lima's avatar
Antoine Lima committed
15 16 17 18 19 20 21 22 23
import modules
from ui.auth2p_ui import Ui_Form as Auth2pWidget

class AuthModule(Module):
	def __init__(self, parent):
		super().__init__(parent, Auth2pWidget())

	def load(self):
		logging.debug('Loading AuthModule')
24
		self.players = {Side.Left: list(), Side.Right: list()}
Antoine Lima's avatar
Antoine Lima committed
25 26 27

	def unload(self):
		logging.debug('Unloading AuthModule')
28
		del self.players
Antoine Lima's avatar
Antoine Lima committed
29 30 31

	def other(self, **kwargs):
		logging.debug('Other AuthModule')
32 33 34 35 36
		
		for key, val in kwargs.items():
			if key=='ardl_rfid' or key=='ardr_rfid':
				side = Side.Left if key.startswith('ardl') else Side.Right
				self.players.append(Player(val))
Antoine Lima's avatar
Antoine Lima committed
37

38 39
	def keyPressEvent(self, e):
		if e.key() == Qt.Key_Escape:
40 41 42
			self.handleCancel()
		elif e.key() == Qt.Key_Return:
			self.handleDone()
43

44
	def handleCancel(self):
Antoine Lima's avatar
Antoine Lima committed
45 46
		self.switchModule(modules.MenuModule)

47 48
	def handleDone(self):
		self.send(modules.GameModule, players=self.players)
Antoine Lima's avatar
Antoine Lima committed
49
		self.switchModule(modules.GameModule)