Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Group Project
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ahmed Yusuf
Group Project
Compare revisions
81c7f9dfb2f32b6fd82beb587ae6db78ca319a5c to cec26e5f3b8c6ed2b62aebbe2302b4e1ec506a52
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
c22027697/group-project
Select target project
No results found
cec26e5f3b8c6ed2b62aebbe2302b4e1ec506a52
Select Git revision
Swap
Target
c22027697/group-project
Select target project
c22027697/group-project
1 result
81c7f9dfb2f32b6fd82beb587ae6db78ca319a5c
Select Git revision
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
Leaderboard (not integrated into game.py yet)
· 5fe9368c
Adriel Nuqui
authored
2 years ago
5fe9368c
Leaderboard
· cec26e5f
Adriel Nuqui
authored
2 years ago
cec26e5f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Group_game/game.py
+2
-0
2 additions, 0 deletions
Group_game/game.py
Group_game/leaderboard.py
+65
-0
65 additions, 0 deletions
Group_game/leaderboard.py
Times.csv
+1
-0
1 addition, 0 deletions
Times.csv
with
68 additions
and
0 deletions
Group_game/game.py
View file @
cec26e5f
...
...
@@ -8,6 +8,8 @@ from items import *
from
level_1
import
*
import
time
from
level_2
import
*
from
leaderboard
import
*
start_time
=
""
global
current_room
global
current_level
...
...
This diff is collapsed.
Click to expand it.
Group_game/leaderboard.py
0 → 100644
View file @
cec26e5f
import
csv
,
datetime
from
email.utils
import
format_datetime
from
datetime
import
datetime
from
csv
import
reader
def
view_leaderboard
(
filename
):
print
(
"
________Leaderboard________
\n
"
)
with
open
(
str
(
filename
))
as
csv_file
:
csv_reader
=
csv
.
reader
(
csv_file
,
delimiter
=
'
,
'
)
line_count
=
0
#csv reader becomes a 2d list with contents of the Times.csv file
for
row
in
csv_reader
:
if
line_count
==
0
:
pass
line_count
+=
1
else
:
time
=
row
[
2
]
#00:00:00 format
minutes
=
time
//
60
seconds
=
time
%
60
time
=
[
round
(
minutes
),
round
(
seconds
)]
name
=
row
[
1
]
if
minutes
[
0
]
==
'
0
'
:
minutes
=
minutes
[
1
]
print
(
f
'
{
row
[
1
]
}
escaped in
{
time
[
0
]
}
minutes and
{
time
[
1
]
}
seconds!
'
)
line_count
+=
1
def
append_leaderboard
(
seconds_used
,
filename
):
#time_used = 20 minutes - time remaining
minutes
=
seconds_used
//
60
seconds
=
seconds_used
%
60
time
=
[
round
(
minutes
),
round
(
seconds
)]
print
(
"
Congrats, enter your name on the leaderboard!
"
)
name
=
input
(
"
What
'
s your name? :
"
)
print
(
'
Well done!
'
+
name
)
print
(
f
'
You escaped in
{
time
[
0
]
}
minutes and
{
time
[
1
]
}
seconds
'
)
file
=
open
(
str
(
filename
),
'
r
'
)
csv_reader
=
reader
(
file
)
list_of_rows
=
list
(
csv_reader
)
lastrow
=
list_of_rows
[
-
1
]
old_index
=
lastrow
[
0
]
if
old_index
==
'
index
'
:
old_index
=
0
newindex
=
int
(
old_index
)
+
1
file
.
close
()
file
=
open
(
str
(
filename
),
'
w
'
)
for
row
in
list_of_rows
:
newRecord
=
str
(
row
[
0
])
+
"
,
"
+
str
(
row
[
1
])
+
"
,
"
+
str
(
row
[
2
])
+
"
\n
"
file
.
write
(
newRecord
)
print
(
newRecord
)
lastRecord
=
str
(
newindex
)
+
"
,
"
+
str
(
name
)
+
"
,
"
+
str
(
seconds_used
)
+
"
\n
"
file
.
write
(
str
(
lastRecord
))
#Writes data into the file
file
.
close
()
This diff is collapsed.
Click to expand it.
Times.csv
0 → 100644
View file @
cec26e5f
index,name,seconds
\ No newline at end of file
This diff is collapsed.
Click to expand it.