Created
November 3, 2021 11:29
-
-
Save hernikplays/85d5227554b9a339a75cac65e5a542b7 to your computer and use it in GitHub Desktop.
Hra úkol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Lokace: | |
def __init__(self,nazev,popis): | |
self.nazev = nazev | |
self.popis = popis | |
self.sever = None | |
self.jih = None | |
self.zapad = None | |
self.vychod = None | |
def __str__(self): | |
smer = "" | |
if self.sever is not None: | |
smer+="sever, " | |
if self.jih is not None: | |
smer+="jih, " | |
if self.zapad is not None: | |
smer+="zapad, " | |
if self.vychod is not None: | |
smer+="vychod, " | |
if smer == "": | |
smer = "nikam" | |
return f"{self.nazev}\n{self.popis}\n\nMůžeš jít směrem na {smer}\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from vse import * | |
aktualni = rozcesti | |
while True: | |
print(aktualni) | |
while True: | |
i = input("Zadej příkaz: ") | |
if(i.lower() == "konec"): | |
exit(0) | |
else: | |
smer = i.split(" ")[2].lower() | |
if smer == "jih" and aktualni.jih is not None: | |
aktualni = aktualni.jih | |
break | |
elif smer == "sever" and aktualni.sever is not None: | |
aktualni = aktualni.sever | |
break | |
elif smer == "zapad" and aktualni.zapad is not None: | |
aktualni = aktualni.zapad | |
break | |
elif smer == "vychod" and aktualni.vychod is not None: | |
aktualni = aktualni.vychod | |
break | |
else: | |
print("Neplatná volba") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from lokace import * | |
hrad = Lokace("Hrad", "Tajuplný hrad plný neobjevených tajemství.") | |
les1 = Lokace("Les", "Hluboký smíšený les, v noci nevíš, kde na tebe něco vyskočí.") | |
les2 = Lokace("Les", "Hluboký smíšený les, v noci nevíš, kde na tebe něco vyskočí.") | |
les3 = Lokace("Les", "Hluboký smíšený les, v dáli vidíš nějaký starý barák.") | |
rozcesti = Lokace("Lesní Rozcestí", "Jediné místo, kde víš, kudy dál") | |
rybnik = Lokace("Rybník", "Romantický rybník") | |
dum = Lokace("Dům", "Dávno opuštěný dům, občas se tu prý objevuje nějaké světlo") | |
hrad.vychod = les1 | |
les1.zapad = hrad | |
les1.vychod = rozcesti | |
rozcesti.jih = les3 | |
rozcesti.zapad = les1 | |
rozcesti.vychod = les2 | |
les2.zapad = rozcesti | |
les2.vychod = rybnik | |
les3.vychod = dum | |
les3.sever = rozcesti | |
dum.zapad = les3 | |
rybnik.zapad = les2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment