Das Inventar ist jetzt immer zu sehen.
This commit is contained in:
@@ -45,7 +45,7 @@ class ActionModul:
|
||||
logging.debug('öffne Truhe')
|
||||
schluessel = self.world.findItemImInventarById(self.world.ITEM_KLEINER_SCHLUESSEL)
|
||||
|
||||
if schluessel != None:
|
||||
if schluessel != None and item.zustand != item.OFFEN:
|
||||
item.zustand = item.OFFEN
|
||||
seil = self.world.findItemById(self.world.ITEM_SEIL)
|
||||
seil.sichtbar = True
|
||||
@@ -53,7 +53,7 @@ class ActionModul:
|
||||
schwert = self.world.findItemById(self.world.ITEM_SCHWERT)
|
||||
schwert.sichtbar = True
|
||||
self.world.aktuellerRaum.items[schwert.id] = schwert
|
||||
self.setFehler('Truhe ist jetzt offen')
|
||||
self.setFehler('Aus der Truhe fallen ein Seil und ein Schwert.')
|
||||
else:
|
||||
self.setFehler('Die Truhe ist verschlossen und dir fehlt der passende Schlüssel.')
|
||||
|
||||
@@ -70,17 +70,29 @@ class ActionModul:
|
||||
logging.debug('öffne Haustür kein Haustürschlüssel')
|
||||
self.setFehler('Die Tür ist verschlossen.')
|
||||
|
||||
def isAktuellerRaum(self, raumid):
|
||||
return self.world.aktuellerRaum.id == raumid
|
||||
|
||||
def benutze(self, parsedCommand):
|
||||
leiter = self.world.findItemInAktuellerRaum(parsedCommand.gegenstand)
|
||||
item = self.world.findItemImInventarOderAktuellerRaum(parsedCommand.gegenstand);
|
||||
|
||||
logging.debug(f'benutze(): Leiter is {leiter}')
|
||||
if leiter != None:
|
||||
if item.id ==self.world.ITEM_JACKE:
|
||||
self.setFehler('Also du die Jacke anziehst, findest du einen kleine Schlüssel in der Tasche.')
|
||||
self.findeTruhenschluessel()
|
||||
elif item.id == self.world.ITEM_LEITER:
|
||||
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.')
|
||||
elif item.id == self.world.ITEM_PLANKE:
|
||||
if self.isAktuellerRaum(self.world.RAUM_BACH):
|
||||
baueBruecke()
|
||||
self.setFehler('Du legst die Planke über den Bach und es ensteht eine Brücke über den Bach')
|
||||
|
||||
|
||||
|
||||
def baueBruecke(self):
|
||||
bach = self.world.sucheRaum(self.world.RAUM_BACH)
|
||||
bach.ausgaenge[self.world.SUED] = self.world.RAUM_TEICH
|
||||
|
||||
def verliere(self,parsedCommand):
|
||||
item = self.world.findItemImInventar(parsedCommand.gegenstand);
|
||||
@@ -92,7 +104,7 @@ class ActionModul:
|
||||
|
||||
if self.world.aktuellerRaum.id == self.world.RAUM_BACH:
|
||||
if item.id == self.world.ITEM_PLANKE:
|
||||
self.world.aktuellerRaum.ausgaenge[self.world.SUED] = self.world.RAUM_TEICH
|
||||
baueBruecke()
|
||||
self.setFehler('Du legst die Planke über den Bach und es ensteht eine Brücke über den Bach')
|
||||
|
||||
self.world.aktuellerRaum.items[item.id] = item
|
||||
@@ -112,7 +124,7 @@ class ActionModul:
|
||||
|
||||
if item != None:
|
||||
logging.debug('stelle() item.id=' + str(item.id))
|
||||
if item.id == self.world.ITEM_GLAS:
|
||||
if item.id == self.world.ITEM_KRUG:
|
||||
self.world.aktuellerRaum.ausgaenge[self.world.NORD] = '5'
|
||||
self.verliere(parsedCommand)
|
||||
self.world.printText('1')
|
||||
@@ -126,27 +138,33 @@ class ActionModul:
|
||||
logging.debug(f'untersucheAktuellenRaum() {parsedCommand.gegenstand} in {self.world.aktuellerRaum.id}')
|
||||
if raum.id == self.world.aktuellerRaum.id:
|
||||
logging.debug(f'untersuche aktuellen Raum {raum.name}')
|
||||
if raum.id == '5':
|
||||
#Schlüssel im Keller sichtbar machen
|
||||
logging.debug('mache Schlüssel sichtbar')
|
||||
self.setFehler('Auf dem Boden findest du einen kleinen Schlüssel.')
|
||||
schluessel = self.world.findRaumItemById(self.world.ITEM_KLEINER_SCHLUESSEL)
|
||||
schluessel.sichtbar = True
|
||||
|
||||
|
||||
def findeTruhenschluessel(self):
|
||||
schluessel = self.world.findItemById(self.world.ITEM_KLEINER_SCHLUESSEL)
|
||||
|
||||
logging.debug(f'Schlüssel ist sichtbar {schluessel.sichtbar}')
|
||||
if not schluessel.sichtbar:
|
||||
logging.debug('mache Schlüssel sichtbar')
|
||||
self.setFehler('In der Jackentasche findest du einen kleinen Schlüssel.')
|
||||
schluessel.sichtbar = True
|
||||
self.insInventar(schluessel)
|
||||
|
||||
|
||||
def untersuche(self,parsedCommand):
|
||||
logging.debug(f'untersuche() suche nach Gegenstand: {parsedCommand.gegenstand}')
|
||||
if parsedCommand.gegenstand == None:
|
||||
self.untersucheAktuellenRaum
|
||||
self.untersucheAktuellenRaum()
|
||||
return
|
||||
|
||||
item = self.world.findItemImInventarOderAktuellerRaum(parsedCommand.gegenstand)
|
||||
|
||||
if item != None:
|
||||
if item.id == self.world.ITEM_PFLANZE:
|
||||
glas = self.world.findRaumItemById(self.world.ITEM_GLAS)
|
||||
logging.debug(f'mache Gegenstand {glas.name} sichtbar')
|
||||
glas.sichtbar = True
|
||||
krug = self.world.findRaumItemById(self.world.ITEM_KRUG)
|
||||
logging.debug(f'mache Gegenstand {krug.name} sichtbar')
|
||||
krug.sichtbar = True
|
||||
self.setFehler('Die Pflanze ist in einen Krug gepflanzt.')
|
||||
elif item.id == self.world.ITEM_BETT:
|
||||
# Falltür sichtbar machen
|
||||
self.world.aktuellerRaum.ausgaenge[self.world.RUNTER] = self.world.RAUM_KELLER
|
||||
@@ -160,6 +178,11 @@ class ActionModul:
|
||||
self.setFehler('Im Teich schwimmt ein kleiner Fish')
|
||||
fisch = self.world.findItemInAktuellerRaum(self.world.ITEM_FISCH)
|
||||
fisch.sichtbar = True
|
||||
elif item.id == self.world.ITEM_JACKE:
|
||||
self.findeTruhenschluessel()
|
||||
|
||||
|
||||
|
||||
else:
|
||||
logging.debug('Kein Item gefunden, suche nach Raum')
|
||||
self.untersucheAktuellenRaum(parsedCommand)
|
||||
@@ -188,6 +211,10 @@ class ActionModul:
|
||||
else:
|
||||
self.setFehler('Eine Leiter sehe ich hier nicht.')
|
||||
|
||||
def insInventar(self, item):
|
||||
logging.debug(f'neu ins Inventar: {item.name}')
|
||||
self.world.inventar[item.id] = item
|
||||
|
||||
|
||||
def nimm(self,parsedCommand):
|
||||
item = self.world.findItemInAktuellerRaum(parsedCommand.gegenstand)
|
||||
@@ -203,8 +230,11 @@ class ActionModul:
|
||||
text = self.world.msg[item.pickupmsg]
|
||||
self.setFehler(text)
|
||||
else:
|
||||
logging.debug(f'Item {item.name} aus aktuellem Raum entfernen')
|
||||
del self.world.aktuellerRaum.items[item.id]
|
||||
self.world.inventar[item.id] = item
|
||||
logging.debug(f'Item {item.name} ins Inventar')
|
||||
|
||||
self.insInventar(item)
|
||||
|
||||
logging.debug(f'nimm: RaumId== {self.world.aktuellerRaum.id}')
|
||||
if self.world.aktuellerRaum.id == self.world.RAUM_BACH:
|
||||
|
@@ -7,40 +7,60 @@ class TestModule:
|
||||
|
||||
logging.debug(f'** init Testmodule {world}')
|
||||
self.world = world
|
||||
self.actionmodul = ActionModul.ActionModul(world)
|
||||
self.ac = ActionModul.ActionModul(world)
|
||||
|
||||
def debug(self,msg):
|
||||
logging.debug(f'AUTO: {msg}')
|
||||
|
||||
def testOeffneTruhe(self):
|
||||
|
||||
pcmd = self.world.parseInput('nimm Truhe')
|
||||
#Auf den Dachboden
|
||||
self.actionmodul.rauf()
|
||||
self.actionmodul.nimm(pcmd)
|
||||
self.ac.rauf()
|
||||
self.ac.nimm(pcmd)
|
||||
|
||||
#Zurück ins Wohnzimmer
|
||||
self.actionmodul.runter()
|
||||
self.ac.runter()
|
||||
#In den Flur
|
||||
self.actionmodul.sued()
|
||||
self.ac.sued()
|
||||
# Ins Schlafzimmer
|
||||
self.actionmodul.west()
|
||||
self.ac.west()
|
||||
self.debug(f'aktueller Raum: {self.world.aktuellerRaum.name}')
|
||||
self.debug(f'Ausgänge: {self.world.aktuellerRaum.ausgaenge}')
|
||||
pcmd = self.world.parseInput('untersuche Bett')
|
||||
|
||||
self.actionmodul.untersuche(pcmd)
|
||||
self.ac.untersuche(pcmd)
|
||||
|
||||
self.debug(f'Ausgänge: {self.world.aktuellerRaum.ausgaenge}')
|
||||
# In den Keller
|
||||
self.actionmodul.runter()
|
||||
pcmd = self.world.parseInput('untersuche Keller')
|
||||
|
||||
self.actionmodul.untersuche(pcmd)
|
||||
pcmd = self.world.parseInput('nimm Schlüssel')
|
||||
self.actionmodul.nimm(pcmd)
|
||||
self.ac.runter()
|
||||
pcmd = self.world.parseInput('nimm Jacke')
|
||||
self.ac.nimm(pcmd)
|
||||
pcmd = self.world.parseInput('benutze Jacke')
|
||||
self.ac.benutze(pcmd)
|
||||
pcmd = self.world.parseInput('öffne Truhe')
|
||||
self.actionmodul.oeffne(pcmd)
|
||||
self.ac.oeffne(pcmd)
|
||||
|
||||
def testTeich(self):
|
||||
self.testOeffneTruhe()
|
||||
pcmd = self.world.parseInput('nimm Seil')
|
||||
self.ac.nimm(pcmd)
|
||||
pcmd = self.world.parseInput('nimm Schwert')
|
||||
self.ac.nimm(pcmd)
|
||||
|
||||
#Rauf ins Schlafzimmer
|
||||
self.ac.rauf()
|
||||
|
||||
pcmd = self.world.parseInput('untersuche Nachtschrank')
|
||||
self.ac.untersuche(pcmd)
|
||||
pcmd = self.world.parseInput('nimm Haustürschlüssel')
|
||||
self.ac.nimm(pcmd)
|
||||
|
||||
#In den Flur
|
||||
self.ac.ost()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
18
World.py
18
World.py
@@ -23,6 +23,15 @@ class World:
|
||||
self.stdscr.getch()
|
||||
|
||||
|
||||
def labelsInventar(self):
|
||||
labels =[]
|
||||
|
||||
for itemid in self.inventar:
|
||||
item = self.inventar[itemid]
|
||||
if item.sichtbar:
|
||||
labels.append(item.name)
|
||||
|
||||
return labels
|
||||
def printRaum(self):
|
||||
raum = self.aktuellerRaum
|
||||
self.clearScreen()
|
||||
@@ -33,11 +42,12 @@ class World:
|
||||
self.stdscr.addstr(3,0,'aktueller Raum: ' + raum.name,curses.color_pair(3))
|
||||
self.stdscr.addstr(4,0,raum.beschreibung)
|
||||
self.stdscr.addstr(7,0,'Gegenstände: ' + str(raum.labelsGegenstaende()),curses.color_pair(2))
|
||||
self.stdscr.addstr(8,0,'Personen: ' + str(raum.labelsPersonen()),curses.color_pair(2))
|
||||
self.stdscr.addstr(8,0,'Inventar: '+ str(self.labelsInventar()), curses.color_pair(2))
|
||||
self.stdscr.addstr(9,0,'Personen: ' + str(raum.labelsPersonen()),curses.color_pair(2))
|
||||
|
||||
|
||||
aus = raum.ausgaenge
|
||||
self.stdscr.addstr(9,0,'mögliche Richtungen: ')
|
||||
self.stdscr.addstr(10,0,'mögliche Richtungen: ')
|
||||
r = []
|
||||
if aus[self.NORD] != '-1':
|
||||
r.append('Norden')
|
||||
@@ -63,7 +73,7 @@ class World:
|
||||
if ixri +1 < len(r):
|
||||
richtungen = richtungen + ', '
|
||||
ixri = ixri +1
|
||||
self.stdscr.addstr(9,22,richtungen)
|
||||
self.stdscr.addstr(10,22,richtungen)
|
||||
self.stdscr.refresh()
|
||||
win.refresh()
|
||||
|
||||
@@ -221,7 +231,7 @@ class World:
|
||||
self.ITEM_TRUHE = '3'
|
||||
self.ITEM_PFLANZE = '4'
|
||||
self.ITEM_HAUSTUER = '5'
|
||||
self.ITEM_GLAS = '6'
|
||||
self.ITEM_KRUG = '6'
|
||||
self.ITEM_BETT = '7'
|
||||
self.ITEM_NACHTSCHRANK = '8'
|
||||
self.ITEM_KLEINER_SCHLUESSEL = '9'
|
||||
|
2
tomb.py
2
tomb.py
@@ -102,6 +102,8 @@ def inputLoop(stdscr):
|
||||
|
||||
if(debugcommand[1] == 'truhe'):
|
||||
testmodul.testOeffneTruhe()
|
||||
elif debugcommand[1] == 'teich':
|
||||
testmodul.testTeich()
|
||||
|
||||
|
||||
else:
|
||||
|
@@ -124,10 +124,10 @@
|
||||
<item name='Truhe' id='3' raum='2' imobil='false' adjektiv = '0' msgid='4' visible='true' />
|
||||
<item name='Pflanze' id='4' raum='3' imobil='false' adjektiv = '0' msgid='3' visible='true' />
|
||||
<item name='Haustür' id='5' raum='3' imobil='true' adjektiv = '0' msgid='5' visible='true' />
|
||||
<item name='Glas' id='6' raum='3' imobil='false' adjektiv = '0' msgid='3' visible='false' />
|
||||
<item name='Krug' id='6' raum='3' imobil='false' adjektiv = '0' msgid='3' visible='false' />
|
||||
<item name='Bett' id='7' raum='4' imobil='true' adjektiv = '0' msgid='1' visible=' true' />
|
||||
<item name='Nachtschrank' id='8' raum='4' imobil='true' adjektiv = '0' msgid='1' visible=' true' />
|
||||
<item name='Schlüssel' id='9' raum='5' imobil='false' adjektiv = '1' msgid='1' visible='false' />
|
||||
<item name='Schlüssel' id='9' raum='-1' 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='Schwert' id='11' 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' />
|
||||
|
Reference in New Issue
Block a user