Skip to content

Instantly share code, notes, and snippets.

@Sasszem
Created February 23, 2020 22:11
Show Gist options
  • Save Sasszem/100f4634d664da3e422505e4df4ebd7f to your computer and use it in GitHub Desktop.
Save Sasszem/100f4634d664da3e422505e4df4ebd7f to your computer and use it in GitHub Desktop.
Text adventore game rewritten with lists
#######
# Map #
#######
#########
#Key A #
# 2#
############# ###
#Key B # Start#
# 3A 1#
##############B##########
#Sword # #Zombie #
# #
# 5# 4#Key C 6#
#############C###################
#Shield # # Z # Goal #
# 8 7 Z 9 10#
#################################
# Szoba:
# Item, szörny, fel, le, jobbra, balra
# irányok: [szoba, kulcs]
TERKEP = [
[
None, None, [1, None], [3, "KULCS B"], [None, None], [2, "KULCS A"]
],
[
"KULCS A", None, [None, None], [0, None], [None, None], [None, None]
],
[
"KULCS B", None, [None, None], [None, None], [0,"KULCS A"], [None, None]
],
[
None, None, [0, "KULCS B"], [6, "KULCS C"], [5, None], [4, None]
],
[
"KARD", None, [None, None], [None, None], [3, None], [None, None]
],
[
"KULCS C", "ZOMBI", [None, None], [None, None], [None, None], [3, None]
],
[
None, None, [3, "KULCS C"], [None, None], [8, None], [7, None]
],
[
"PAJZS", None, [None, None], [None, None], [6, None], [None, None]
],
[
None, "ZOMBIx2", [None, None], [None, None], [9, None], [6, None]
],
[
None, None, [None, None], [None, None], [None, None], [8, None]
]
]
print("Parancsok:")
print(" FEL")
print(" LE")
print(" BALRA")
print(" JOBBRA")
print(" FELVESZ")
print(" UT")
SZOBA = 0
FUT = True
INVENTORY = []
while FUT:
print(f"SZOBA {SZOBA}")
if TERKEP[SZOBA][0]:
print(f"Van itt egy {TERKEP[SZOBA][0]}")
else:
print("Nincs itt SEMMI")
if TERKEP[SZOBA][1]:
print(f"A szobában lesben áll egy {TERKEP[SZOBA][1]}!")
print(TERKEP[SZOBA])
print(INVENTORY)
print("Mehetsz:")
if TERKEP[SZOBA][2][0] != None:
print(" FEL")
if TERKEP[SZOBA][3][0] != None:
print(" LE")
if TERKEP[SZOBA][4][0] != None:
print(" JOBBRA")
if TERKEP[SZOBA][5][0] != None:
print(" BALRA")
if SZOBA==9:
print("Itt van a KINCS!")
print("Gratulálok, nyerél!")
FUT = False
parancs = input("Mit csinálsz?")
if parancs in ["FEL", "LE", "BALRA", "JOBBRA", "FELVESZ", "UT"]:
if TERKEP[SZOBA][1] and parancs != "UT":
print(f"A {TERKEP[SZOBA][1]} rádveti magát és MEGÖL!")
print("MEGHALTÁL!")
FUT = False
else:
SZORNY = TERKEP[SZOBA][1]
if SZORNY == "ZOMBI":
if "KARD" in INVENTORY:
print(f"Agyonütöd a {SZORNY}-t a KARD-al!")
TERKEP[SZOBA][1] = None
else:
print(f"A {SZORNY} erősebb és MEGÖL!")
print("MEGHALTÁL!")
FUT = False
elif SZORNY == "ZOMBIx2":
if "KARD" in INVENTORY:
print("Agyonütöd az első ZOMBI-t a KARD-al!")
if "PAJZS" in INVENTORY:
print("A második ZOMBI RÁDTÁMAD, de megvéd a PAJZS!")
print("Agyonütöd a ZOMBI-t a KARD-al!")
else:
print("A második ZOMBI RÁDTÁMAD, és MEGÖL!")
print("MEGHALTÁL!")
FUT = False
else:
print("A {SZORNY} erősebb és MEGÖL!")
print("MEGHALTÁL!")
FUT = False
if parancs=="UT" and not TERKEP[SZOBA][1]:
print("A szobában nincs ellenség!")
if parancs=="FELVESZ":
if TERKEP[SZOBA][0]:
INVENTORY.append(TERKEP[SZOBA][0])
print(f"Megszerezted a {TERKEP[SZOBA][0]}-t!")
TERKEP[SZOBA][0] = None
else:
print("A szobában nincsen semmi!")
if parancs=="FEL":
if not TERKEP[SZOBA][2][0] != None:
print("Erre nem lehet menni!")
else:
if TERKEP[SZOBA][2][1] and not TERKEP[SZOBA][2][1] in INVENTORY:
print("Az AJTÓ be van ZÁRVA!")
else:
SZOBA = TERKEP[SZOBA][2][0]
if parancs=="LE":
if not TERKEP[SZOBA][3][0] != None:
print("Erre nem lehet menni!")
else:
if TERKEP[SZOBA][3][1] and not TERKEP[SZOBA][3][1] in INVENTORY:
print("Az AJTÓ be van ZÁRVA!")
else:
SZOBA = TERKEP[SZOBA][3][0]
if parancs=="JOBBRA":
if not TERKEP[SZOBA][4][0] != None:
print("Erre nem lehet menni!")
else:
if TERKEP[SZOBA][4][1] and not TERKEP[SZOBA][4][1] in INVENTORY:
print("Az AJTÓ be van ZÁRVA!")
else:
SZOBA = TERKEP[SZOBA][4][0]
if parancs=="BALRA":
if not TERKEP[SZOBA][5][0] != None:
print("Erre nem lehet menni!")
else:
if TERKEP[SZOBA][5][1] and not TERKEP[SZOBA][5][1] in INVENTORY:
print("Az AJTÓ be van ZÁRVA!")
else:
SZOBA = TERKEP[SZOBA][5][0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment