gehe funktioniert wieder.

hilfe Kommando.
This commit is contained in:
Olli Graf
2022-05-14 10:16:06 +02:00
parent 5b0b25cec1
commit 0a0ffcbc5f
5 changed files with 27 additions and 8 deletions

View File

@@ -87,7 +87,8 @@ class ActionModul:
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')
else:
self.setFehler('Das macht hier keinen Sinn.')
def baueBruecke(self):
@@ -102,7 +103,7 @@ class ActionModul:
if item != None:
del self.world.inventar[item.id]
if self.world.aktuellerRaum.id == self.world.RAUM_BACH:
if self.isAktuellerRaum(self.world.RAUM_BACH):
if item.id == self.world.ITEM_PLANKE:
baueBruecke()
self.setFehler('Du legst die Planke über den Bach und es ensteht eine Brücke über den Bach')
@@ -136,7 +137,7 @@ class ActionModul:
logging.debug(f'raumId {raum.id}')
logging.debug(f'untersucheAktuellenRaum() {parsedCommand.gegenstand} in {self.world.aktuellerRaum.id}')
if raum.id == self.world.aktuellerRaum.id:
if self.isAktuellerRaum(raum.id):
logging.debug(f'untersuche aktuellen Raum {raum.name}')
@@ -205,7 +206,7 @@ class ActionModul:
logging.debug(f'klettere(): Leiter is {leiter}')
if leiter != None:
if(self.world.aktuellerRaum.id == self.world.RAUM_ESSZIMMER):
if self.isAktuellerRaum(self.world.RAUM_ESSZIMMER):
logging.debug(f'aktuellerRaum ist {self.world.aktuellerRaum.id}')
self.rauf()
else:
@@ -237,7 +238,7 @@ class ActionModul:
self.insInventar(item)
logging.debug(f'nimm: RaumId== {self.world.aktuellerRaum.id}')
if self.world.aktuellerRaum.id == self.world.RAUM_BACH:
if self.isAktuellerRaum(self.world.RAUM_BACH):
logging.debug(f'nimm: ItemId == {item.id}')
if item.id == self.world.ITEM_PLANKE:
logging.debug('nehme Planke am Bach')
@@ -248,6 +249,9 @@ class ActionModul:
self.setFehler("diesen Gegenstand sehe ich hier nicht.")
def hilfe(self):
self.world.printText('hilfe')
def gehe(self,parsedCommand):
richtung = parsedCommand.gegenstand.lower()
logging.debug("gehe nach " + richtung)
@@ -260,6 +264,9 @@ class ActionModul:
self.west()
if richtung == 'ost':
self.ost()
if richtung == 'rauf':
self.rauf()
def geheNach(self,richtung):
logging.debug(f'geheNach() Richtung {richtung}')

View File

@@ -57,6 +57,10 @@ class TestModule:
#In den Flur
self.ac.ost()
pcmd = self.world.parseInput('untersuche Pflanze')
self.ac.untersuche(pcmd)
pcmd = self.world.parseInput('nimm Krug')
self.ac.nimm(pcmd)

View File

@@ -151,6 +151,7 @@ class World:
def ermittleBefehlId(self,befehl):
for id in self.befehle:
name = self.befehle[id].name
logging.debug(f'ermittleBefehlId(): {befehl} - {name}')
if name == befehl:
return id
return None

View File

@@ -54,6 +54,8 @@ def verarbeiteBefehl(parsedCommand):
actionmodul.klettere(parsedCommand)
elif id == '22':
actionmodul.fange(parsedCommand)
elif id == '23':
actionmodul.hilfe()
elif id == '-1':
world.fehler = 'Ich verstehe diesen Befehl nicht'
else:

View File

@@ -71,7 +71,7 @@
<command name='quit' id='0' key='0' />
<command name='ende' id='0' key='0' />
<command name='geh' id='1' key='1' />
<command name='gehe' id='26' key='1' />
<command name='gehe' id='27' key='1' />
<command name='nimm' id='2' key='2' />
<command name='untersuche' id='3' key='3' />
<command name='benutze' id='4' key='4' />
@@ -82,7 +82,6 @@
<command name='west' id='9' key='8' />
<command name='rauf' id='10' key='9' />
<command name='runter' id='11' key='10' />
<command name='gehe' id='12' key='11' />
<command name='inventar' id='13' key='12' />
<command name='about' id='14' key='13' />
<command name='verliere' id='15' key='14' />
@@ -97,7 +96,7 @@
<command name='öffne' id='23' key='20' />
<command name='klettere' id='24' key='21' />
<command name='fange' id='25' key='22' />
<command name='hilfe' id='28' key='23' />
</commandset>
<adjektive>
@@ -117,6 +116,7 @@
<sortout name='in' />
<sortout name='und' />
<sortout name='kleiner' />
<sortout name='nach' />
</sortouts>
<items>
<item name='Tisch' id='1' raum='1' imobil='true' adjektiv = '0' msgid='1' visible='true' />
@@ -176,5 +176,10 @@
Das Tor besteht aus schmideeisernen Stäben, die geschmiedete Querträger halten. Das Tor ist an den Seiten in Führungsschienen
eingelassen. Auf der rechten Seite befindet sich etwa in der Mitte ein Schloss. Hinter dem Tor scheint ein Treppenhaus zu sein.
</text>
<text id='hilfe'>
Das Grab des Azteken ist ein klassisches Textadventure.
Du bedienst es durch Befehle wie "nimm Schwert" oder "gehe Süd". Die Eingabe ist so flexibel wie möglich gestaltet, so dass
auch ganze Sätze wie "nimm das Schwert" verstanden werden.
</text>
</texte>
</welt>