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
b291a3fc
Commit
b291a3fc
authored
2 years ago
by
Ahmed Yusuf
Browse files
Options
Downloads
Patches
Plain Diff
boiler room gas leakage works
parent
829029d5
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Group_game/game.py
+33
-3
33 additions, 3 deletions
Group_game/game.py
Group_game/items.py
+8
-0
8 additions, 0 deletions
Group_game/items.py
Group_game/level_2.py
+20
-3
20 additions, 3 deletions
Group_game/level_2.py
Group_game/map.py
+4
-2
4 additions, 2 deletions
Group_game/map.py
with
65 additions
and
8 deletions
Group_game/game.py
+
33
−
3
View file @
b291a3fc
...
@@ -10,6 +10,7 @@ from level_2 import *
...
@@ -10,6 +10,7 @@ from level_2 import *
start_time
=
""
start_time
=
""
global
current_room
global
current_room
global
current_level
global
current_level
gas_starttime
=
""
def
list_of_items
(
items
):
def
list_of_items
(
items
):
new_list
=
""
new_list
=
""
...
@@ -72,7 +73,8 @@ def print_menu(exits, room_items, inv_items):
...
@@ -72,7 +73,8 @@ def print_menu(exits, room_items, inv_items):
if
"
open
"
in
items
:
if
"
open
"
in
items
:
if
not
items
[
"
open
"
]:
if
not
items
[
"
open
"
]:
print
(
"
OPEN
"
,
items
[
"
id
"
],
"
to open
"
,
items
[
"
name
"
]
+
"
.
"
)
print
(
"
OPEN
"
,
items
[
"
id
"
],
"
to open
"
,
items
[
"
name
"
]
+
"
.
"
)
print
(
"
CHECK TIMER to check the time remaining
"
)
if
not
location_boileroom
[
"
valve_open
"
]:
print
(
"
CHECK TIMER to check the time remaining
"
)
if
current_room
==
location_door
and
location_door
[
"
locked
"
]:
if
current_room
==
location_door
and
location_door
[
"
locked
"
]:
if
current_level
==
"
level 1
"
:
if
current_level
==
"
level 1
"
:
print
(
"
UNLOCK DOOR to attempt to unlock the escape door
"
)
print
(
"
UNLOCK DOOR to attempt to unlock the escape door
"
)
...
@@ -91,6 +93,10 @@ def print_menu(exits, room_items, inv_items):
...
@@ -91,6 +93,10 @@ def print_menu(exits, room_items, inv_items):
# print("USE BATTERIES for LOCK to place the batteries in the torch")
# print("USE BATTERIES for LOCK to place the batteries in the torch")
if
(
powered_torch
in
inv_items
)
or
(
unpowered_torch
in
inv_items
):
if
(
powered_torch
in
inv_items
)
or
(
unpowered_torch
in
inv_items
):
print
(
"
USE TORCH to use your torch
"
)
print
(
"
USE TORCH to use your torch
"
)
if
current_room
==
location_boileroom
and
location_boileroom
[
"
valve_open
"
]:
print
(
"
CLOSE valve to close the valve and stop the leakage
"
)
if
location_boileroom
[
"
valve_open
"
]:
print
(
"
CHECK GAS TIMER to see how long left before the room fills with gas
"
)
print
(
"
What do you want to do?
"
)
print
(
"
What do you want to do?
"
)
...
@@ -218,8 +224,12 @@ def execute_command(command):
...
@@ -218,8 +224,12 @@ def execute_command(command):
print
(
"
open what?
"
)
print
(
"
open what?
"
)
elif
command
[
0
]
==
"
check
"
:
elif
command
[
0
]
==
"
check
"
:
if
command
[
1
]
==
"
timer
"
:
if
len
(
command
)
>
1
:
check_timer
()
if
command
[
1
]
==
"
timer
"
:
check_timer
()
elif
command
[
1
]
==
"
gas
"
:
if
location_boileroom
[
"
valve_open
"
]:
gas_timer
(
gas_starttime
)
else
:
else
:
print
(
"
Check what?
"
)
print
(
"
Check what?
"
)
elif
command
[
0
]
==
"
unlock
"
:
elif
command
[
0
]
==
"
unlock
"
:
...
@@ -227,6 +237,11 @@ def execute_command(command):
...
@@ -227,6 +237,11 @@ def execute_command(command):
unlock_door
()
unlock_door
()
else
:
else
:
print
(
"
unlock what?
"
)
print
(
"
unlock what?
"
)
elif
command
[
0
]
==
"
close
"
:
if
command
[
1
]
==
"
valve
"
:
close_valve
()
else
:
print
(
"
unlock what?
"
)
elif
command
[
0
]
==
"
use
"
:
elif
command
[
0
]
==
"
use
"
:
if
len
(
command
)
>
1
:
if
len
(
command
)
>
1
:
if
command
[
1
]
==
"
batteries
"
:
if
command
[
1
]
==
"
batteries
"
:
...
@@ -268,6 +283,7 @@ def move(exits, direction):
...
@@ -268,6 +283,7 @@ def move(exits, direction):
def
main
():
def
main
():
global
current_level
global
current_level
current_level
=
"
level 1
"
current_level
=
"
level 1
"
global
gas_starttime
global
start_time
global
start_time
start_time
=
datetime
.
now
()
start_time
=
datetime
.
now
()
# Main game loop
# Main game loop
...
@@ -278,7 +294,21 @@ def main():
...
@@ -278,7 +294,21 @@ def main():
if
time_left
<
0
:
if
time_left
<
0
:
print
(
"
Oh no! You ran out of time!
"
)
print
(
"
Oh no! You ran out of time!
"
)
break
break
if
location_boileroom
[
"
valve_open
"
]:
gastime
=
current_time
-
gas_starttime
gastime_left
=
120
-
gastime
.
total_seconds
()
if
gastime_left
<
0
:
print
(
"
OH NO! the floor was filled with gas and you died
"
)
break
# Display game status (room description, inventory etc.)
# Display game status (room description, inventory etc.)
if
current_room
==
location_boileroom
:
if
not
location_boileroom
[
"
entered
"
]:
location_boileroom
[
"
valve_open
"
]
=
True
print
(
"
(gas warning message 2 min)
"
)
time
.
sleep
(
5
)
gas_starttime
=
datetime
.
now
()
location_boileroom
[
"
entered
"
]
=
True
print_room
(
current_room
)
print_room
(
current_room
)
print_inventory_items
(
inventory
)
print_inventory_items
(
inventory
)
...
...
This diff is collapsed.
Click to expand it.
Group_game/items.py
+
8
−
0
View file @
b291a3fc
...
@@ -62,3 +62,11 @@ item_diary = {
...
@@ -62,3 +62,11 @@ item_diary = {
"
pick-up
"
:
True
,
"
pick-up
"
:
True
,
"
open
"
:
False
"
open
"
:
False
}
}
item_screwdriver
=
{
"
id
"
:
"
screwdriver
"
,
"
name
"
:
"
a screwdriver
"
,
"
description
"
:
"
()
"
,
"
pick-up
"
:
True
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Group_game/level_2.py
+
20
−
3
View file @
b291a3fc
...
@@ -3,6 +3,7 @@ from operator import truediv
...
@@ -3,6 +3,7 @@ from operator import truediv
from
items
import
*
from
items
import
*
from
player
import
*
from
player
import
*
from
map
import
*
from
map
import
*
from
datetime
import
datetime
from
gameparser
import
*
from
gameparser
import
*
...
@@ -23,15 +24,31 @@ def drink_wine(time_taken):
...
@@ -23,15 +24,31 @@ def drink_wine(time_taken):
False
False
def
close_valve
():
def
close_valve
():
pass
if
item_screwdriver
in
inventory
:
if
location_boileroom
[
"
valve_open
"
]:
location_boileroom
[
"
valve_open
"
]
=
False
print
(
"
Well done! You stopped the leakage
"
)
else
:
print
(
"
valve is closed
"
)
else
:
print
(
"
You need a screwdriver to close the valve
"
)
def
open_trapdoor
():
def
open_trapdoor
():
pass
pass
def
hangman
():
def
play_
hangman
():
pass
pass
def
open_closet
():
def
open_closet
():
pass
pass
def
use_battery_lock
():
def
use_battery_lock
():
pass
pass
\ No newline at end of file
def
gas_timer
(
timer
):
current_time
=
datetime
.
now
()
time_taken
=
current_time
-
timer
time_left
=
120
-
time_taken
.
total_seconds
()
minutes
=
time_left
//
60
seconds
=
time_left
%
60
if
time_left
>
0
:
print
(
"
You have
"
,
round
(
minutes
),
"
minutes and
"
,
round
(
seconds
),
"
seconds before the room fills with gas
"
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Group_game/map.py
+
4
−
2
View file @
b291a3fc
...
@@ -10,7 +10,7 @@ Good luck you have 20 minutes!""",
...
@@ -10,7 +10,7 @@ Good luck you have 20 minutes!""",
"
exits
"
:
{
"
south
"
:
"
fireplace
"
,
"
west
"
:
"
bookshelf
"
,
"
north
"
:
"
door
"
,
"
north-east
"
:
"
office desk
"
,
"
south-east
"
:
"
dark corner
"
},
"
exits
"
:
{
"
south
"
:
"
fireplace
"
,
"
west
"
:
"
bookshelf
"
,
"
north
"
:
"
door
"
,
"
north-east
"
:
"
office desk
"
,
"
south-east
"
:
"
dark corner
"
},
"
items
"
:
[]
"
items
"
:
[
item_screwdriver
]
}
}
location_Fireplace
=
{
location_Fireplace
=
{
...
@@ -97,7 +97,9 @@ location_boileroom = {
...
@@ -97,7 +97,9 @@ location_boileroom = {
"
exits
"
:
{
"
north
"
:
"
entrance
"
},
"
exits
"
:
{
"
north
"
:
"
entrance
"
},
"
items
"
:
[]
"
items
"
:
[],
"
valve_open
"
:
False
,
"
entered
"
:
False
}
}
desk
=
{
desk
=
{
"
name
"
:
"
desk
"
,
"
name
"
:
"
desk
"
,
...
...
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