68 lines
1.8 KiB
Python
68 lines
1.8 KiB
Python
import logging
|
|
import inspect
|
|
|
|
class ActionBasics:
|
|
|
|
def __init__(self,world):
|
|
self.world = world
|
|
|
|
def debug(self, method, text):
|
|
logging.debug(f'ActionBasics: {text}')
|
|
|
|
def insInventar(self, item):
|
|
logging.debug(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):
|
|
logging.debug(f'entferne aus aktuellen Raum {item.name}')
|
|
del self.world.aktuellerRaum.items[item.id]
|
|
logging.debug(f'ins Inventar {item.name}')
|
|
self.insInventar(item)
|
|
|
|
def moveItemVonInventarNachRaum(self,item, nachRaumId):
|
|
self.ausDemInventar(item)
|
|
raum = self.world.findRaumById(nachRaumId)
|
|
raum.items[item.id] = item
|
|
item.raumid = nachRaumId
|
|
|
|
def isItemAndAktRaum(self,item, itemid, raumid):
|
|
isItem = self.isItem(item,itemid)
|
|
isRaum = self.isAktuellerRaum(raumid)
|
|
|
|
logging.debug(f'isItem={isItem}, isRaum={isRaum}')
|
|
return isItem and isRaum
|
|
|
|
def isItem(self, item, itemid):
|
|
return item.id == itemid
|
|
|
|
def macheWegFrei(self, richtung, raumid):
|
|
logging.debug(f'Richtung {richtung} führt jetzt zu RaumId {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]
|
|
logging.debug(f'{itemid} -{item.id}')
|
|
if item.id == itemid:
|
|
return item
|
|
return None
|
|
|
|
def personVonRaumNachRaum(self, person, vonRaumId, nachRaumId):
|
|
vonRaum = self.world.findRaumById(vonRaumId)
|
|
nachRaum = self.world.findRaumById(nachRaumId)
|
|
|
|
del vonRaum.personen[person.id]
|
|
nachRaum.personen[person.id] = person
|
|
person.raumid = nachRaumId
|
|
|
|
|
|
|