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
3d382d3d
Commit
3d382d3d
authored
2 years ago
by
Ahmed Yusuf
Browse files
Options
Downloads
Patches
Plain Diff
some more changes
parent
1d9a4e03
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
+46
-29
46 additions, 29 deletions
Group_game/game.py
Group_game/items.py
+18
-14
18 additions, 14 deletions
Group_game/items.py
Group_game/level_1.py
+42
-0
42 additions, 0 deletions
Group_game/level_1.py
Group_game/map.py
+3
-3
3 additions, 3 deletions
Group_game/map.py
with
109 additions
and
46 deletions
Group_game/game.py
+
46
−
29
View file @
3d382d3d
...
...
@@ -4,6 +4,7 @@ from player import *
from
gameparser
import
*
from
datetime
import
datetime
from
items
import
*
from
level_1
import
*
start_time
=
""
...
...
@@ -58,21 +59,25 @@ def print_menu(exits, room_items, inv_items):
# Print the exit name and where it leads to
print_exit
(
direction
,
exit_leads_to
(
exits
,
direction
))
for
items
in
room_items
:
print
(
"
TAKE
"
,
items
[
"
id
"
],
"
to take
"
,
items
[
"
name
"
]
+
"
.
"
)
if
items
[
"
pick-up
"
]:
print
(
"
TAKE
"
,
items
[
"
id
"
],
"
to take
"
,
items
[
"
name
"
]
+
"
.
"
)
for
items
in
inv_items
:
print
(
"
DROP
"
,
items
[
"
id
"
],
"
to drop
"
,
items
[
"
name
"
]
+
"
.
"
)
for
items
in
inv_items
:
if
"
open
"
in
items
:
print
(
"
OPEN
"
,
items
[
"
id
"
],
"
to open
"
,
items
[
"
name
"
]
+
"
.
"
)
if
not
items
[
"
open
"
]:
print
(
"
OPEN
"
,
items
[
"
id
"
],
"
to open
"
,
items
[
"
name
"
]
+
"
.
"
)
print
(
"
CHECK TIMER to check the time remaining
"
)
if
current_room
==
current_level
[
"
door
"
]:
print
(
"
UNLOCK DOOR to attempt to unlock the escape door
"
)
#
# COMPLETE ME!
#
if
item_note
in
inv_items
:
print
(
"
READ NOTE to read the hidden note
"
)
if
item_safe
in
room_items
:
if
not
item_safe
[
"
open
"
]:
print
(
"
OPEN SAFE to attempt to open the safe
"
)
else
:
"
You
'
ve already opened the safe
"
print
(
"
What do you want to do?
"
)
...
...
@@ -99,7 +104,6 @@ def execute_take(item_id):
found
=
True
if
not
found
:
print
(
current_room
[
"
items
"
])
print
(
"
You cannot take that.
"
)
...
...
@@ -115,18 +119,17 @@ def execute_drop(item_id):
print
(
"
You cannot drop that.
"
)
def
execute_open
(
item_id
):
found
=
False
x
=
""
for
items
in
inventory
:
if
items
[
"
id
"
]
==
item_id
:
print
(
"
You opened the
"
,
item_id
,
"
and found
"
,
items
[
"
open
"
][
"
name
"
])
x
=
items
[
"
open
"
]
found
=
True
if
found
:
inventory
.
append
(
x
)
def
unlock_door
():
if
current_room
[
"
name
"
]
==
"
Escape door
"
:
if
item_key
in
inventory
:
print
(
"
WELL DONE! You
'
ve escaped
"
,
current_level
)
else
:
print
(
"
You need a key to open the door
"
)
else
:
print
(
"
You cannot open that.
"
)
print
(
"
There is no door to open
"
)
def
check_timer
():
...
...
@@ -160,25 +163,39 @@ def execute_command(command):
else
:
print
(
"
Drop what?
"
)
#
elif command[0] == "read":
#
if
len(
command
) > 1
:
#
execute_read(command[1]
)
#
else:
#
print("read what?")
elif
command
[
0
]
==
"
read
"
:
if
command
[
1
]
==
"
note
"
:
read_note
(
)
else
:
print
(
"
read what?
"
)
elif
command
[
0
]
==
"
open
"
:
if
len
(
command
)
>
1
:
execute_open
(
command
[
1
])
if
command
[
1
]
==
"
diary
"
:
open_diary
()
elif
command
[
1
]
==
"
safe
"
:
open_safe
()
else
:
print
(
"
check
what?
"
)
print
(
"
open
what?
"
)
elif
command
[
0
]
==
"
check
"
:
if
command
[
1
]
==
"
timer
"
:
check_timer
()
else
:
print
(
"
Check what?
"
)
else
:
print
(
"
This makes no sense.
"
)
elif
command
[
0
]
==
"
unlock
"
:
if
command
[
1
]
==
"
door
"
:
unlock_door
()
else
:
print
(
"
unlock what?
"
)
# elif command[0] == "use":
# if command[1] == "battery":
# use_battery()
# if command[1] == "battery":
# use_torch()
# else:
# print("use what?")
# else:
# print("This makes no sense.")
def
menu
(
exits
,
room_items
,
inv_items
):
...
...
This diff is collapsed.
Click to expand it.
Group_game/items.py
+
18
−
14
View file @
3d382d3d
item_battery
=
{
"
id
"
:
"
battery
"
,
"
name
"
:
"
a pair of batteries
"
,
"
description
"
:
"
(no description)
"
,
"
pick-up
"
:
True
}
item_safe
=
{
"
id
"
:
"
safe
"
,
"
name
"
:
"
a secure safe
"
,
"
description
"
:
"
(no description)
"
}
item_battery
=
{
"
id
"
:
"
battery
"
,
"
name
"
:
"
a pair of batteries
"
,
"
description
"
:
"
(no description)
"
,
"
pick-up
"
:
False
,
"
open
"
:
False
"
description
"
:
"
(no description)
"
}
item_note
=
{
"
id
"
:
"
note
"
,
"
name
"
:
"
a hidden note
"
,
"
description
"
:
"
(no description)
"
# "read": read_note()
"
description
"
:
"
(no description)
"
,
"
pick-up
"
:
True
}
item_key
=
{
...
...
@@ -30,7 +31,8 @@ item_key = {
"
name
"
:
"
a key
"
,
"
description
"
:
"
(no description).
"
"
description
"
:
"
(no description).
"
,
"
pick-up
"
:
True
}
item_torch
=
{
...
...
@@ -38,7 +40,8 @@ item_torch = {
"
name
"
:
"
a torch
"
,
"
description
"
:
"
(no description)
"
"
description
"
:
"
(no description)
"
,
"
pick-up
"
:
True
}
item_diary
=
{
...
...
@@ -47,5 +50,6 @@ item_diary = {
"
name
"
:
"
a personal diary
"
,
"
description
"
:
"
(no description)
"
,
"
open
"
:
item_note
"
pick-up
"
:
True
,
"
open
"
:
False
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Group_game/level_1.py
0 → 100644
+
42
−
0
View file @
3d382d3d
from
items
import
*
from
player
import
*
def
open_diary
():
if
item_diary
in
inventory
:
print
(
"
You opened the diary and found a hidden note.
"
)
inventory
.
append
(
item_note
)
item_diary
.
update
({
"
open
"
:
True
})
else
:
print
(
"
You cannot open that.
"
)
def
open_safe
():
global
safe_opened
print
(
"
To open this safe you need a passcode
"
)
print
(
"
please enter the passcode
"
)
passcode
=
input
()
if
passcode
==
"
042
"
:
print
(
"
THE PASSCODE WAS CORRECT!
"
)
print
(
"
inside the safe you found a pair of batteries
"
)
inventory
.
append
(
item_battery
)
item_safe
.
update
({
"
open
"
:
True
})
def
use_battery
():
if
item_battery
in
inventory
:
if
item_torch
in
inventory
:
inventory
.
remove
(
item_battery
)
inventory
.
remove
(
item_torch
)
def
read_note
():
if
item_note
in
inventory
:
print
(
"
You read the note and notice a strange puzzle
"
)
print
(
"
682 >> one digit is correct & well placed
"
)
print
(
"
614 >> one digit is correct but wrong placed
"
)
print
(
"
206 >> two numbers are correct but wrong placed
"
)
print
(
"
738 >> nothing is correct
"
)
print
(
"
870 >> one number is correct but wrong placed
"
)
else
:
print
(
"
There is no note to read
"
)
This diff is collapsed.
Click to expand it.
Group_game/map.py
+
3
−
3
View file @
3d382d3d
...
...
@@ -7,7 +7,7 @@ location_centre = {
"
exits
"
:
{
"
south
"
:
"
fireplace
"
,
"
west
"
:
"
bookshelf
"
,
"
north
"
:
"
door
"
,
"
north-east
"
:
"
desk
"
,
"
south-east
"
:
"
dark corner
"
},
"
items
"
:
[
item_torch
]
"
items
"
:
[]
}
location_Fireplace
=
{
...
...
@@ -17,7 +17,7 @@ location_Fireplace = {
"
exits
"
:
{
"
north
"
:
"
centre
"
,
"
east
"
:
"
Dark corner
"
},
"
items
"
:
[
item_
safe
]
"
items
"
:
[
item_
torch
]
}
location_bookshelf
=
{
...
...
@@ -37,7 +37,7 @@ Location_desk = {
"
exits
"
:
{
"
west
"
:
"
door
"
,
"
south- west
"
:
"
centre
"
,
"
west
"
:
"
dark corner
"
},
"
items
"
:
[
item_
battery
]
"
items
"
:
[
item_
safe
]
}
location_dark_corner
=
{
...
...
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