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
Commits
347afb70
Commit
347afb70
authored
2 years ago
by
Lucas Von Mullen Brown
Browse files
Options
Downloads
Patches
Plain Diff
time.sleep changes
parent
ceb185d3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Group_game/game.py
+31
-0
31 additions, 0 deletions
Group_game/game.py
with
31 additions
and
0 deletions
Group_game/game.py
+
31
−
0
View file @
347afb70
...
...
@@ -13,6 +13,7 @@ global current_level
gas_starttime
=
""
def
list_of_items
(
items
):
time
.
sleep
(
0.1
)
new_list
=
""
for
number
in
range
(
len
(
items
)):
if
number
==
len
(
items
)
-
1
:
...
...
@@ -24,24 +25,30 @@ def list_of_items(items):
def
print_room_items
(
room
):
time
.
sleep
(
0.8
)
if
room
[
"
items
"
]:
print
(
"
There is
"
,
list_of_items
(
room
[
"
items
"
]),
"
here.
"
+
"
\n
"
)
def
print_inventory_items
(
items
):
time
.
sleep
(
0.1
)
if
items
:
print
(
"
You have
"
,
list_of_items
(
items
)
+
"
.
"
+
"
\n
"
)
def
print_room
(
room
):
time
.
sleep
(
0.5
)
# Display room name
print
()
print
(
room
[
"
name
"
].
upper
())
print
()
time
.
sleep
(
1.2
)
# Display room description
print
(
room
[
"
description
"
])
print
()
time
.
sleep
(
1.2
)
print_room_items
(
room
)
time
.
sleep
(
0.5
)
#
# COMPLETE ME!
...
...
@@ -49,15 +56,18 @@ def print_room(room):
def
exit_leads_to
(
exits
,
direction
):
time
.
sleep
(
0.1
)
return
locations
[
exits
[
direction
]][
"
name
"
]
def
print_exit
(
direction
,
leads_to
):
time
.
sleep
(
0.8
)
print
(
"
GO
"
+
direction
.
upper
()
+
"
to
"
+
leads_to
+
"
.
"
)
def
print_menu
(
exits
,
room_items
,
inv_items
):
global
current_level
time
.
sleep
(
0.5
)
print
(
"
You can:
"
)
# Iterate over available exits
for
direction
in
exits
:
...
...
@@ -65,48 +75,64 @@ def print_menu(exits, room_items, inv_items):
print_exit
(
direction
,
exit_leads_to
(
exits
,
direction
))
for
items
in
room_items
:
if
items
[
"
pick-up
"
]:
time
.
sleep
(
0.8
)
print
(
"
TAKE
"
,
items
[
"
id
"
],
"
to take
"
,
items
[
"
name
"
]
+
"
.
"
)
for
items
in
inv_items
:
time
.
sleep
(
0.8
)
print
(
"
DROP
"
,
items
[
"
id
"
],
"
to drop
"
,
items
[
"
name
"
]
+
"
.
"
)
for
items
in
inv_items
:
if
"
open
"
in
items
:
if
not
items
[
"
open
"
]:
time
.
sleep
(
0.8
)
print
(
"
OPEN
"
,
items
[
"
id
"
],
"
to open
"
,
items
[
"
name
"
]
+
"
.
"
)
if
not
location_boileroom
[
"
valve_open
"
]:
time
.
sleep
(
0.8
)
print
(
"
CHECK TIMER to check the time remaining
"
)
if
current_room
==
location_door
and
location_door
[
"
locked
"
]:
if
current_level
==
"
level 1
"
:
time
.
sleep
(
0.8
)
print
(
"
UNLOCK DOOR to attempt to unlock the escape door
"
)
else
:
time
.
sleep
(
0.8
)
print
(
"
GO UPSTAIRS to go back to level 1
"
)
if
item_note
in
inv_items
:
time
.
sleep
(
0.8
)
print
(
"
READ NOTE to read the hidden note
"
)
if
item_safe
in
room_items
:
if
not
item_safe
[
"
open
"
]:
time
.
sleep
(
0.8
)
print
(
"
OPEN SAFE to attempt to open the safe
"
)
else
:
"
You
'
ve already opened the safe
"
if
item_batteries
in
inventory
and
unpowered_torch
in
inventory
:
time
.
sleep
(
0.8
)
print
(
"
USE BATTERIES for TORCH to place the batteries in the torch
"
)
# if item_batteries in inventory and item_lock in inventory:
# print("USE BATTERIES for LOCK to place the batteries in the torch")
if
(
powered_torch
in
inv_items
)
or
(
unpowered_torch
in
inv_items
):
time
.
sleep
(
0.8
)
print
(
"
USE TORCH to use your torch
"
)
if
current_room
==
location_boileroom
and
location_boileroom
[
"
valve_open
"
]:
time
.
sleep
(
0.8
)
print
(
"
CLOSE valve to close the valve and stop the leakage
"
)
if
location_boileroom
[
"
valve_open
"
]:
time
.
sleep
(
0.8
)
print
(
"
CHECK GAS TIMER to see how long left before the room fills with gas
"
)
if
item_winebottle
in
inventory
:
time
.
sleep
(
0.8
)
print
(
'
DRINK WINE to have a glass of wine
'
)
time
.
sleep
(
0.8
)
print
(
"
What do you want to do?
"
)
def
is_valid_exit
(
exits
,
chosen_exit
):
time
.
sleep
(
0.1
)
return
chosen_exit
in
exits
def
execute_go
(
direction
):
time
.
sleep
(
0.1
)
global
current_room
if
is_valid_exit
(
current_room
[
"
exits
"
],
direction
):
new_room
=
move
(
current_room
[
"
exits
"
],
direction
)
...
...
@@ -117,6 +143,7 @@ def execute_go(direction):
def
execute_take
(
item_id
):
time
.
sleep
(
0.1
)
found
=
False
for
items
in
current_room
[
"
items
"
]:
if
item_id
==
items
[
"
id
"
]:
...
...
@@ -131,6 +158,7 @@ def execute_take(item_id):
def
execute_drop
(
item_id
):
time
.
sleep
(
0.1
)
found
=
False
for
items
in
inventory
:
if
items
[
"
id
"
]
==
item_id
:
...
...
@@ -143,6 +171,7 @@ def execute_drop(item_id):
def
time_taken
():
time
.
sleep
(
0.1
)
current_time
=
datetime
.
now
()
time_taken
=
(
current_time
-
start_time
).
total_seconds
()
minutes
=
time_taken
//
60
...
...
@@ -152,6 +181,7 @@ def time_taken():
def
unlock_door
():
time
.
sleep
(
0.2
)
global
current_room
global
start_time
minutes
=
time_taken
()[
0
]
...
...
@@ -181,6 +211,7 @@ def unlock_door():
def
check_timer
():
time
.
sleep
(
0.2
)
current_time
=
datetime
.
now
()
time_taken
=
current_time
-
start_time
time_left
=
1200
-
time_taken
.
total_seconds
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment