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