From 25cc73ccf9dd6a363ed77d988a2eb825ef92444e Mon Sep 17 00:00:00 2001 From: Olli Graf Date: Sun, 29 May 2022 16:20:40 +0200 Subject: [PATCH] Jacke -> Zwerg -> Schachtel -> Karte --- ActionBasics.py | 8 ++++++++ ActionModul.py | 41 +++++++++++++++++++++++++++++++++-------- World.py | 2 ++ tomb.py | 2 ++ world.xml | 2 ++ 5 files changed, 47 insertions(+), 8 deletions(-) diff --git a/ActionBasics.py b/ActionBasics.py index 98d67b3..391c5e5 100644 --- a/ActionBasics.py +++ b/ActionBasics.py @@ -24,9 +24,17 @@ class ActionBasics: def clearFehler(self): self.world.fehler = '' + def wechsleRaum(self,raum): + self.world.aktuellerRaum = raum + raum.entdeckt = True + def liegtItemInRaum(self,itemid, raum): return itemid in raum.items + def macheItemSichtbar(self, item): + logging.debug(f'mache sichtbar {item.name} in Raum {item.raumid}') + item.sichtbar = True + def moveItemVonRaumNachInventar(self,item): logging.debug(f'entferne aus aktuellen Raum {item.name}') del self.world.aktuellerRaum.items[item.id] diff --git a/ActionModul.py b/ActionModul.py index 707c614..36720db 100644 --- a/ActionModul.py +++ b/ActionModul.py @@ -99,6 +99,11 @@ class ActionModul(ActionBasics): self.setFehler('Das Gatter steht offen.') else: self.setFehler(f'Der Stier steht dir im Weg.') + elif item.id == self.world.ITEM_SCHACHTEL: + karte = self.world.findItemById(self.world.ITEM_KARTE) + logging.debug('Schachtel öffnen') + item.zustand = item.OFFEN + self.macheItemSichtbar(karte) @@ -264,6 +269,7 @@ class ActionModul(ActionBasics): schluessel.sichtbar = True elif item.id == self.world.ITEM_TEICH: fisch = self.world.findItemById(self.world.ITEM_FISCH) + if fisch.raumid == self.world.RAUM_TEICH: fisch.sichtbar = True @@ -276,10 +282,14 @@ class ActionModul(ActionBasics): self.zeigeItemBeschreibung(item) item.sichtbar = False self.ausDemInventar(item) + elif self.isItem(item,self.world.ITEM_KARTE): + self.world.printKarte() else: self.zeigeItemBeschreibung(item) else: + person = self.world.findPersonImAktuellenRaum(self.world.PERSON_ZWERG) + logging.debug('Kein Item gefunden, suche nach Raum') self.untersucheAktuellenRaum(parsedCommand) @@ -429,12 +439,12 @@ class ActionModul(ActionBasics): def sprich(self,parsedCommand): - geist = self.world.findPersonImAktuellenRaum(parsedCommand.gegenstand) + person = self.world.findPersonImAktuellenRaum(parsedCommand.gegenstand) - if geist != None: - self.world.printText('geist') + if person != None: + self.world.printText(f'npc-{person.id}') else: - self.setFehler(f'{parsedCommand.gegenstand} ist nicht im Raum.') + self.setFehler(f'{parsedCommand.gegenstand} ist nicht im Raum.') def hilfe(self,parsedCommand): if parsedCommand.gegenstand == 'befehle': @@ -470,10 +480,25 @@ class ActionModul(ActionBasics): else: self.geheNachItem(parsedCommand) - - def wechsleRaum(self,raum): - self.world.aktuellerRaum = raum - raum.entdeckt = True + def gib(self, parsedCommand): + item = self.world.findItemImInventar(parsedCommand.gegenstand) + + if item == None: + self.setFehler('Das besitzt du nicht') + return + + if item.id == self.world.ITEM_JACKE: + zwerg = self.world.findPersonImAktuellenRaumById(self.world.PERSON_ZWERG) + + logging.debug(f'gib() Zwerg {zwerg}') + + if zwerg != None: + schachtel = self.world.findItemById(self.world.ITEM_SCHACHTEL) + self.setFehler('Der Zwerg zieht sich die Jacke an, grinst erleichtert und verschwindet.') + del self.world.aktuellerRaum.personen[zwerg.id] + self.macheItemSichtbar(schachtel) + + def geheNach(self,richtung): logging.debug(f'Richtung {richtung}') raum = self.world.aktuellerRaum diff --git a/World.py b/World.py index bc29b77..688f23f 100644 --- a/World.py +++ b/World.py @@ -375,6 +375,8 @@ class World: self.ITEM_ELEFANT = '22' self.ITEM_HAFEN = '23' self.ITEM_GATTER = '25' + self.ITEM_SCHACHTEL = '26' + self.ITEM_KARTE = '27' # Räume diff --git a/tomb.py b/tomb.py index 8f3c826..3683e4e 100755 --- a/tomb.py +++ b/tomb.py @@ -68,6 +68,8 @@ def verarbeiteBefehl(parsedCommand): actionmodul.fuelle(parsedCommand) elif id == '28': actionmodul.wirf(parsedCommand) + elif id == '29': + actionmodul.gib(parsedCommand) elif id == '-1': world.fehler = 'Ich verstehe diesen Befehl nicht' else: diff --git a/world.xml b/world.xml index b54f789..cc9045f 100644 --- a/world.xml +++ b/world.xml @@ -265,6 +265,8 @@ + +