benutze/klettere Leiter
findItemById() iteriert jetzt richtig übers Dictionary
This commit is contained in:
@@ -47,6 +47,12 @@ class ActionModul:
|
|||||||
|
|
||||||
if schluessel != None:
|
if schluessel != None:
|
||||||
item.zustand = item.OFFEN
|
item.zustand = item.OFFEN
|
||||||
|
seil = self.world.findItemById(self.world.ITEM_SEIL)
|
||||||
|
seil.sichtbar = True
|
||||||
|
self.world.aktuellerRaum.gegenstaende[seil.id] = seil
|
||||||
|
schwert = self.world.findItemById(self.world.ITEM_SCHWERT)
|
||||||
|
schwert.sichtbar = True
|
||||||
|
self.world.aktuellerRaum.gegenstaende[schwert.id] = schwert
|
||||||
self.setFehler('Truhe ist jetzt offen')
|
self.setFehler('Truhe ist jetzt offen')
|
||||||
else:
|
else:
|
||||||
self.setFehler('Die Truhe ist verschlossen und dir fehlt der passende Schlüssel.')
|
self.setFehler('Die Truhe ist verschlossen und dir fehlt der passende Schlüssel.')
|
||||||
@@ -65,6 +71,17 @@ class ActionModul:
|
|||||||
self.setFehler('Die Tür ist verschlossen.')
|
self.setFehler('Die Tür ist verschlossen.')
|
||||||
|
|
||||||
|
|
||||||
|
def benutze(self, parsedCommand):
|
||||||
|
leiter = self.world.findItemInAktuellerRaum(parsedCommand.gegenstand)
|
||||||
|
|
||||||
|
logging.debug(f'benutze(): Leiter is {leiter}')
|
||||||
|
if leiter != None:
|
||||||
|
if(self.world.aktuellerRaum.id == self.world.RAUM_ESSZIMMER):
|
||||||
|
logging.debug(f'aktuellerRaum ist {self.world.aktuellerRaum.id}')
|
||||||
|
self.rauf()
|
||||||
|
else:
|
||||||
|
self.setFehler('Eine Leiter sehe ich hier nicht.')
|
||||||
|
|
||||||
def verliere(self,parsedCommand):
|
def verliere(self,parsedCommand):
|
||||||
item = self.world.findItemImInventar(parsedCommand.gegenstand);
|
item = self.world.findItemImInventar(parsedCommand.gegenstand);
|
||||||
|
|
||||||
@@ -138,6 +155,10 @@ class ActionModul:
|
|||||||
self.setFehler('In der Schublade findest du einen Schlüssel')
|
self.setFehler('In der Schublade findest du einen Schlüssel')
|
||||||
schluessel = self.world.findRaumItemById(self.world.ITEM_HAUSTUERSCHLUESSEL)
|
schluessel = self.world.findRaumItemById(self.world.ITEM_HAUSTUERSCHLUESSEL)
|
||||||
schluessel.sichtbar = True
|
schluessel.sichtbar = True
|
||||||
|
elif item.id == self.world.ITEM_TEICH:
|
||||||
|
self.setFehler('Im Teich schwimmt ein kleiner Fish')
|
||||||
|
fisch = self.world.findItemInAktuellerRaum(self.world.ITEM_FISCH)
|
||||||
|
fisch.sichtbar = True
|
||||||
else:
|
else:
|
||||||
logging.debug('Kein Item gefunden, suche nach Raum')
|
logging.debug('Kein Item gefunden, suche nach Raum')
|
||||||
self.untersucheAktuellenRaum(parsedCommand)
|
self.untersucheAktuellenRaum(parsedCommand)
|
||||||
@@ -152,6 +173,21 @@ class ActionModul:
|
|||||||
else:
|
else:
|
||||||
self.setFehler('Das sehe ich hier nicht.')
|
self.setFehler('Das sehe ich hier nicht.')
|
||||||
|
|
||||||
|
def fange(self, parsedCommand):
|
||||||
|
skip
|
||||||
|
|
||||||
|
def klettere(self, parsedCommand):
|
||||||
|
leiter = self.world.findItemInAktuellerRaum(parsedCommand.gegenstand)
|
||||||
|
|
||||||
|
logging.debug(f'klettere(): Leiter is {leiter}')
|
||||||
|
if leiter != None:
|
||||||
|
if(self.world.aktuellerRaum.id == self.world.RAUM_ESSZIMMER):
|
||||||
|
logging.debug(f'aktuellerRaum ist {self.world.aktuellerRaum.id}')
|
||||||
|
self.rauf()
|
||||||
|
else:
|
||||||
|
self.setFehler('Eine Leiter sehe ich hier nicht.')
|
||||||
|
|
||||||
|
|
||||||
def nimm(self,parsedCommand):
|
def nimm(self,parsedCommand):
|
||||||
item = self.world.findItemInAktuellerRaum(parsedCommand.gegenstand)
|
item = self.world.findItemInAktuellerRaum(parsedCommand.gegenstand)
|
||||||
|
|
||||||
@@ -181,12 +217,18 @@ class ActionModul:
|
|||||||
self.setFehler("diesen Gegenstand sehe ich hier nicht.")
|
self.setFehler("diesen Gegenstand sehe ich hier nicht.")
|
||||||
|
|
||||||
|
|
||||||
def gehe(self):
|
def gehe(self,parsedCommand):
|
||||||
richtung = self.world.parsedCommand.gegenstand
|
richtung = parsedCommand.gegenstand.lower()
|
||||||
logging.debug("gehe nach " + richtung)
|
logging.debug("gehe nach " + richtung)
|
||||||
|
|
||||||
if richtung == 'nord':
|
if richtung == 'nord':
|
||||||
self.nord()
|
self.nord()
|
||||||
|
elif richtung == 'süd':
|
||||||
|
self.sued()
|
||||||
|
if richtung == 'west':
|
||||||
|
self.west()
|
||||||
|
if richtung == 'ost':
|
||||||
|
self.ost()
|
||||||
|
|
||||||
def geheNach(self,richtung):
|
def geheNach(self,richtung):
|
||||||
logging.debug(f'geheNach() Richtung {richtung}')
|
logging.debug(f'geheNach() Richtung {richtung}')
|
||||||
|
30
World.py
30
World.py
@@ -89,6 +89,16 @@ class World:
|
|||||||
return item
|
return item
|
||||||
|
|
||||||
|
|
||||||
|
def findItemById(self,id):
|
||||||
|
for itemkey in self.gegenstaende:
|
||||||
|
item = self.gegenstaende[itemkey]
|
||||||
|
logging.debug(f'findItemById(): Item= {item}')
|
||||||
|
logging.debug(f'findItemById(): Itemtype= {type(item)}')
|
||||||
|
if item.id == id:
|
||||||
|
return item
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
def findItemInAktuellerRaum(self,itemname):
|
def findItemInAktuellerRaum(self,itemname):
|
||||||
raum = self.aktuellerRaum
|
raum = self.aktuellerRaum
|
||||||
|
|
||||||
@@ -167,6 +177,19 @@ class World:
|
|||||||
|
|
||||||
return parsedCommand
|
return parsedCommand
|
||||||
|
|
||||||
|
def debug_Items(self):
|
||||||
|
logging.debug('liste Items')
|
||||||
|
logging.debug(self.gegenstaende)
|
||||||
|
count = 1
|
||||||
|
|
||||||
|
for key in self.gegenstaende:
|
||||||
|
item = self.gegenstaende[key]
|
||||||
|
|
||||||
|
logging.debug(f'count= {count}')
|
||||||
|
logging.debug('Itemtyp: ' + str(type(item)))
|
||||||
|
logging.debug(f'Item-IdId:{item.id} - Item-Name:{item.name}')
|
||||||
|
count = count +1
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.raumliste = {}
|
self.raumliste = {}
|
||||||
self.msg = {}
|
self.msg = {}
|
||||||
@@ -199,14 +222,17 @@ class World:
|
|||||||
self.ITEM_NACHTSCHRANK = '8'
|
self.ITEM_NACHTSCHRANK = '8'
|
||||||
self.ITEM_KLEINER_SCHLUESSEL = '9'
|
self.ITEM_KLEINER_SCHLUESSEL = '9'
|
||||||
self.ITEM_JACKE = '10'
|
self.ITEM_JACKE = '10'
|
||||||
self.ITEM_SCHWERT = '11'
|
|
||||||
self.ITEM_SEIL = '12'
|
self.ITEM_SEIL = '12'
|
||||||
self.ITEM_HAUSTUERSCHLUESSEL = '13'
|
self.ITEM_HAUSTUERSCHLUESSEL = '13'
|
||||||
self.ITEM_RANKGITTER = '14'
|
self.ITEM_RANKGITTER = '14'
|
||||||
self.ITEM_PLANKE = '15'
|
self.ITEM_PLANKE = '15'
|
||||||
|
self.ITEM_TEICH = '16'
|
||||||
|
self.ITEM_FISCH = '17'
|
||||||
|
self.ITEM_SCHWERT = '18'
|
||||||
|
|
||||||
# Räume
|
# Räume
|
||||||
|
|
||||||
|
self.RAUM_UNDEF = '-1'
|
||||||
self.RAUM_ESSZIMMER = '1'
|
self.RAUM_ESSZIMMER = '1'
|
||||||
self.RAUM_DACHBODEN = '2'
|
self.RAUM_DACHBODEN = '2'
|
||||||
self.RAUM_FLUR = '3'
|
self.RAUM_FLUR = '3'
|
||||||
@@ -222,3 +248,5 @@ class World:
|
|||||||
parser = WorldParser.WorldParser(self)
|
parser = WorldParser.WorldParser(self)
|
||||||
parser.parseWorld('world.xml')
|
parser.parseWorld('world.xml')
|
||||||
|
|
||||||
|
self.debug_Items()
|
||||||
|
|
||||||
|
@@ -100,13 +100,15 @@ class WorldParser():
|
|||||||
gegenstand.sichtbar = visible.lower() not in ['false','False','0']
|
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
|
gegenstand.pickupmsg = msgid
|
||||||
print('Item ' + gegenstand.name + ' - Pickup: ' + gegenstand.pickupmsg)
|
logging.debug('Item ' + gegenstand.name + ' - Pickup: ' + gegenstand.pickupmsg)
|
||||||
|
|
||||||
raum.items[id] = gegenstand
|
raum.items[id] = gegenstand
|
||||||
|
logging.debug(f'Hinzufügen Gegenstand vom Typ: {str(type(gegenstand))}')
|
||||||
self.world.gegenstaende[id] = gegenstand
|
self.world.gegenstaende[id] = gegenstand
|
||||||
else:
|
else:
|
||||||
logging.error(f'Kann Raum für Gegenstand {gegenstand.name} nicht finden')
|
if raum != '-1':
|
||||||
print(f'Kein Raum für {gegenstand.name}')
|
logging.error(f'Kann Raum für Gegenstand {gegenstand.name} nicht finden')
|
||||||
|
logging.error(f'Kein Raum für {gegenstand.name}')
|
||||||
|
|
||||||
# Personen
|
# Personen
|
||||||
for item in root.findall('personen/person'):
|
for item in root.findall('personen/person'):
|
||||||
|
19
tomb.py
19
tomb.py
@@ -19,6 +19,8 @@ def verarbeiteBefehl(parsedCommand):
|
|||||||
actionmodul.nimm(parsedCommand)
|
actionmodul.nimm(parsedCommand)
|
||||||
elif id == '3':
|
elif id == '3':
|
||||||
actionmodul.untersuche(parsedCommand)
|
actionmodul.untersuche(parsedCommand)
|
||||||
|
elif id == '4':
|
||||||
|
actionmodul.benutze(parsedCommand)
|
||||||
elif id == '5':
|
elif id == '5':
|
||||||
actionmodul.nord()
|
actionmodul.nord()
|
||||||
elif id == '6':
|
elif id == '6':
|
||||||
@@ -49,6 +51,8 @@ def verarbeiteBefehl(parsedCommand):
|
|||||||
actionmodul.oeffne(parsedCommand)
|
actionmodul.oeffne(parsedCommand)
|
||||||
elif id == '21':
|
elif id == '21':
|
||||||
actionmodul.klettere(parsedCommand)
|
actionmodul.klettere(parsedCommand)
|
||||||
|
elif id == '22':
|
||||||
|
actionmodul.fange(parsedCommand)
|
||||||
elif id == '-1':
|
elif id == '-1':
|
||||||
world.fehler = 'Ich verstehe diesen Befehl nicht'
|
world.fehler = 'Ich verstehe diesen Befehl nicht'
|
||||||
else:
|
else:
|
||||||
@@ -86,10 +90,7 @@ def inputLoop(stdscr):
|
|||||||
logging.debug(f'debugcommand: {debugcommand}')
|
logging.debug(f'debugcommand: {debugcommand}')
|
||||||
|
|
||||||
if debugcommand[1] == 'items':
|
if debugcommand[1] == 'items':
|
||||||
logging.debug('liste Items')
|
world.debug_Items()
|
||||||
logging.debug(world.gegenstaende)
|
|
||||||
for item in world.gegenstaende:
|
|
||||||
logging.debug(f'Id:{item.id} - Name:{item.name}')
|
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@@ -99,4 +100,14 @@ def inputLoop(stdscr):
|
|||||||
schrittzaehler = schrittzaehler +1
|
schrittzaehler = schrittzaehler +1
|
||||||
actionmodul.raumaction()
|
actionmodul.raumaction()
|
||||||
|
|
||||||
|
def debug_Items():
|
||||||
|
logging.debug('liste Items')
|
||||||
|
logging.debug(world.gegenstaende)
|
||||||
|
count = 0
|
||||||
|
for item in world.gegenstaende:
|
||||||
|
logging.debug(f'count= {count}')
|
||||||
|
logging.debug('Itemtyp: ' + str(type(item)))
|
||||||
|
# logging.debug(f'Item-IdId:{item.id} - Item-Name:{item.name}')
|
||||||
|
count = count +1
|
||||||
|
|
||||||
wrapper(inputLoop)
|
wrapper(inputLoop)
|
||||||
|
@@ -71,6 +71,7 @@
|
|||||||
<command name='quit' id='0' key='0' />
|
<command name='quit' id='0' key='0' />
|
||||||
<command name='ende' id='0' key='0' />
|
<command name='ende' id='0' key='0' />
|
||||||
<command name='geh' id='1' key='1' />
|
<command name='geh' id='1' key='1' />
|
||||||
|
<command name='gehe' id='26' key='1' />
|
||||||
<command name='nimm' id='2' key='2' />
|
<command name='nimm' id='2' key='2' />
|
||||||
<command name='untersuche' id='3' key='3' />
|
<command name='untersuche' id='3' key='3' />
|
||||||
<command name='benutze' id='4' key='4' />
|
<command name='benutze' id='4' key='4' />
|
||||||
@@ -95,6 +96,7 @@
|
|||||||
<command name='stell' id='22' key='19' />
|
<command name='stell' id='22' key='19' />
|
||||||
<command name='öffne' id='23' key='20' />
|
<command name='öffne' id='23' key='20' />
|
||||||
<command name='klettere' id='24' key='21' />
|
<command name='klettere' id='24' key='21' />
|
||||||
|
<command name='fange' id='25' key='22' />
|
||||||
|
|
||||||
</commandset>
|
</commandset>
|
||||||
|
|
||||||
@@ -128,10 +130,13 @@
|
|||||||
<item name='Schlüssel' id='9' raum='5' imobil='false' adjektiv = '1' msgid='1' visible='false' />
|
<item name='Schlüssel' id='9' raum='5' imobil='false' adjektiv = '1' msgid='1' visible='false' />
|
||||||
<item name='Jacke' id='10' raum='5' imobil='false' adjektiv = '0' msgid='1' visible='true' />
|
<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='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='Seil' id='12' raum='-1' imobil='false' adjektiv = '0' msgid='1' visible='false' />
|
||||||
<item name='Haustürschlüssel' id='13' raum='4' imobil='false' adjektiv = '0' msgid='1' visible='false' />
|
<item name='Haustürschlüssel' id='13' raum='4' imobil='false' adjektiv = '0' msgid='1' visible='false' />
|
||||||
<item name='Rankgitter' id='14' raum='6' imobil='false' adjektiv = '0' msgid='3' visible='true' />
|
<item name='Rankgitter' id='14' raum='6' imobil='false' adjektiv = '0' msgid='3' visible='true' />
|
||||||
<item name='Planke' id='15' raum='7' imobil='false' adjektiv = '0' msgid='3' visible='true' />
|
<item name='Planke' id='15' raum='7' imobil='false' adjektiv = '0' msgid='3' visible='true' />
|
||||||
|
<item name='Teich' id='16' raum='9' imobil='true' adjektiv = '0' msgid='2' visible='true' />
|
||||||
|
<item name='Fisch' id='17' raum='9' imobil='false' adjektiv = '0' msgid='0' visible='false' />
|
||||||
|
<item name='Schwert' id='18' raum='-1' imobil='false' adjektiv = '0' msgid='1' visible='false' />
|
||||||
|
|
||||||
</items>
|
</items>
|
||||||
<personen>
|
<personen>
|
||||||
@@ -142,7 +147,7 @@
|
|||||||
</personen>
|
</personen>
|
||||||
<messages>
|
<messages>
|
||||||
<pickup text='Das ist zu schwer' id='1' />
|
<pickup text='Das ist zu schwer' id='1' />
|
||||||
<pickup text='Daran sind soviel Körperflüssigkeiten runtergelaufen, du möchtest das nicht anfassen' id='2' />
|
<pickup text='Das kannst du nicht mitnehmen' id='2' />
|
||||||
<pickup text='Das ist fest verschraubt' id ='3' />
|
<pickup text='Das ist fest verschraubt' id ='3' />
|
||||||
<pickup text='Daran hebst du dir nur nen Bruch' id='4' />
|
<pickup text='Daran hebst du dir nur nen Bruch' id='4' />
|
||||||
<pickup text='Die Eingangstür ist nicht zum Mitnehmen gedacht.' id='5' />
|
<pickup text='Die Eingangstür ist nicht zum Mitnehmen gedacht.' id='5' />
|
||||||
|
Reference in New Issue
Block a user