49 lines
1.3 KiB
Python
49 lines
1.3 KiB
Python
import logging
|
|
import inspect
|
|
|
|
class ActionBasics:
|
|
|
|
def __init__(self,world):
|
|
self.world = world
|
|
|
|
def debug(self, method, text):
|
|
logging.debug(f'ActionBasics#{method}: {text}')
|
|
|
|
def insInventar(self, item):
|
|
self.debug('insInventar()',f'neu ins Inventar: {item.name}')
|
|
self.world.inventar[item.id] = item
|
|
|
|
def setFehler(self,text):
|
|
self.world.fehler =text
|
|
|
|
def clearFehler(self):
|
|
self.world.fehler = ''
|
|
|
|
def moveItemVonRaumNachInventar(self,item):
|
|
self.debug('moveItemVonRaumNachInventar()',f'entferne aus aktuellen Raum {item.name}')
|
|
del self.world.aktuellerRaum.items[item.id]
|
|
self.debug('moveItemVonRaumNachInventar()',f'ins Inventar {item.name}')
|
|
self.insInventar(item)
|
|
|
|
def isItemAndAktRaum(self,item, itemid, raumid):
|
|
return self.isItem(item, itemid) and self.isAktuellerRaum(raumid)
|
|
|
|
def isItem(self, item, itemid):
|
|
return item.id == itemid
|
|
|
|
def macheWegFrei(self, richtung, raumid):
|
|
self.world.aktuellerRaum.ausgaenge[richtung] = raumid
|
|
|
|
def findItemInAktuellerRaumById(self, itemid):
|
|
for itemid in self.world.aktuellerRaum.items:
|
|
raum = self.world.aktuellerRaum
|
|
|
|
item = self.world.aktuellerRaum.items[itemid]
|
|
self.debug('findRaumItemById()',f'{itemid} -{item.id}')
|
|
if item.id == itemid:
|
|
return item
|
|
|
|
return None
|
|
|
|
|