Beispiel #1
0
    def __init__(self, name, startingRoom, inventory, doing=None):

        if doing is None:
            doing = ['', None, False]
            # ['verb' (plain english),object (pointer), IfActivityFullyOccupying (bool)]

        if inventory is None:
            inventory = []

        self.name = name
        self.inventory = inventory
        self.currentRoom = startingRoom
        self.doing = doing
        #an array of inventory objects
        import invFurnClass

        basicShirt = invFurnClass.inventoryObject(
            name="basic shirt",
            basicDesc="A basic synth-cloth shirt",
            inspectDesc="There's a small rip in the armpit...",
            equippable=[True, "clothesTorso"])
        basicLegs = invFurnClass.inventoryObject(
            name="basic legwear",
            basicDesc="Some basic synth-cloth legwear",
            inspectDesc="This could probably do with being washed.",
            equippable=[True, "clothesLegs"])
        basicShoes = invFurnClass.inventoryObject(
            name="basic shoes",
            basicDesc="A pair of basic synthetic fabric and rubber shoes",
            inspectDesc="You can feel a hole in your sock. Ugh.",
            equippable=[True, "footwear"])

        self.inventory.append(basicShirt)
        self.inventory.append(basicLegs)
        self.inventory.append(basicShoes)

        #in case we decide to add stats later

        self.equipped = {
            "clothesTorso": basicShirt,
            "clothesLegs": basicLegs,
            "armwear": None,
            "headgear": None,
            "footwear": basicShoes,
            "armourTorso": None,
            "armourLegs": None,
            "accessories": [],
            "weaponLeft": None,
            "weaponRight": None,
            "weaponBoth": None
        }
        #this is more for a fantasy setting and it hasn't been tested cuz I wrote it at 00:37

        self.location = None
Beispiel #2
0
invTree = ET.parse('DATA\\inventoryObjects.xml')
invRoot = invTree.getroot()
vitalInv = {}
for room in rooms:
    if len(room.objects) > 0:
        for obj in room.objects:
            vitalInv[obj] = room

for child in invRoot:
    if child.attrib["name"] in vitalInv:
        vitalInv[child.attrib["name"]].objects.append(
            invFurnClass.inventoryObject(
                child.attrib["name"], child[0].text, child[1].text,
                [eval(child[2][0].text), child[2][1].text],
                [eval(child[3][0].text), child[3][1].text],
                eval(child[4].text),
                [eval(child[5][0].text), [elem.text for elem in child[5][1]]],
                eval(child[6].text),
                [eval(child[7][0].text), child[7][1].text],
                [child[8][0].text, child[8][1].text]))
        vitalInv[child.attrib["name"]].objects.remove(child.attrib["name"])
#setting up inventory objects in rooms

vitalInv = {}
for furn in furnishingList:
    if len(furn.containedObjects) > 0:
        for obj in furn.containedObjects:
            vitalInv[obj] = furn

for child in invRoot:
    if child.attrib["name"] in vitalInv: