Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Babyfut
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PR-Baby-A18
Babyfut
Commits
a09cf6ff
Commit
a09cf6ff
authored
Oct 26, 2018
by
Antoine Lima
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added league authentification
parent
1c83eca5
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
410 additions
and
8 deletions
+410
-8
compile_resources.sh
compile_resources.sh
+1
-0
modules/auth.py
modules/auth.py
+7
-4
modules/authleague.py
modules/authleague.py
+42
-4
modules/authquick.py
modules/authquick.py
+4
-0
player.py
player.py
+8
-0
ui/authleague.ui
ui/authleague.ui
+348
-0
No files found.
compile_resources.sh
View file @
a09cf6ff
...
...
@@ -7,6 +7,7 @@ pyuic5 --import-from=ui ui/game.ui -o ui/game_ui.py
pyuic5
--import-from
=
ui ui/endgame.ui
-o
ui/endgame_ui.py
pyuic5
--import-from
=
ui ui/options.ui
-o
ui/options_ui.py
pyuic5
--import-from
=
ui ui/authquick.ui
-o
ui/authquick_ui.py
pyuic5
--import-from
=
ui ui/authleague.ui
-o
ui/authleague_ui.py
pyuic5
--import-from
=
ui ui/leaderboard.ui
-o
ui/leaderboard_ui.py
# Custom widgets
...
...
modules/auth.py
View file @
a09cf6ff
...
...
@@ -17,18 +17,21 @@ from player import Side, Player, PlayerGuest
class
AuthModuleBase
(
Module
):
def
__init__
(
self
,
parent
,
widget
):
super
().
__init__
(
parent
,
widget
)
self
.
players
=
{
Side
.
Left
:
list
(),
Side
.
Right
:
list
()}
self
.
createPlayerList
()
self
.
numPlayers
=
0
def
load
(
self
):
pass
def
unload
(
self
):
self
.
players
=
{
Side
.
Left
:
list
(),
Side
.
Right
:
list
()}
self
.
createPlayerList
()
self
.
numPlayers
=
0
def
other
(
self
,
**
kwargs
):
for
key
,
val
in
kwargs
.
items
():
if
key
==
'rfid'
and
'source'
in
kwargs
:
side
=
kwargs
[
'source'
]
self
.
numPlayers
+=
1
self
.
addPlayer
(
side
,
Player
.
fromRFID
(
val
))
def
keyPressEvent
(
self
,
e
):
...
...
@@ -40,10 +43,10 @@ class AuthModuleBase(Module):
elif
e
.
key
()
==
Qt
.
Key_Left
or
e
.
key
()
==
Qt
.
Key_Right
:
side
=
Side
.
Left
if
e
.
key
()
==
Qt
.
Key_Left
else
Side
.
Right
rfid
=
-
2
*
(
side
.
value
+
1
)
-
(
self
.
players
[
side
][
0
]
!=
PlayerGuest
)
rfid
=
-
(
2
+
self
.
numPlayers
%
5
)
self
.
send
(
type
(
self
),
rfid
=
rfid
,
source
=
side
)
def
addPlayer
(
self
,
side
,
player
):
def
createPlayerList
(
self
):
logging
.
warning
(
'Base function meant to be reimplemented'
)
def
handleCancel
(
self
):
...
...
modules/authleague.py
View file @
a09cf6ff
...
...
@@ -8,17 +8,55 @@ Created on Wed Apr 18 18:34:40 2018
import
logging
from
PyQt5.QtWidgets
import
QAbstractItemView
from
module
import
Module
from
ui.authquick_ui
import
Ui_Form
as
AuthQuickWidget
from
modules.auth
import
AuthModuleBase
from
ui.authleague_ui
import
Ui_Form
as
AuthLeagueWidget
class
AuthLeagueModule
(
Module
):
from
player
import
Side
,
PlayerEmpty
class
AuthLeagueModule
(
AuthModuleBase
):
def
__init__
(
self
,
parent
):
super
().
__init__
(
parent
,
Auth
Quick
Widget
())
super
().
__init__
(
parent
,
Auth
League
Widget
())
def
load
(
self
):
logging
.
debug
(
'Loading AuthLeagueModule'
)
super
().
load
()
self
.
addPlayer
(
Side
.
Left
,
PlayerEmpty
)
def
unload
(
self
):
logging
.
debug
(
'Loading AuthLeagueModule'
)
super
().
load
()
super
().
unload
()
self
.
ui
.
playersList
.
clear
()
def
createPlayerList
(
self
):
'''
Duplicates the player list to be the same on both sides.
That way, adding a player on the left or on the right have the exact same effect,
and thus the AuthModuleBase code can remain generic.
'''
l
=
list
()
self
.
players
=
{
Side
.
Left
:
l
,
Side
.
Right
:
l
}
def
addPlayer
(
self
,
side
,
player
):
# Add the player if not already in the list
if
all
([
p
.
id
!=
player
.
id
for
p
in
self
.
players
[
side
]]):
if
player
!=
PlayerEmpty
:
self
.
players
[
side
].
append
(
player
)
# Update the left side description
player
.
displayImg
(
self
.
ui
.
img
)
self
.
ui
.
lblName
.
setText
(
player
.
name
)
self
.
ui
.
lblStat1
.
setText
(
'{} Victories'
.
format
(
player
.
stats
.
victories
))
self
.
ui
.
lblStat2
.
setText
(
'{} Games Played'
.
format
(
player
.
stats
.
games_played
))
self
.
ui
.
lblStat3
.
setText
(
'{} Goals Scored'
.
format
(
player
.
stats
.
goals_scored
))
if
player
!=
PlayerEmpty
:
# Update the right side list, making sure that the added player is showed
self
.
ui
.
playersList
.
addItem
(
'{}. {}'
.
format
(
len
(
self
.
players
[
side
]),
player
.
name
))
widgetItem
=
self
.
ui
.
playersList
.
item
(
self
.
ui
.
playersList
.
count
()
-
1
)
self
.
ui
.
playersList
.
scrollToItem
(
widgetItem
,
QAbstractItemView
.
PositionAtBottom
)
def
handleDone
(
self
):
super
().
handleDone
()
modules/authquick.py
View file @
a09cf6ff
...
...
@@ -40,7 +40,11 @@ class AuthQuickModule(AuthModuleBase):
super
().
unload
()
#self.updateSides()
def
createPlayerList
(
self
):
self
.
players
=
{
Side
.
Left
:
list
(),
Side
.
Right
:
list
()}
def
addPlayer
(
self
,
side
,
player
):
# If there is a placeholder Guest, clear it from the list, we don't need it anymore
if
len
(
self
.
players
[
side
])
>
0
and
self
.
players
[
side
][
0
]
==
PlayerGuest
:
self
.
players
[
side
].
clear
()
...
...
player.py
View file @
a09cf6ff
...
...
@@ -51,6 +51,13 @@ class Player():
player
=
Player
(
id
,
'Enzo'
,
'Arobaz'
)
player
.
stats
.
goals_scored
=
1
elif
id
==-
10
:
player
=
Player
(
id
,
'Name'
,
''
)
player
.
stats
.
victories
=
''
player
.
stats
.
time_played
=
''
player
.
stats
.
games_played
=
''
player
.
stats
.
goals_scored
=
''
else
:
player
=
Player
(
id
,
fname
,
lname
,
pic_url
)
...
...
@@ -88,3 +95,4 @@ class Stat():
self
.
goals_scored
=
0
PlayerGuest
=
Player
.
fromRFID
(
-
1
)
PlayerEmpty
=
Player
.
fromRFID
(
-
10
)
ui/authleague.ui
0 → 100644
View file @
a09cf6ff
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment