Definition der Konstanten für Gegenstände.
Adjektivliste.
This commit is contained in:
@@ -24,6 +24,15 @@ class ActionModul:
|
||||
self.world.stdscr.addstr(zeile,0,item.name)
|
||||
zeile = zeile +1
|
||||
|
||||
def oeffne(self,parsedCommand):
|
||||
item = self.world.findItemImInventar(parsedCommand.gegenstand);
|
||||
|
||||
if item != None:
|
||||
if self.world.findItemImInventarById(13) != None:
|
||||
item.zustand = item.GEOEFFNET
|
||||
else:
|
||||
self.setFehler('Die Tür ist verschlossen.')
|
||||
|
||||
def verliere(self,parsedCommand):
|
||||
item = self.world.findItemImInventar(parsedCommand.gegenstand);
|
||||
|
||||
@@ -46,7 +55,7 @@ class ActionModul:
|
||||
|
||||
if item != None:
|
||||
logging.debug('stelle() item.id=' + str(item.id))
|
||||
if item.id == '6':
|
||||
if item.id == self.world.ITEM_GLAS:
|
||||
self.world.aktuellerRaum.ausgaenge[self.world.NORD] = '5'
|
||||
self.verliere(parsedCommand)
|
||||
self.world.printText('1')
|
||||
@@ -64,7 +73,7 @@ class ActionModul:
|
||||
#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('9')
|
||||
schluessel = self.world.findRaumItemById(self.world.ITEM_KLEINER_SCHLUESSEL)
|
||||
schluessel.sichtbar = True
|
||||
|
||||
|
||||
@@ -74,10 +83,10 @@ class ActionModul:
|
||||
|
||||
if item != None:
|
||||
if item.id == '4':
|
||||
glas = self.world.findRaumItemById('6')
|
||||
glas = self.world.findRaumItemById(self.world.ITEM_GLAS)
|
||||
logging.debug(f'mache Gegenstand {glas.name} sichtbar')
|
||||
glas.sichtbar = True
|
||||
elif item.id == '7':
|
||||
elif item.id == self.world.ITEM_BETT:
|
||||
# Falltür sichtbar machen
|
||||
self.world.aktuellerRaum.ausgaenge[self.world.RUNTER] = '5'
|
||||
self.setFehler('Im Boden unter dem Bett findest du eine Falltür, die nach unten führt.')
|
||||
|
20
World.py
20
World.py
@@ -118,6 +118,13 @@ class World:
|
||||
if self.inventar[itemid].name == itemname:
|
||||
return self.inventar[itemid]
|
||||
return None
|
||||
|
||||
def findItemImInventarById(self,id):
|
||||
|
||||
for itemid in self.inventar:
|
||||
if self.inventar[itemid].id == id:
|
||||
return self.inventar[itemid]
|
||||
return None
|
||||
|
||||
def ermittleBefehlId(self,befehl):
|
||||
for id in self.befehle:
|
||||
@@ -158,6 +165,7 @@ class World:
|
||||
self.personen = {}
|
||||
self.bewegungen = {}
|
||||
self.gegenstaende = {}
|
||||
self.adjektive = []
|
||||
self.befehle = {}
|
||||
self.inventar = {}
|
||||
self.objekte = {}
|
||||
@@ -173,6 +181,18 @@ class World:
|
||||
self.RAUF = '4'
|
||||
self.RUNTER = '5'
|
||||
self.VERSION = '0.5'
|
||||
self.ITEM_TISCH = '1'
|
||||
self.ITEM_LEITER = '2'
|
||||
self.ITEM_TRUHE = '3'
|
||||
self.ITEM_PFLANZE = '4'
|
||||
self.ITEM_EINGANGSTUER = '5'
|
||||
self.ITEM_GLAS = '6'
|
||||
self.ITEM_BETT = '7'
|
||||
self.ITEM_NACHTSCHRANK = '8'
|
||||
self.ITEM_KLEINER_SCHLUESSEL = '9'
|
||||
self.ITEM_JACKE = '10'
|
||||
self.ITEM_SCHWERT = '11'
|
||||
self.ITEM_SEIL = '12'
|
||||
self.fehler = ''
|
||||
parser = WorldParser.WorldParser(self)
|
||||
parser.parseWorld('world.xml')
|
||||
|
@@ -62,7 +62,13 @@ class WorldParser():
|
||||
command = Befehl(name,id,key)
|
||||
|
||||
self.world.befehle[id] = command
|
||||
# Adjektive
|
||||
for adj in root.findall('adjektive/adjektiv'):
|
||||
name = adj.attrib['name']
|
||||
id = adj.attrib['id']
|
||||
key = adj.attrib['key']
|
||||
|
||||
self.world.adjektive.append(name)
|
||||
# Sortouts
|
||||
for sortout in root.findall('sortouts/sortout'):
|
||||
name = sortout.attrib['name']
|
||||
|
@@ -71,6 +71,13 @@ class Gegenstand(SuperNode):
|
||||
self.OFFEN = 1
|
||||
self.zustand = self.GESCHLOSSEN
|
||||
|
||||
class Adjektiv(SuperNode):
|
||||
def __init__(self,name, id):
|
||||
super.__init__(self, name, '')
|
||||
self.key = key
|
||||
|
||||
|
||||
|
||||
class Person(SuperNode):
|
||||
def __init__(self, name,id,raum):
|
||||
super().__init__(name,id)
|
||||
|
Binary file not shown.
14
world.xml
14
world.xml
@@ -30,6 +30,7 @@
|
||||
</raum>
|
||||
<raum id='5' name='Keller'>
|
||||
<ausgang dir='Rauf' nachRaum='4' />
|
||||
In der Decke führt eine Öffnung nach oben ins Schlafzimmer. An der Wand hängt eine Jacke.
|
||||
<beschreibung>
|
||||
Kellerraum
|
||||
</beschreibung>
|
||||
@@ -82,8 +83,17 @@
|
||||
<command name='benutze' id='20' key='18' />
|
||||
<command name='stelle' id='21' key='19' />
|
||||
<command name='stell' id='22' key='19' />
|
||||
<command name='öffne' id='23' key='20' />
|
||||
|
||||
</commandset>
|
||||
|
||||
<adjektive>
|
||||
<adjektiv name='klein' id='1' key='1' />
|
||||
<adjektiv name='kleines' id='2' key='1' />
|
||||
<adjektiv name='kleinen' id='3' key='1' />
|
||||
<adjektiv name='kleiner' id='4' key='1' />
|
||||
<adjektiv name='kleinem' id='5' key='1' />
|
||||
</adjektive>
|
||||
<sortouts>
|
||||
<sortout name='der' />
|
||||
<sortout name='die' />
|
||||
@@ -105,6 +115,10 @@
|
||||
<item name='Bett' id='7' raum='4' imobil='true' msgid='1' visible=' true' />
|
||||
<item name='Nachtschrank' id='8' raum='4' imobil='true' msgid='1' visible=' true' />
|
||||
<item name='Schlüssel' id='9' raum='5' imobil='false' msgid='1' visible='false' />
|
||||
<item name='Jacke' id='10' raum='5' imobil='false' msgid='1' visible='true' />
|
||||
<item name='Schwert' id='11' raum='5' imobil='false' msgid='1' visible='false' />
|
||||
<item name='Seil' id='12' raum='5' imobil='false' msgid='1' visible='false' />
|
||||
<item name='Schlüssel' id='13' raum='5' imobil='false' msgid='1' visible='false' />
|
||||
|
||||
</items>
|
||||
<personen>
|
||||
|
Reference in New Issue
Block a user