Skip to content

Commit 47757f1

Browse files
committed
This is the design of the infrastructure of medium level of the game - Push_button and Cloth are assumed simply as key and object, respectively.
1 parent 5ed900b commit 47757f1

File tree

1 file changed

+235
-2
lines changed

1 file changed

+235
-2
lines changed

textworld/challenges/spaceship/maker.py

Lines changed: 235 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
PATH = r"/home/v-hapurm/Documents/Haki's Git/TextWorld/textworld/challenges/spaceship/textworld_data"
99

1010

11-
def spaceship_maker():
11+
def spaceship_maker_level_easy():
1212
# GameMaker object for handcrafting text-based games.
1313
kb = KnowledgeBase.load(target_dir=PATH)
1414
gm = GameMaker(kb=kb, theme='Spaceship')
@@ -84,5 +84,238 @@ def spaceship_maker():
8484
gm.quests.append(quest)
8585

8686

87+
def spaceship_maker_level_medium():
88+
# GameMaker object for handcrafting text-based games.
89+
kb = KnowledgeBase.load(target_dir=PATH)
90+
gm = GameMaker(kb=kb, theme='Spaceship')
91+
92+
# ===== Sleep Station Design =======================================================================================
93+
sleep_station = gm.new_room("Sleep Station")
94+
sleep_station.desc = "This is a typical bedroom in spaceship; here, it is called sleep station. It is small " \
95+
"but comfortable to take a good rest after a day full of missions. However, today your " \
96+
"mission will start from here. Wait to be notified by a message. So, you should find " \
97+
"that message first." \
98+
" " \
99+
"BTW, don't forget that when the Hatch door is open, you should already have worn your " \
100+
"specially-designed outfit to be able to enter and stay at Hatch area; otherwise you'll die!" \
101+
" Yes! Living in space is tough." # Text to display when issuing command "examine note".
102+
103+
sleep_bag = gm.new(type='c', name="sleeping bag")
104+
sleep_bag.desc = "cool! You can sleep in a comfy bag."
105+
sleep_station.add(sleep_bag) # Sleeping bag is fixed in place in the Sleep Station.
106+
gm.add_fact("open", sleep_bag)
107+
108+
surf_1 = gm.new(type='s', name='vertical desk') # surf_1 is a table (supporter) in the Sleep Station.
109+
surf_1.desc = "This is not a regular table. The surface is installed vertically and your objects are attached " \
110+
"or hooked to it, why? Come on! we are in space, there is no gravity here."
111+
sleep_station.add(surf_1) # The card box contains nothing at this game
112+
113+
laptop = gm.new(type='o', name="laptop")
114+
laptop.desc = "This is your personal laptop which is attached to the surface of the table. " \
115+
"You can do regular things with this, like check your emails, watch YouTube, Skype with family,etc." \
116+
"Since you are here, we recommend you to check your emails. New missions are posted through emails. "
117+
surf_1.add(laptop)
118+
119+
# ===== US LAB Design ==============================================================================================
120+
us_lab = gm.new_room("US LAB")
121+
us_lab.desc = "This is where Americans do their research on Space. In addition to all computers and lab gadgets, " \
122+
"you can find a couple of objects here which are useful during our game. Let's explore the room."
123+
124+
box_a = gm.new(type='c', name="box A")
125+
box_a.desc = "This a regular box, keeps the electronic key to open door C. But it is locked. " \
126+
"The lock looks like a keypad, means that the key is in fact just a code! So, ... let's " \
127+
"search around to find its key."
128+
us_lab.add(box_a)
129+
gm.add_fact("locked", box_a)
130+
131+
key_1 = gm.new(type='k', name="electronic key 1")
132+
key_1.desc = "This key is a card key which opens door C."
133+
box_a.add(key_1)
134+
135+
corridor_1 = gm.connect(sleep_station.south, us_lab.north)
136+
door_a = gm.new_door(corridor_1, name="door A")
137+
gm.add_fact("closed", door_a)
138+
139+
# ===== European Module Design =====================================================================================
140+
european_module = gm.new_room("European Module")
141+
european_module.desc = "This room belongs to European scientists. Isn't it cool? what do they research? well, " \
142+
"we can explore it later... For now, there is a key code here. This code opens the box " \
143+
"in the next room and consequently takes you to the next stage. So, explore the table to " \
144+
"find the key."
145+
146+
surf_2 = gm.new(type='s', name='table')
147+
surf_2.desc = "This is a simple table located in the middle of the room. Let's take a look at it..."
148+
european_module.add(surf_2)
149+
150+
box_b = gm.new(type='c', name="box B")
151+
box_b.desc = "This a regular box, keeps the key to open box A."
152+
surf_2.add(box_b)
153+
gm.add_fact("closed", box_b)
154+
155+
key_2 = gm.new(type='k', name="code key 1")
156+
key_2.desc = "This key is in fact a digital code which opens the box in the US Lab area. " \
157+
"The code, in fact, is written on a piece of paper."
158+
box_b.add(key_2)
159+
gm.add_fact("match", key_2, box_a)
160+
161+
chair_1 = gm.new(type='s', name='chair')
162+
chair_1.desc = "this is a dark-gray chair which is developed to be used in space."
163+
european_module.add(chair_1)
164+
165+
corridor2 = gm.connect(us_lab.east, european_module.west)
166+
167+
# ===== Russian Module Design ======================================================================================
168+
russian_module = gm.new_room("Russian Module")
169+
russian_module.desc = "The Russian module is a typical space lab that you can expect, filled with a lot of " \
170+
"processing machines, test equipments and space drive cars. Since it is located at the " \
171+
"center of International Space Station, it is also important room for everyone. there are " \
172+
"many other objects here and there belongs to other astronauts, probably that's why here " \
173+
"looks a bit messy. There are some stuffs here you should pick, obviously if you can find " \
174+
"them among all this mess."
175+
176+
surf_3 = gm.new(type='s', name='metal table')
177+
surf_3.desc = "This is a big metal table, a messy one, there are many things on it, it is difficult to find " \
178+
"what you want. However, there is just one item which is important for you. Try to find that item."
179+
russian_module.add(surf_3)
180+
181+
papers = gm.new(type='o', name='bunch of sticked papers')
182+
surf_3.add(papers)
183+
184+
notebooks = gm.new(type='o', name='lots of hanged notebooks')
185+
surf_3.add(notebooks)
186+
187+
tools = gm.new(type='o', name='attached bags for mechanical tools')
188+
surf_3.add(tools)
189+
190+
box_c = gm.new(type='c', name="box C")
191+
box_c.desc = "This box is locked! sounds it carries important item... So, let's find its key to open it. Wait... " \
192+
"strange! the lock looks like a heart!! Wait we've seen something similar to this somewhere before."
193+
surf_3.add(box_c)
194+
gm.add_fact("locked", box_c)
195+
196+
key_3 = gm.new(type='k', name="digital key 1")
197+
key_3.desc = "This key is an important key in this craft. If you want to leave the spaceship, you definitely " \
198+
"need this key "
199+
box_c.add(key_3)
200+
201+
surf_4 = gm.new(type='s', name='wall-mounted surface')
202+
surf_4.desc = "This is a wall-mounted surface which different instruments are installed on this. " \
203+
"These instruments are basically control various modules and doors in the shuttle."
204+
russian_module.add(surf_4)
205+
206+
box_d = gm.new(type='c', name="exit box (box D)")
207+
box_d.desc = "The most important box here, which is in fact locked! sounds it carries important item... " \
208+
"So, let's find its key to open it."
209+
surf_4.add(box_d)
210+
gm.add_fact("locked", box_d)
211+
212+
"""
213+
Push button should be defined here
214+
"""
215+
push_button = gm.new(type='k', name="exit push button")
216+
russian_module.add(push_button)
217+
218+
corridor3 = gm.connect(us_lab.south, russian_module.north)
219+
door_b = gm.new_door(corridor3, name="door B")
220+
gm.add_fact("locked", door_b)
221+
gm.add_fact("match", key_1, door_b) # Tell the game 'Electronic key' is matching the 'door B''s lock
222+
223+
# ===== Lounge Design ==============================================================================================
224+
lounge = gm.new_room("Lounge Module")
225+
lounge.desc = "This lounge is very quiet room with a big round window to the space. Wow, you can look to our " \
226+
"beloved Earth from this window. This room is the place that you can stay here for hours and just " \
227+
"get relax. This room also contains some other stuff, let's explore what they are ..."
228+
229+
box_e = gm.new(type='c', name="box E")
230+
box_e.desc = "This box is actually a wall-mounted bag and you can put an object into it. Since we have no " \
231+
"gravity in the space, you can't just simply leave the object in the room. The object should be " \
232+
"hooked or inserted into a container like this bag. Well, know we know what it is!"
233+
lounge.add(box_e)
234+
gm.add_fact("closed", box_e)
235+
236+
key_4 = gm.new(type='k', name="electronic key 2")
237+
key_4.desc = "This key is the key opens the door to the control room. Although it looks like a regular iron key, " \
238+
"it is very special metal key! Not any other key can be like it. Make sure to keep it in safe place."
239+
box_e.add(key_4)
240+
241+
corridor4 = gm.connect(russian_module.east, lounge.west)
242+
243+
# ===== Control Module Design ======================================================================================
244+
control_module = gm.new_room("Control Module")
245+
control_module.desc = "This is the heart of this spaceship! Wow ... look around, all the monitors and panels. " \
246+
"It is like you can control everything from here; more interestingly, you can communicate " \
247+
"with people on the Earth. There are also super important objects kept in this room. Let's " \
248+
"find them."
249+
250+
box_f = gm.new(type='c', name="secured box (box F)")
251+
box_f.desc = "This box is secured very much, simple box with a complex, strange keypad to enter the code! " \
252+
"so ... it should contain extremely important items in it. Isn't it the thing you are looking for?!"
253+
control_module.add(box_f)
254+
gm.add_fact("locked", box_f)
255+
gm.add_fact("match", key_3, box_f)
256+
257+
book = gm.new(type='o', name='Secret Codes Handbook')
258+
book.desc = "If you open and check this book, here it is the description: 'This is a book of all secret codes " \
259+
"to manage different actions and functions inside the International Space Station. These codes are " \
260+
"pre-authorized by the main control room at Earth unless it is mentioned.'" \
261+
" " \
262+
"On the second page of the book, you can find this: 'To open the hatch door you should have both " \
263+
"two keys in the secured box. ATTENTION: you MUST have the outfit on you, before opening the hatch. " \
264+
"Otherwise, your life is in fatal danger.'"
265+
box_f.add(book)
266+
267+
key_5 = gm.new(type='k', name="digital key 2")
268+
box_f.add(key_5)
269+
gm.add_fact("match", key_5, box_d)
270+
key_6 = gm.new(type='k', name="code key 2")
271+
box_f.add(key_6)
272+
273+
corridor5 = gm.connect(control_module.east, russian_module.west)
274+
door_c = gm.new_door(corridor5, name="door C")
275+
gm.add_fact("locked", door_c)
276+
gm.add_fact("match", key_4, door_c) # Tell the game 'Electronic key' is matching the 'door B''s lock
277+
278+
# ===== Hatch Design ===============================================================================================
279+
hatch = gm.new_room("Hatch")
280+
hatch.desc = "This area is like the entrance to the spaceship, so like home entrance with outer and inner doors " \
281+
"and a place that outfits are hooked. There are only two important differences: first, if the outer " \
282+
"door is open and you don't have outfit on you, you are dead!! No joke here! So make sure that you " \
283+
"open the door after wearing those cloths. Second, the door nob to open the door is not neither on " \
284+
"the door nor in this room. You should open the external door from Russian Module! woooh so much of " \
285+
"safety concerns, yeah?!"
286+
287+
"""
288+
Cloths
289+
"""
290+
cloth = gm.new(type='o', name="outfit")
291+
hatch.add(cloth)
292+
293+
corridor6 = gm.connect(hatch.north, lounge.south)
294+
door_d = gm.new_door(corridor6, name="door D")
295+
gm.add_fact("locked", door_d)
296+
gm.add_fact("match", key_6, door_d)
297+
298+
# ===== Outside Spaceship (Space) Design ===========================================================================
299+
outside = gm.new_room("Outside")
300+
outside.desc = "Here is outside the spaceship. No Oxygen, no gravity, nothing! If you are here, it means that " \
301+
"you have the special outfit on you and you passed the medium level of the game! Congrats!"
302+
303+
corridor7 = gm.connect(outside.north, hatch.south)
304+
door_e = gm.new_door(corridor7, name="door E")
305+
gm.add_fact("locked", door_e)
306+
gm.add_fact("match", push_button, door_e)
307+
308+
# ===== Player and Inventory Design ================================================================================
309+
gm.set_player(sleep_station)
310+
311+
key_7 = gm.new(type='k', name="hearty key")
312+
key_7.desc = "This key is shaped like a heart, not a normal key for a spaceship, ha ha ha..."
313+
gm.add_fact("match", key_7, box_c)
314+
gm.inventory.add(key_7) # Add the object to the player's inventory.
315+
316+
gm.render(interactive=True)
317+
318+
87319
if __name__ == "__main__":
88-
spaceship_maker()
320+
# spaceship_maker_level_easy()
321+
spaceship_maker_level_medium()

0 commit comments

Comments
 (0)