diff --git a/WorldParser.py b/WorldParser.py index c8892ac..1693520 100644 --- a/WorldParser.py +++ b/WorldParser.py @@ -83,16 +83,20 @@ class WorldParser(): imobil = item.attrib['imobil'] visible = item.attrib['visible'] raum = self.world.sucheRaum(raumid) - gegenstand.raum = raum.id - 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)) - gegenstand.pickupmsg = msgid - print('Item ' + gegenstand.name + ' - Pickup: ' + gegenstand.pickupmsg) + if raum is not None: + gegenstand.raum = raum.id + 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)) + gegenstand.pickupmsg = msgid + print('Item ' + gegenstand.name + ' - Pickup: ' + gegenstand.pickupmsg) - raum.items[id] = gegenstand - self.world.gegenstaende[id] = gegenstand + raum.items[id] = gegenstand + self.world.gegenstaende[id] = gegenstand + else: + logging.error(f'Kann Raum für Gegenstand {gegenstand.name} nicht finden') + print(f'Kein Raum für {gegenstand.name}') # Personen for item in root.findall('personen/person'): diff --git a/kerker.py b/kerker.py deleted file mode 100755 index 958bcfb..0000000 --- a/kerker.py +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/python3 -import World -import ActionModul -import signal -import sys -import logging -import curses -from curses import wrapper - -def verarbeiteBefehl(parsedCommand): - id = parsedCommand.key - - logging.debug(' Befehlkey: ' + id) - if id == '0': - sys.exit() - elif id == '1': - actionmodul.gehe(parsedCommand) - elif id == '2': - actionmodul.nimm(parsedCommand) - elif id == '3': - actionmodul.untersuche(parsedCommand) - elif id == '5': - actionmodul.nord() - elif id == '6': - actionmodul.ost() - elif id == '7': - actionmodul.sued() - elif id == '8': - actionmodul.west() - elif id == '9': - actionmodul.rauf() - elif id == '10': - actionmodul.runter() - elif id == '12': - actionmodul.inventar() - world.waitForCR() - elif id == '13': - actionmodul.about() - elif id == '14': - print('verliere: ' + parsedCommand.gegenstand) - actionmodul.verliere(parsedCommand) - elif id == '15': - actionmodul.warte() - elif id == '17': - actionmodul.ziehe(parsedCommand) - elif id == '19': - actionmodul.stelle(parsedCommand) - elif id == '-1': - world.fehler = 'Ich verstehe diesen Befehl nicht' - else: - world.fehler = 'nicht implementierter Befehl' - -def handle_SIGINT(sig,frame): - logging.debug("CTRL-C abgefangen") - sys.exit(0) - - -logging.basicConfig(filename='kerker.log', level=logging.DEBUG) -signal.signal(signal.SIGINT,handle_SIGINT) -world = World.World() -logging.debug('World initialisiert') -actionmodul = ActionModul.ActionModul(world) - -def inputLoop(stdscr): - world.stdscr = stdscr - curses.echo() - curses.init_pair(1,curses.COLOR_RED, curses.COLOR_WHITE) - curses.init_pair(2,curses.COLOR_GREEN, curses.COLOR_BLACK) - curses.init_pair(3,curses.COLOR_YELLOW, curses.COLOR_BLACK) - commandid = '' - while commandid != '0': - world.printRaum() - 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) - actionmodul.raumaction() - -wrapper(inputLoop) diff --git a/world.xml b/world.xml index e540e35..7598676 100644 --- a/world.xml +++ b/world.xml @@ -1,25 +1,24 @@ - - - - - Im Raum steht eine Streckbank, mit der du vermutlich bald nähere Bekanntschaft machen wirst. -An der Wand steht eine geöffnete eiserne Jungfrau mit furchterregenden spitzen, rostigen Dornen. - - - - - Hier lagern die Folterinstrumente. Du erkennst verschiede Zangen, Ketten, spitze Gegenstände und einige Utensilien, von denen du gar nicht wissen willst, welchen Zweck sie haben. + + + + + Vor dem Fenster steht ein Tisch,ts davon führt eine Leiter nach oben. + + + + + Du befindest dich auf dem Dachboden, auf dem eine alte verstaubte Truhe steht. - + - - + - Der Gang verläuft von Süd nach Nord. Im Norden versperrt ein massives Gittertor den Weg. + Du stehst in Flur vor der Eingangstür, die nach Süden ins Freie führt. + Rechts von der Tür hängt ein abstraktes Bild, links steht eine Pflanze in einer Nische. @@ -96,22 +95,15 @@ An der Wand steht eine geöffnete eiserne Jungfrau mit furchterregenden spitzen, - - - - - - - - - - - - + + + + + + - - + @@ -119,10 +111,11 @@ An der Wand steht eine geöffnete eiserne Jungfrau mit furchterregenden spitzen, - + - - + + +