From 71e76c957e4d38a5cd2ce0d13dd9149a4753f973 Mon Sep 17 00:00:00 2001 From: Olli Graf Date: Wed, 27 Apr 2022 08:25:18 +0200 Subject: [PATCH] Raumkonstanten. --- ActionModul.py | 6 ++++++ World.py | 17 ++++++++++++++--- WorldParser.py | 2 +- tomb.py | 23 ++++++++++++++++++----- world.xml | 2 +- 5 files changed, 40 insertions(+), 10 deletions(-) diff --git a/ActionModul.py b/ActionModul.py index d0d01c4..1f0cfe4 100644 --- a/ActionModul.py +++ b/ActionModul.py @@ -80,6 +80,7 @@ class ActionModul: self.setFehler('Auf dem Boden findest du einen kleinen Schlüssel.') schluessel = self.world.findRaumItemById(self.world.ITEM_KLEINER_SCHLUESSEL) schluessel.sichtbar = True + def untersuche(self,parsedCommand): @@ -95,6 +96,10 @@ class ActionModul: # Falltür sichtbar machen self.world.aktuellerRaum.ausgaenge[self.world.RUNTER] = '5' self.setFehler('Im Boden unter dem Bett findest du eine Falltür, die nach unten führt.') + elif item.id == self.world.ITEM_NACHTSCHRANK: + self.setFehler('In der Schublade findest du einen Schlüssel') + schluessel = self.world.findRaumItemById(self.world.ITEM_HAUSTUERSCHLUESSEL) + #schluessel.sichtbar = True else: logging.debug('Kein Item gefunden, suche nach Raum') self.untersucheAktuellenRaum(parsedCommand) @@ -103,6 +108,7 @@ class ActionModul: item = self.world.findIteminAktuellerRaum(parsedCommand.gegenstand) if item != None: + #alter Code! if item.id == 8: self.world.stdscr.addstr('Du ziehst den Hebel und es passiert.... nichts!') else: diff --git a/World.py b/World.py index 96cd26c..eb90f20 100644 --- a/World.py +++ b/World.py @@ -77,7 +77,7 @@ class World: def sucheRaumName(self,name): for raumid in self.raumliste: raum = self.raumliste[raumid] - if raum.name == name: + if raum.name.lower() == name.lower(): return raum return None @@ -97,7 +97,7 @@ class World: logging.debug('raum.id=' + raum.id) logging.debug('item.raumid=' + item.raumid) logging.debug('findItemInAktuellerRaum() ' + itemname + '-' + item.name) - if item.raumid == raum.id and item.name == itemname: + if item.raumid == raum.id and item.name.lower() == itemname.lower(): return item return None @@ -107,6 +107,7 @@ class World: for itemid in raum.items: item = raum.items[itemid] + logging.debug('findRaumItemById() ' + id + '-' + item.id) if item.raumid == raum.id and item.id == id: return item @@ -115,7 +116,7 @@ class World: def findItemImInventar(self,itemname): for itemid in self.inventar: - if self.inventar[itemid].name == itemname: + if self.inventar[itemid].name.lower() == itemname.lower(): return self.inventar[itemid] return None @@ -200,6 +201,16 @@ class World: self.ITEM_JACKE = '10' self.ITEM_SCHWERT = '11' self.ITEM_SEIL = '12' + self.ITEM_HAUSTUERSCHLUESSEL = '13' + + # Räume + + self.RAUM_ESSZIMMER = '1' + self.RAUM_DACHBODEN = '2' + self.RAUM_FLUR = '3' + self.RAUM_SCHLAFZIMMER = '4' + self.RAUM_KELLER = '5' + self.fehler = '' parser = WorldParser.WorldParser(self) parser.parseWorld('world.xml') diff --git a/WorldParser.py b/WorldParser.py index 524a67a..fd812f1 100644 --- a/WorldParser.py +++ b/WorldParser.py @@ -98,7 +98,7 @@ class WorldParser(): gegenstand.imobil = imobil.lower() in ['true','True','1'] logging.debug('itemid= ' + id + ',visible= ' + visible) gegenstand.sichtbar = visible.lower() not in ['false','False','0'] - logging.debug('Gegenstand ' + gegenstand.name + ' ist sichtbar: ' + str(gegenstand.sichtbar)) + #logging.debug('Gegenstand ' + gegenstand.name + ' ist sichtbar: ' + str(gegenstand.sichtbar)) gegenstand.pickupmsg = msgid print('Item ' + gegenstand.name + ' - Pickup: ' + gegenstand.pickupmsg) diff --git a/tomb.py b/tomb.py index 91e2461..ad48c2a 100755 --- a/tomb.py +++ b/tomb.py @@ -78,10 +78,23 @@ def inputLoop(stdscr): stdscr.addstr(11,0,'Was nun? ') command = stdscr.getstr(11,10,40).decode(encoding="utf-8") command = command.rstrip() - parsedCommand = world.parseInput(command) - commandid = parsedCommand.commandid - verarbeiteBefehl(parsedCommand) - schrittzaehler = schrittzaehler +1 - actionmodul.raumaction() + if command.startswith('debug:'): + debugcommand = command.split(':',1) + + logging.debug(f'debugcommand: {debugcommand}') + + if debugcommand[1] == 'items': + logging.debug('liste Items') + logging.debug(world.gegenstaende) + for item in world.gegenstaende: + logging.debug(f'Id:{item.id} - Name:{item.name}') + + + else: + parsedCommand = world.parseInput(command) + commandid = parsedCommand.commandid + verarbeiteBefehl(parsedCommand) + schrittzaehler = schrittzaehler +1 + actionmodul.raumaction() wrapper(inputLoop) diff --git a/world.xml b/world.xml index 96fcbae..80af372 100644 --- a/world.xml +++ b/world.xml @@ -118,7 +118,7 @@ - +