This repository has been archived on 2022-05-04. You can view files and clone it, but cannot push or open issues or pull requests.
Pyhton-Dungeon-Spiel/game.py

361 lines
18 KiB
Python
Raw Permalink Normal View History

2017-07-06 07:22:07 +00:00
#Dungeon Spiel Emanuel
import random
eg=("Mmh...","Mhh...","Schmatz...","Mampf...")
lg=("Lecker!","Das war aber gut!")
2020-10-05 22:28:16 +00:00
kg=("Versuche es noch einmal!")
2017-07-06 09:51:38 +00:00
#dungeon="..w..K.w.G...K.w.G..K..w..K..G.w.K.$..K.w.G.K.w.w.K.w.G.K.€.K.G.w.K..wKG.K.G.K.€.G.K.G.K.w.G.K.G.K..€.G.K.G.K.w..K.G.w.K.w.$.w.K.w.G.K.p"
dungeon1="""
############################################################################################################################
#.<################################################################################################.#######.################
2017-07-06 09:51:38 +00:00
##.#########################################################################################################################
##.#########################################################################################################################
2017-11-10 13:36:53 +00:00
##.###.............*..............H...........*......G.....K.................H...............H.H.................###########
##K###.###############H#########################################################################################.###########
##G###..K..###########*HHHH.#####HH#############################################################################.###########
##.#######..##########*####HHH.H.##HH###########################################################################.###########
##.#####...###########K#########################################################################################.###########
##.#####.#############K#########################################################################################k###########
2017-07-06 09:51:38 +00:00
##.#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#########.###########
#->....k.*...#......*..#......*..#........*#..........*#.......*.#.......*.#.........*.#....*#..*#...<B#########*###########
2017-07-06 09:51:38 +00:00
####d#d#s#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#########.###########
########p#####k#*#*#K#K#########################################################################################.###########
################K#K#K#K#########################################################################################.###########
################*#K#K#K#########################################################################################.###########
################*#G#K#K############################################################################.#######.####.###########
################H#*#G#K#########################################################################################.###########
################.........*......*........*.....................G.......K.........................................###########
2017-07-06 09:51:38 +00:00
############################################################################################################################
############################################################################################################################
############################################################################################################################
############################################################################################################################
############################################################################################################################
############################################################################################################################
############################################################################################################################
############################################################################################################################
"""
dungeon2="""
############################################################################################################################
#.>HHGGKKKK.................................HHH.........................:..........#.......⬆........#######.....#######....#
#..HHGGKKKK...............................H.....H..................................#................#..#...........#.......#
#HHHHGGKKKK..............................H.......H................................#................#...#...........#.......#
#HHHHGGKKKK..............................H.......H...............................#................#..l.#...........#.......#
#GGKKKK...................................H.....H................................#...............#...w.#...........#.......#
#GGKKKK.....................................HHH..................................#..............#....b.#...........#.......#
#KKKKKK...........................................................................#............#....h..#...........#.......#
#KKKKKK...........................................................................##..........#....r.###...........#.......#
#KKKKKK..........................................................................#..#........#....c.####...........#.......#
2017-11-10 13:36:53 +00:00
#...............................................................................#....#......#....e.###.#...........#.......#
-->.............................................................................#.....#....#....r.###..#...........#.......#
#..............................................................................#.......#..#......###...#...........#.......#
#...............................................................................#.....#..#......###....#...........#.......#
#....................................................##.###.###.####.###.####.####.#####.#####.###.....#HHHHHHHHHHH#.......#
#....................................................#.................................................#HHHHHHHHHHH#.......#
2017-11-10 13:36:53 +00:00
#...................................................#######################################################.....>######....#
#..................................................HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH............#########......#
#HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH########...............#
#K.K.K.K.K.K.K.K.K.K.K.GK.K.K.K.K.K.GK.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.GK.K.K.K.K.K................#
#HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH...............#
#HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH...............#
#HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH...............#
#HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH...............#
#HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH...............#
#..........................................................................................................................#
2017-07-06 09:51:38 +00:00
############################################################################################################################
"""
dungeon3="""
############################################################################################################################
#..........................................................................................#######..#######..#######.......#
#.............................................................................................#........#........#..........#
#.............................................................................................#........#........#..........#
#.............................................................................................#........#........#..........#
#.............................................................................................#........#........#..........#
#.............................................................................................#........#........#..........#
#.............................................................................................#........#........#..........#
#.............................................................................................#........#........#..........#
#.............................................................................................#........#........#..........#
#.............................................................................................#........#........#..........#
--><..........................................................................................#........#........#..........#
2017-07-06 09:51:38 +00:00
#.............................................................................................#........#........#..........#
#.............................................................................................#........#........#..........#
#.............................................................................................#........#........#..........#
#.............................................................................................#........#........#..........#
#..........................................................................................#######..#######..#######.......#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
############################################################################################################################
2017-07-06 09:51:38 +00:00
"""
l="""
##########################################################
#........................................................~
#........................................................#
##########################################################
#wwwwwwwww#w#wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww#
#wwwwwwwww###wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww#
#wwwwwwwww#wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww#
#wwwwwwwww#wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww#
###########wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww#
#wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww#
#wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww#
##########################################################
"""
2017-07-06 07:22:07 +00:00
hero="@"
2017-07-06 09:51:38 +00:00
herox=1
heroy=2
heroz=0
2017-07-06 07:22:07 +00:00
hero_Gold=0
hero_Wurstsemmel=50
2017-07-06 07:22:07 +00:00
hero_hunger=0
hero_hp=2500
hero_key=0
hero_special_key=0
2017-07-06 09:51:38 +00:00
#level=list(dungeon)
level=[]
for d in (dungeon1,dungeon2,dungeon3,l):
2017-07-06 09:51:38 +00:00
l=[]
for line in d.splitlines():
l.append(list(line))
level.append(l)
while True:
if hero_hunger>38:
2020-10-05 22:28:16 +00:00
print("Du bist verhungert!")
break
if hero_hunger<-1:
2020-10-05 22:28:16 +00:00
print("Dein Bauch ist geplatzt!")
break
hero_hunger+=random.choice((0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2))
2017-07-06 09:51:38 +00:00
#for x,c in enumerate(level):
# if x==herox:
# print(hero,end="")
# else:
# print (c,end="")
#print()
for y, line in enumerate(level[heroz]):
for x,c in enumerate(line):
if x==herox and y==heroy:
print(hero,end="")
else:
print(c,end="")
print()
command=input("Gold:{} \nWurstsemmeln:{} \nHunger:{}\nLeben:{}\nKeys:{}\n?".format(hero_Gold,hero_Wurstsemmel,hero_hunger,hero_hp,hero_key))
dx=0
2017-07-06 09:51:38 +00:00
dy=0
2017-07-06 07:22:07 +00:00
if command=="a":
#herox-=1
dx=-1
2017-07-06 07:22:07 +00:00
if command=="d":
#herox+=1
dx=1
2017-07-06 09:51:38 +00:00
if command=="s":
#heroy-=1
dy=1
if command=="w":
#heroy+=1
2017-07-06 09:51:38 +00:00
dy=-1
2017-07-06 07:22:07 +00:00
if command=="e":
if hero_Wurstsemmel>0:
hero_hunger-= random.randint(4,20)
hero_Wurstsemmel-=1
print(random.choice(eg)+"\n"+random.choice(lg))
else:
2020-10-05 22:28:16 +00:00
print("Hilfe!!!\nKein essen mehr!!")
if command=="Zaubertrank":
hero_hp+=100
if command=="Schlüssel+":
hero_key+=10
if command=="Semmel+":
hero_wurstsemmel+=10
if command=="fly up":
if heroz==0:
print("Du bist schon im obersten Level")
else:
heroz-=1
if command=="fly down":
if heroz==len(level)-1:
print("Du bist schon im untersten Level")
else:
heroz+=1
2017-07-06 09:51:38 +00:00
# ---in Wand gelaufen---
target=level[heroz][heroy+dy][herox+dx]
if target=="#":
dx=0
dy=0
2020-10-05 22:28:16 +00:00
print("Autch ich bin in eine Mauer gelaufen!")
#In Teleporter gelaufen---
elif target=="*":
#try to find legal field
for v in range(100):
tx=random.randint(-5,5)+herox
ty=random.randint(-4,4)+heroy
if level[heroz][ty][tx]=="." or level[heroz][ty][tx]=="*":
herox=tx
dx=0
heroy=ty
dy=0
break
else:
dx=0
dy=0
#print("Der teleporter katapultiert dich woanders hin!")
#dx=random.randint(-5,5)
#dy=random.randint(-5,5)
# ---- Ausgang anfang ----
elif target=="~":
heroz==1
heroy==2
herox==102
# ---- in türe gelaufen ? -----
# ---- Lebensmittelgeschäft anfang ----
elif target=="l":
heroz==3
heroy==1
herox==1
# ---- Lebensmittelgeschäft Ende ----
elif target=="d":
if hero_key>0:
hero_key-=1
level[heroz][heroy+dy][herox+dx]="H"
else:
dx=0
dy=0
2020-10-05 22:28:16 +00:00
print("Hife!\nIch bin gegen eine geslossene Tür ohne Schlüssel gelaufen!")
#----In Spezialtüre gelaufen?----
elif target=="s":
if hero_special_key>0:
hero_special_key-=1
level[heroz][heroy+dy][herox+dx]="H"
else:
dx=0
dy=0
2020-10-05 22:28:16 +00:00
print("Hife!\nIch bin gegen eine geslossene Tür ohne Schlüssel gelaufen!")
# in Monster gelaufen?
2017-07-06 09:51:38 +00:00
#target=level[herox+dx]
#---Gorilla anfang---
if target=="G":
print("Ein Gorilla blockiert deinen Weg!")
print("Der Gorilla schlägt dich mit einer Banane!")
schaden=random.randint(1,10)
2017-07-06 09:51:38 +00:00
hero_hp-=schaden
print("Du erleidest {} Schaden".format(schaden))
if hero_hp<1:
2020-10-05 22:28:16 +00:00
print:("Du stirbst!")
break
sieg=0.333333
if random.random() < sieg:
2017-07-06 09:51:38 +00:00
level[heroz][heroy+dy][herox+dx]="."
print("Du erledigst heldenhaft den Gorilla!!")
else:
print("Du Verlierst!")
dx=0
2017-07-06 09:51:38 +00:00
dy=0
# -------- gorilla ende ---------
#---Boss anfang---
if target=="B":
print("Der Boss hat die Prinnzessin enntführt!")
print("Der Boss kämpft proffessionell!")
schaden=random.randint(100,1500)
hero_hp-=schaden
print("Du erleidest {} Schaden".format(schaden))
if hero_hp<1:
2020-10-05 22:28:16 +00:00
print:("Du stirbst!")
break
sieg=0.1
if random.random() < sieg:
level[heroz][heroy+dy][herox+dx]="H"
print("Du erledigst heldenhaft den Boss!!")
hero_special_key+=1
else:
print("Du Verlierst!")
dx=0
dy=0
#---kobold anfang---
if target=="K":
print("Ein Kobold blockiert deinen Weg!")
print("Der Kobold piekst dich mit einer Gabel!")
schaden=random.randint(10,20)
hero_hp-=schaden
print("Du erleidest {} Schaden".format(schaden))
if hero_hp<1:
print:("Du stirbst!\nVersager!")
break
sieg=0.7
if random.random() < sieg:
print("Du erledigst heldenhaft den Kobold!!")
2017-07-06 09:51:38 +00:00
level[heroz][heroy+dy][herox+dx]="."
else:
print("Du Verlierst!")
dx=0
2017-07-06 09:51:38 +00:00
dy=0
# -------- kobold ende ---------
2017-11-10 13:36:53 +00:00
# -------- Hexe Anfang ---------
if target=="H":
print("Eine Hexe blockiert deinen Weg!")
print("Die Hexe verletzt dich mit einem Zauberball!")
schaden=random.randint(100,300)
2017-11-10 13:36:53 +00:00
hero_hp-=schaden
print("Du erleidest {} Schaden".format(schaden))
if hero_hp<1:
2020-10-05 22:28:16 +00:00
print:("Du stirbst!")
2017-11-10 13:36:53 +00:00
break
sieg=0.2
2017-11-10 13:36:53 +00:00
if random.random() < sieg:
level[heroz][heroy+dy][herox+dx]="."
print("Du erledigst heldenhaft die Hexe!!")
else:
print("Du Verlierst!")
dx=0
dy=0
herox+=dx
2017-07-06 09:51:38 +00:00
heroy+=dy
2017-11-10 13:36:53 +00:00
#--------Hexe Ende-------
#Aufheben
2017-07-06 09:51:38 +00:00
stuff=level[heroz][heroy][herox]
2017-07-06 07:22:07 +00:00
if stuff=="" or stuff=="$":
hero_Gold+=1
level[heroz][heroy][herox]="H"
2017-07-06 07:22:07 +00:00
if stuff=="w":
hero_Wurstsemmel+=1
level[heroz][heroy][herox]="H"
if stuff=="p":
print("Du hast die Prinzessin befreit!")
2017-07-06 09:51:38 +00:00
level[heroz][heroy][herox]="p"
break
if stuff=="<":
command2=input("Du bist auf einer Treppe gelandet.\nWillst du ein Stockwerk tiefer gehen?")
if command2=="y":
heroz+=1
else:
print("Ok, dann eben nicht.")
if stuff==">":
command3=input("Du bist auf einer Treppe gelandet.\nWillst du ein Stockwerk höher gehen?")
if command3=="y":
heroz-=1
else:
print("Ok, dann eben nicht.")
if stuff=="k":
hero_key+=1
level[heroz][heroy][herox]="H"
2017-07-06 07:22:07 +00:00
print("Ende")
2017-07-06 07:22:07 +00:00