Öffnen der Truhe
This commit is contained in:
@@ -28,10 +28,15 @@ class ActionModul:
|
||||
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.')
|
||||
if item.id == self.world.ITEM_TRUHE:
|
||||
schluessel = self.world.findItemImInventarById(self.world.ITEM_KLEINER_SCHLUESSEL)
|
||||
|
||||
if schluessel != None:
|
||||
item.zustand = item.OFFEN
|
||||
self.setFehler('Truhe ist jetzt offen')
|
||||
else:
|
||||
self.setFehler('Die Truhe ist verschlossen und du hast keinen Schlüssel.')
|
||||
|
||||
|
||||
def verliere(self,parsedCommand):
|
||||
item = self.world.findItemImInventar(parsedCommand.gegenstand);
|
||||
|
@@ -4,6 +4,7 @@ class ParsedCommand:
|
||||
self.verb = None
|
||||
self.gegenstand = None
|
||||
self.gegenstand2 = None
|
||||
self.adjektiv = None
|
||||
self.objekt = None
|
||||
self.key = '-1'
|
||||
|
||||
|
15
World.py
15
World.py
@@ -133,9 +133,16 @@ class World:
|
||||
return id
|
||||
return None
|
||||
|
||||
def removeSortouts(self,words):
|
||||
def findAdjektiv(self,adjektiv):
|
||||
skip
|
||||
def removeSortouts(self,words,parsedCommand):
|
||||
w = []
|
||||
for word in words:
|
||||
if word in self.adjektive:
|
||||
if word == adj.name:
|
||||
parsedCommand.adjektiv = adj
|
||||
|
||||
|
||||
if word not in self.sortouts:
|
||||
w.append(word)
|
||||
return w
|
||||
@@ -143,8 +150,8 @@ class World:
|
||||
|
||||
def parseInput(self,input):
|
||||
words = input.split(' ')
|
||||
words = self.removeSortouts(words)
|
||||
parsedCommand = ParsedCommand.ParsedCommand()
|
||||
words = self.removeSortouts(words,parsedCommand)
|
||||
befehlid = self.ermittleBefehlId(words[0])
|
||||
|
||||
if befehlid != None:
|
||||
@@ -165,7 +172,7 @@ class World:
|
||||
self.personen = {}
|
||||
self.bewegungen = {}
|
||||
self.gegenstaende = {}
|
||||
self.adjektive = []
|
||||
self.adjektive = {}
|
||||
self.befehle = {}
|
||||
self.inventar = {}
|
||||
self.objekte = {}
|
||||
@@ -185,7 +192,7 @@ class World:
|
||||
self.ITEM_LEITER = '2'
|
||||
self.ITEM_TRUHE = '3'
|
||||
self.ITEM_PFLANZE = '4'
|
||||
self.ITEM_EINGANGSTUER = '5'
|
||||
self.ITEM_HAUSTUER = '5'
|
||||
self.ITEM_GLAS = '6'
|
||||
self.ITEM_BETT = '7'
|
||||
self.ITEM_NACHTSCHRANK = '8'
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import xml.etree.ElementTree as ET
|
||||
from data.Raum import Raum, Befehl, Gegenstand,Person,TextNode
|
||||
from data.Raum import Raum, Befehl, Adjektiv,Gegenstand,Person,TextNode
|
||||
import io
|
||||
import logging
|
||||
|
||||
@@ -67,8 +67,10 @@ class WorldParser():
|
||||
name = adj.attrib['name']
|
||||
id = adj.attrib['id']
|
||||
key = adj.attrib['key']
|
||||
adjektiv = Adjektiv(name,id,key)
|
||||
|
||||
self.world.adjektive.append(name)
|
||||
self.world.adjektive[id] = adjektiv
|
||||
|
||||
# Sortouts
|
||||
for sortout in root.findall('sortouts/sortout'):
|
||||
name = sortout.attrib['name']
|
||||
@@ -88,9 +90,11 @@ class WorldParser():
|
||||
gegenstand = Gegenstand(name,id,raumid)
|
||||
imobil = item.attrib['imobil']
|
||||
visible = item.attrib['visible']
|
||||
adjektiv = item.attrib['adjektiv']
|
||||
raum = self.world.sucheRaum(raumid)
|
||||
if raum is not None:
|
||||
gegenstand.raum = raum.id
|
||||
gegenstand.adjektiv = adjektiv
|
||||
gegenstand.imobil = imobil.lower() in ['true','True','1']
|
||||
logging.debug('itemid= ' + id + ',visible= ' + visible)
|
||||
gegenstand.sichtbar = visible.lower() not in ['false','False','0']
|
||||
|
@@ -67,13 +67,14 @@ class Gegenstand(SuperNode):
|
||||
self.zustand = 0
|
||||
self.sichtbar = True
|
||||
self.imobil = False
|
||||
self.adjektiv = None
|
||||
self.GESCHLOSSEN = 0
|
||||
self.OFFEN = 1
|
||||
self.zustand = self.GESCHLOSSEN
|
||||
|
||||
class Adjektiv(SuperNode):
|
||||
def __init__(self,name, id):
|
||||
super.__init__(self, name, '')
|
||||
def __init__(self,name, id,key):
|
||||
super().__init__(name, id)
|
||||
self.key = key
|
||||
|
||||
|
||||
|
Binary file not shown.
26
world.xml
26
world.xml
@@ -106,19 +106,19 @@
|
||||
<sortout name='kleiner' />
|
||||
</sortouts>
|
||||
<items>
|
||||
<item name='Tisch' id='1' raum='1' imobil='true' msgid='1' visible='true' />
|
||||
<item name='Leiter' id='2' raum='1' imobil='true' msgid='1' visible='true' />
|
||||
<item name='Truhe' id='3' raum='2' imobil='false' msgid='4' visible='true' />
|
||||
<item name='Pflanze' id='4' raum='3' imobil='false' msgid='3' visible='true' />
|
||||
<item name='Eingangstür' id='5' raum='3' imobil='true' msgid='3' visible='true' />
|
||||
<item name='Glas' id='6' raum='3' imobil='false' msgid='3' visible='false' />
|
||||
<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' />
|
||||
<item name='Tisch' id='1' raum='1' imobil='true' adjektiv = '0' msgid='1' visible='true' />
|
||||
<item name='Leiter' id='2' raum='1' imobil='true' adjektiv = '0' msgid='1' visible='true' />
|
||||
<item name='Truhe' id='3' raum='2' imobil='false' adjektiv = '0' msgid='4' visible='true' />
|
||||
<item name='Pflanze' id='4' raum='3' imobil='false' adjektiv = '0' msgid='3' visible='true' />
|
||||
<item name='Haustür' id='5' raum='3' imobil='true' adjektiv = '0' msgid='3' visible='true' />
|
||||
<item name='Glas' id='6' raum='3' imobil='false' adjektiv = '0' msgid='3' visible='false' />
|
||||
<item name='Bett' id='7' raum='4' imobil='true' adjektiv = '0' msgid='1' visible=' true' />
|
||||
<item name='Nachtschrank' id='8' raum='4' imobil='true' adjektiv = '0' msgid='1' visible=' true' />
|
||||
<item name='Schlüssel' id='9' raum='5' imobil='false' adjektiv = '1' msgid='1' visible='false' />
|
||||
<item name='Jacke' id='10' raum='5' imobil='false' adjektiv = '0' msgid='1' visible='true' />
|
||||
<item name='Schwert' id='11' raum='5' imobil='false' adjektiv = '0' msgid='1' visible='false' />
|
||||
<item name='Seil' id='12' raum='5' imobil='false' adjektiv = '0' msgid='1' visible='false' />
|
||||
<item name='Schlüssel' id='13' raum='5' imobil='false' adjektiv = '0' msgid='1' visible='false' />
|
||||
|
||||
</items>
|
||||
<personen>
|
||||
|
Reference in New Issue
Block a user