Raumkonstanten.

This commit is contained in:
Olli Graf
2022-04-27 08:25:18 +02:00
parent 0ded3de76e
commit 71e76c957e
5 changed files with 40 additions and 10 deletions

View File

@@ -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:

View File

@@ -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')

View File

@@ -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)

23
tomb.py
View File

@@ -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)

View File

@@ -118,7 +118,7 @@
<item name='Jacke' id='10' raum='5' imobil='false' adjektiv = '0' msgid='1' visible='true' />
<item name='Schwert' id='11' raum='5' imobil='false' adjektiv = '0' msgid='1' visible='false' />
<item name='Seil' id='12' raum='5' imobil='false' adjektiv = '0' msgid='1' visible='false' />
<item name='Schlüssel' id='13' raum='5' imobil='false' adjektiv = '0' msgid='1' visible='false' />
<item name='Haustürschlüssel' id='13' raum='5' imobil='false' adjektiv = '0' msgid='1' visible='false' />
</items>
<personen>