Jacke dupliziert sich beim Werfen nicht mehr.
This commit is contained in:
@@ -9,6 +9,11 @@ class ActionBasics:
|
|||||||
def debug(self, method, text):
|
def debug(self, method, text):
|
||||||
logging.debug(f'ActionBasics: {text}')
|
logging.debug(f'ActionBasics: {text}')
|
||||||
|
|
||||||
|
def ausDemInventar(self,item):
|
||||||
|
del self.world.inventar[item.id]
|
||||||
|
self.world.aktuellerRaum.items[item.id] = item
|
||||||
|
item.raumid = self.world.aktuellerRaum.id
|
||||||
|
|
||||||
def insInventar(self, item):
|
def insInventar(self, item):
|
||||||
logging.debug(f'neu ins Inventar: {item.name}')
|
logging.debug(f'neu ins Inventar: {item.name}')
|
||||||
self.world.inventar[item.id] = item
|
self.world.inventar[item.id] = item
|
||||||
@@ -19,6 +24,9 @@ class ActionBasics:
|
|||||||
def clearFehler(self):
|
def clearFehler(self):
|
||||||
self.world.fehler = ''
|
self.world.fehler = ''
|
||||||
|
|
||||||
|
def liegtItemInRaum(self,itemid, raum):
|
||||||
|
return itemid in raum.items
|
||||||
|
|
||||||
def moveItemVonRaumNachInventar(self,item):
|
def moveItemVonRaumNachInventar(self,item):
|
||||||
logging.debug(f'entferne aus aktuellen Raum {item.name}')
|
logging.debug(f'entferne aus aktuellen Raum {item.name}')
|
||||||
del self.world.aktuellerRaum.items[item.id]
|
del self.world.aktuellerRaum.items[item.id]
|
||||||
@@ -26,8 +34,12 @@ class ActionBasics:
|
|||||||
self.insInventar(item)
|
self.insInventar(item)
|
||||||
|
|
||||||
def moveItemVonInventarNachRaum(self,item, nachRaumId):
|
def moveItemVonInventarNachRaum(self,item, nachRaumId):
|
||||||
self.ausDemInventar(item)
|
del self.world.inventar[item.id]
|
||||||
|
logging.debug(f' Item {item.name} nach RaumId {nachRaumId}')
|
||||||
raum = self.world.findRaumById(nachRaumId)
|
raum = self.world.findRaumById(nachRaumId)
|
||||||
|
logging.debug(f' Item {item.name} liegt jetzt in Raum {raum.name}')
|
||||||
|
logging.debug(f'{item.name} liegt im {raum.name}: {self.liegtItemInRaum(item.id, raum)}')
|
||||||
|
logging.debug(f'{item.name} liegt im {self.world.aktuellerRaum.name}: {self.liegtItemInRaum(item.id, self.world.aktuellerRaum)}')
|
||||||
raum.items[item.id] = item
|
raum.items[item.id] = item
|
||||||
item.raumid = nachRaumId
|
item.raumid = nachRaumId
|
||||||
|
|
||||||
|
@@ -89,16 +89,16 @@ class ActionModul(ActionBasics):
|
|||||||
elif item.id == self.world.ITEM_GATTER:
|
elif item.id == self.world.ITEM_GATTER:
|
||||||
logging.debug('Gatter öffnen')
|
logging.debug('Gatter öffnen')
|
||||||
if self.isAktuellerRaum(self.world.RAUM_WIESE):
|
if self.isAktuellerRaum(self.world.RAUM_WIESE):
|
||||||
stier = self.world.findPersonImAktuellenRaum(self.world.PERSON_STIER)
|
stier = self.world.findPersonImAktuellenRaumById(self.world.PERSON_STIER)
|
||||||
|
|
||||||
logging.debug('Stier ist {stier}')
|
logging.debug(f'Stier ist {stier}')
|
||||||
|
|
||||||
if stier != None:
|
if stier == None:
|
||||||
item.zustand = item.OFFEN
|
item.zustand = item.OFFEN
|
||||||
self.macheWegFrei(self.world.SUED,self.world.RAUM_BRACHLAND)
|
self.macheWegFrei(self.world.SUED,self.world.RAUM_BRACHLAND)
|
||||||
self.setFehler('Das Gatter steht offen.')
|
self.setFehler('Das Gatter steht offen.')
|
||||||
else:
|
else:
|
||||||
self.setFehler(f'Der {stier.name} steht dir im Weg.')
|
self.setFehler(f'Der Stier steht dir im Weg.')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -194,10 +194,23 @@ class ActionModul(ActionBasics):
|
|||||||
if self.isAktuellerRaum(self.world.RAUM_BRACHLAND):
|
if self.isAktuellerRaum(self.world.RAUM_BRACHLAND):
|
||||||
if item.zustand == item.VOLL:
|
if item.zustand == item.VOLL:
|
||||||
ranke = self.world.findItemById(self.world.ITEM_BOHNENRANKE)
|
ranke = self.world.findItemById(self.world.ITEM_BOHNENRANKE)
|
||||||
|
fisch = self.world.findItemImInventarById(self.world.ITEM_FISCH)
|
||||||
|
|
||||||
|
logging.debug(f'Fisch ist {fisch}')
|
||||||
|
|
||||||
|
if fisch != None:
|
||||||
|
logging.debug('Krug leeren löst den Fisch auf.')
|
||||||
|
self.vanishItem(fisch)
|
||||||
|
self.setFehler('Der Fisch löst sich auf.')
|
||||||
|
|
||||||
if ranke.zustand < ranke.GROSS:
|
if ranke.zustand < ranke.GROSS:
|
||||||
ranke.zustand = ranke.zustand +1
|
ranke.zustand = ranke.zustand +1
|
||||||
self.setFehler('Die Bohnenranke wächst.')
|
meldung = 'Die Bohnenranke wächst.'
|
||||||
|
|
||||||
|
if fisch != None:
|
||||||
|
meldung = meldung + ' Der Fisch löst sich auf.'
|
||||||
|
|
||||||
|
self.setFehler(meldung)
|
||||||
if ranke.zustand == ranke.GROSS:
|
if ranke.zustand == ranke.GROSS:
|
||||||
self.world.aktuellerRaum.ausgaenge[self.world.RAUF] = self.world.RAUM_BOHNENRANKE
|
self.world.aktuellerRaum.ausgaenge[self.world.RAUF] = self.world.RAUM_BOHNENRANKE
|
||||||
self.setFehler('Die Bohnenranke reicht jetzt bis in die Wolken hinein.')
|
self.setFehler('Die Bohnenranke reicht jetzt bis in die Wolken hinein.')
|
||||||
@@ -309,7 +322,7 @@ class ActionModul(ActionBasics):
|
|||||||
self.setFehler('Der Elefant ist schon geflohen.')
|
self.setFehler('Der Elefant ist schon geflohen.')
|
||||||
else:
|
else:
|
||||||
self.setFehler('Das besitzt du nicht')
|
self.setFehler('Das besitzt du nicht')
|
||||||
elif self.isAktuellerRaum(self.world.RAUM_WIESE):
|
elif self.isItemAndAktRaum(item, self.world.ITEM_JACKE, self.world.RAUM_WIESE):
|
||||||
logging.debug('Jackenwurf')
|
logging.debug('Jackenwurf')
|
||||||
stier = self.world.findPersonImAktuellenRaumById(self.world.PERSON_STIER)
|
stier = self.world.findPersonImAktuellenRaumById(self.world.PERSON_STIER)
|
||||||
jacke = self.world.findItemImInventarById(self.world.ITEM_JACKE)
|
jacke = self.world.findItemImInventarById(self.world.ITEM_JACKE)
|
||||||
@@ -318,13 +331,18 @@ class ActionModul(ActionBasics):
|
|||||||
if stier != None:
|
if stier != None:
|
||||||
if jacke != None:
|
if jacke != None:
|
||||||
self.world.printText('jackewurf')
|
self.world.printText('jackewurf')
|
||||||
|
logging.debug(f'1:Jacke im Raum {self.liegtItemInRaum(jacke.id, self.world.aktuellerRaum)}')
|
||||||
self.personVonRaumNachRaum(stier,self.world.aktuellerRaum.id, self.world.RAUM_FELD)
|
self.personVonRaumNachRaum(stier,self.world.aktuellerRaum.id, self.world.RAUM_FELD)
|
||||||
|
logging.debug(f'2:Jacke im Raum {self.liegtItemInRaum(jacke.id, self.world.aktuellerRaum)}')
|
||||||
self.moveItemVonInventarNachRaum(jacke, self.world.RAUM_FELD)
|
self.moveItemVonInventarNachRaum(jacke, self.world.RAUM_FELD)
|
||||||
|
logging.debug(f'3:Jacke im Raum {self.liegtItemInRaum(jacke.id, self.world.aktuellerRaum)}')
|
||||||
else:
|
else:
|
||||||
self.setFehler('Die trägst du nicht bei dir.')
|
self.setFehler('Die trägst du nicht bei dir.')
|
||||||
else:
|
else:
|
||||||
|
logging.debug(f'verliere Jacke (kein Stier)')
|
||||||
self.verliere(parsedCommand)
|
self.verliere(parsedCommand)
|
||||||
else:
|
else:
|
||||||
|
logging.debug(f'verliere Jacke (falscher Raum, nicht Jacke)')
|
||||||
self.verliere(parsedCommand)
|
self.verliere(parsedCommand)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -18,6 +18,7 @@ class TestModule:
|
|||||||
return self.world.parseInput(command)
|
return self.world.parseInput(command)
|
||||||
|
|
||||||
def testOeffneTruhe(self):
|
def testOeffneTruhe(self):
|
||||||
|
logging.debug('===== Beginn Testmodul Truhe =====')
|
||||||
pcmd = self.parseInput('nimm Truhe')
|
pcmd = self.parseInput('nimm Truhe')
|
||||||
|
|
||||||
#Auf den Dachboden
|
#Auf den Dachboden
|
||||||
@@ -76,6 +77,7 @@ class TestModule:
|
|||||||
|
|
||||||
def testTeich(self):
|
def testTeich(self):
|
||||||
self.testOeffneTruhe()
|
self.testOeffneTruhe()
|
||||||
|
logging.debug('===== Beginn Testmodul Teich =====')
|
||||||
|
|
||||||
#Rauf ins Schlafzimmer
|
#Rauf ins Schlafzimmer
|
||||||
self.ac.rauf()
|
self.ac.rauf()
|
||||||
@@ -132,12 +134,16 @@ class TestModule:
|
|||||||
|
|
||||||
#Zum Teich
|
#Zum Teich
|
||||||
self.ac.ost()
|
self.ac.ost()
|
||||||
|
pcmd = self.parseInput('nimm Fisch')
|
||||||
|
self.ac.nimm(pcmd)
|
||||||
self.schrittzaehler += 1
|
self.schrittzaehler += 1
|
||||||
|
|
||||||
|
|
||||||
self.world.schrittzaehler = self.schrittzaehler
|
self.world.schrittzaehler = self.schrittzaehler
|
||||||
|
|
||||||
def testStier(self):
|
def testStier(self):
|
||||||
self.testTeich()
|
self.testTeich()
|
||||||
|
logging.debug('===== Beginn Testmodul Stier =====')
|
||||||
|
|
||||||
pcmd = self.parseInput('nimm Fisch')
|
pcmd = self.parseInput('nimm Fisch')
|
||||||
self.ac.nimm(pcmd)
|
self.ac.nimm(pcmd)
|
||||||
@@ -166,36 +172,29 @@ class TestModule:
|
|||||||
self.ac.west()
|
self.ac.west()
|
||||||
self.schrittzaehler += 1
|
self.schrittzaehler += 1
|
||||||
|
|
||||||
|
pcmd = self.parseInput('wirf Jacke')
|
||||||
|
self.ac.wirf(pcmd)
|
||||||
|
self.schrittzaehler += 1
|
||||||
|
|
||||||
|
#Feld
|
||||||
|
self.ac.ost()
|
||||||
|
self.schrittzaehler += 1
|
||||||
|
pcmd = self.parseInput('nimm Jacke')
|
||||||
|
self.ac.nimm(pcmd)
|
||||||
|
self.schrittzaehler += 1
|
||||||
|
|
||||||
|
# Auf die Wiese
|
||||||
|
self.ac.west()
|
||||||
|
self.schrittzaehler += 1
|
||||||
|
pcmd = self.parseInput('öffne Gatter')
|
||||||
|
self.ac.oeffne(pcmd)
|
||||||
|
self.schrittzaehler += 1
|
||||||
|
|
||||||
|
|
||||||
def testRanke(self):
|
def testRanke(self):
|
||||||
self.testTeich()
|
self.testStier()
|
||||||
|
|
||||||
pcmd = self.parseInput('nimm Fisch')
|
|
||||||
self.ac.nimm(pcmd)
|
|
||||||
|
|
||||||
# zum Bach
|
|
||||||
self.ac.west()
|
|
||||||
self.schrittzaehler += 1
|
|
||||||
|
|
||||||
|
|
||||||
#Aufs Feld
|
|
||||||
self.ac.sued()
|
|
||||||
self.schrittzaehler += 1
|
|
||||||
|
|
||||||
# Kleines Feld
|
|
||||||
self.ac.sued()
|
|
||||||
self.schrittzaehler += 1
|
|
||||||
|
|
||||||
pcmd = self.parseInput('nimm Maus')
|
|
||||||
self.ac.nimm(pcmd)
|
|
||||||
self.schrittzaehler += 1
|
|
||||||
|
|
||||||
self.ac.nord()
|
|
||||||
self.schrittzaehler += 1
|
|
||||||
|
|
||||||
# Auf die Wiese
|
|
||||||
self.ac.west()
|
|
||||||
self.schrittzaehler += 1
|
|
||||||
|
|
||||||
|
logging.debug('===== Beginn Testmodul Ranke =====')
|
||||||
|
|
||||||
# Aufs Brachland
|
# Aufs Brachland
|
||||||
self.ac.sued()
|
self.ac.sued()
|
||||||
|
4
World.py
4
World.py
@@ -183,6 +183,8 @@ class World:
|
|||||||
for persid in raum.personen:
|
for persid in raum.personen:
|
||||||
person = raum.personen[persid]
|
person = raum.personen[persid]
|
||||||
|
|
||||||
|
logging.debug(f'{person.id} - {personid}')
|
||||||
|
|
||||||
if person.id == personid:
|
if person.id == personid:
|
||||||
return person
|
return person
|
||||||
return None
|
return None
|
||||||
@@ -205,7 +207,7 @@ class World:
|
|||||||
def ermittleBefehlId(self,befehl):
|
def ermittleBefehlId(self,befehl):
|
||||||
for id in self.befehle:
|
for id in self.befehle:
|
||||||
name = self.befehle[id].name
|
name = self.befehle[id].name
|
||||||
logging.debug(f'{befehl} - {name}')
|
#logging.debug(f'{befehl} - {name}')
|
||||||
if name == befehl:
|
if name == befehl:
|
||||||
return id
|
return id
|
||||||
return None
|
return None
|
||||||
|
@@ -42,7 +42,7 @@ class Raum(SuperNode):
|
|||||||
|
|
||||||
for itemid in self.items:
|
for itemid in self.items:
|
||||||
item = self.items[itemid]
|
item = self.items[itemid]
|
||||||
logging.debug('labelsGegenstaende(): Item ' + self.items[itemid].name + ' ist ' + str(item.sichtbar))
|
#logging.debug('labelsGegenstaende(): Item ' + self.items[itemid].name + ' ist ' + str(item.sichtbar))
|
||||||
if item.sichtbar:
|
if item.sichtbar:
|
||||||
if item.display != None:
|
if item.display != None:
|
||||||
labels.append(item.display)
|
labels.append(item.display)
|
||||||
|
Binary file not shown.
12
tomb.py
12
tomb.py
@@ -154,19 +154,21 @@ def debug_Personen():
|
|||||||
|
|
||||||
def debug_Items():
|
def debug_Items():
|
||||||
logging.debug('liste Items')
|
logging.debug('liste Items')
|
||||||
logging.debug(world.gegenstaende)
|
logging.debug(world.aktuellerRaum.items)
|
||||||
count = 0
|
count = 0
|
||||||
for item in world.gegenstaende:
|
for itemid in world.aktuellerRaum.items:
|
||||||
|
item = world.aktuellerRaum.items[itemid]
|
||||||
logging.debug(f'count= {count}')
|
logging.debug(f'count= {count}')
|
||||||
logging.debug(f'Itemtyp: {type(item)}')
|
# logging.debug(f'Itemtyp: {type(item)}')
|
||||||
# logging.debug(f'Item-IdId:{item.id} - Item-Name:{item.name}')
|
logging.debug(f'Item-IdId:{item.id} - Item-Name:{item.name}')
|
||||||
count = count +1
|
count = count +1
|
||||||
|
|
||||||
def debug_Inventar():
|
def debug_Inventar():
|
||||||
logging.debug('liste Items')
|
logging.debug('liste Items')
|
||||||
logging.debug(world.inventar)
|
logging.debug(world.inventar)
|
||||||
count = 0
|
count = 0
|
||||||
for item in world.inventar:
|
for itemid in world.inventar:
|
||||||
|
item = world.inventar[itemid]
|
||||||
logging.debug(f'count= {count}')
|
logging.debug(f'count= {count}')
|
||||||
logging.debug(f'Itemtyp: {type(item)}')
|
logging.debug(f'Itemtyp: {type(item)}')
|
||||||
# logging.debug(f'Item-IdId:{item.id} - Item-Name:{item.name}')
|
# logging.debug(f'Item-IdId:{item.id} - Item-Name:{item.name}')
|
||||||
|
Reference in New Issue
Block a user