Exemplo n.º 1
0
 def test3():
     # Same things as test2, but better and closer to a use casew
     m = mansion()
     # Use the crafting classes in this test
     c = crafting()
     # populate inventory with everything you need
     for ingredient in m.crafter.ingredients_by_spell(SPELLS.PROTECTION): c.select(ingredient)
     c.select(ALTAR())
     new_craft = c.craft(craft_engine().spells, SPELLS.PROTECTION)
     if new_craft: 
         c.select(new_craft)
         m.char.inventory.put_away(new_craft)
     for ingredient in m.crafter.ingredients_by_spell(SPELLS.PROTECTION2): c.select(ingredient)
     c.select(ALTAR())
     new_craft = c.craft(craft_engine().spells, SPELLS.PROTECTION2)
     if new_craft: 
         c.select(new_craft)
         m.char.inventory.put_away(new_craft)
     for ingredient in m.crafter.ingredients_by_spell(SPELLS.PROTECTION3): c.select(ingredient)
     c.select(ALTAR())
     new_craft = c.craft(craft_engine().spells, SPELLS.PROTECTION3)
     if new_craft: 
         c.select(new_craft)
         m.char.inventory.put_away(new_craft)
     print(m.char.inventory)
Exemplo n.º 2
0
 def ingredients_by_name(self, item_type, item_name):
     """Returns a list of constructed ingredients and crafts based on the item_type dict"""
     #parts = [INGREDIENT(ing_name=ing) for ing in item_type[item_name][4] if type(ing)==type(ingredient_name.ADDERSTONE)]
     parts = [INGREDIENT(ing_name=ing) for ing in item_type[item_name][4]]
     if item_type == craft_engine().spells:
         parts.append(ALTAR())
     return parts
Exemplo n.º 3
0
    def test2():
        # create an inventory with an altar and the ingredients needed for a spell
        m = mansion()
        m.char.inventory.put_away(ALTAR())
        for ingredient in m.crafter.ingredients_by_spell(SPELLS.PROTECTION):
            m.char.inventory.put_away(ingredient)
        # this causes the side effect of adding craft names as ingredients, they should be ignored or removed
        # test remove
        for ing in m.char.inventory.ingredients.items:
            # check items against the ingredient list
            if not ing.name in [e for e in ingredient_name]:
                # throw away everything that isn't an ingredient
                m.char.inventory.throw_away(ing)
        # now that everything is cleaned up, craft the spells!
        # hand the sublist of selected ingredients to the craft engine.
        print("Items accounted for? {}".format( m.crafter.check_spell_prerequisites(m.char.inventory, SPELLS.PROTECTION) ))
        prot = _craft(craft_type=craft_engine().spells, craft_name=SPELLS.PROTECTION, 
            ingredients_list=\
                m.char.inventory.ingredients.items+\
                m.char.inventory.spells.items)
        # This is where you would remove the selected item subset, but we're not doing that here
        # instead, we'll just blow away the whole list and replace it with the new subset
        m.char.inventory.ingredients.items = [] # kabloosh now it's empty
        m.char.inventory.spells.items = [] # kabloosh now it's empty
        # next craft, now without any comments:

        for ingredient in m.crafter.ingredients_by_spell(SPELLS.PROTECTION2):
            m.char.inventory.put_away(ingredient)
        for ing in m.char.inventory.ingredients.items:
            if not ing.name in [e for e in ingredient_name]:
                m.char.inventory.throw_away(ing)
        m.char.inventory.put_away(prot) # okay, one comment. This spell requires the craft we made before
        print("Items accounted for? {}".format( m.crafter.check_spell_prerequisites(m.char.inventory, SPELLS.PROTECTION2) ))
        prot2 = _craft(craft_type=craft_engine().spells, craft_name=SPELLS.PROTECTION2, 
            ingredients_list=\
                m.char.inventory.ingredients.items+\
                m.char.inventory.spells.items)
        m.char.inventory.ingredients.items = []
        m.char.inventory.spells.items = []

        # and 3
        for ingredient in m.crafter.ingredients_by_spell(SPELLS.PROTECTION3):
            m.char.inventory.put_away(ingredient)
        for ing in m.char.inventory.ingredients.items:
            if not ing.name in [e for e in ingredient_name]:
                m.char.inventory.throw_away(ing)
        m.char.inventory.put_away(prot2) # same thing as before
        print("Items accounted for? {}".format( m.crafter.check_spell_prerequisites(m.char.inventory, SPELLS.PROTECTION3) ))
        prot3 = _craft(craft_type=craft_engine().spells, craft_name=SPELLS.PROTECTION3, 
            ingredients_list=\
                m.char.inventory.ingredients.items+\
                m.char.inventory.spells.items)

        m.char.inventory.put_away(prot) # need to put this back in because we blew away the inventory containing it
        m.char.inventory.put_away(prot3)

        print(m.char.inventory) # should just contain the list from protection3, since I didn't blow that one away, and the three crafts
Exemplo n.º 4
0
 def furnish(self):
     """Populates a room with furniture and ingredients. Needs to be overhauled."""
     #TODO: Overhaul this whole thing
     self.containers = {
         room_type.BEDROOM: {
             c.CHEST: [],
             c.CLOSET: [],
             c.DRESSER: [],
             c.BED: [],
             c.UNDERBED: []
         },
         room_type.SITTINGROOM: {
             c.CHEST: [],
             c.CHESTERFIELD: [],
             c.SHELF: [],
             c.DISPLAYCASE: []
         },
         room_type.KITCHEN: {
             c.CABINET: [],
             c.BREADBOX: [],
             c.PANTRY: []
         },
         room_type.HALLWAY: {
             c.DISPLAYCASE: []
         },
         room_type.STUDY: {
             c.DESKDRAWER: [],
             c.DESK: [],
             c.CABINET: [],
             c.CHEST: [],
             c.BOOKCASE: [],
             c.DISPLAYCASE: [],
             c.CHESTERFIELD: []
         },
         room_type.LIBRARY: {
             c.BOOKCASE: [],
             c.DESK: [],
             c.DESKDRAWER: []
         }
     }[self.room_type]
     for container, items in self.containers.items():
         ## populate with ingredients
         # number of ingredients in container
         for i in range(
                 0,
                 random.choice([0] * 20 + [1] * 30 + [2] * 30 + [3] * 10 +
                               [4] * 8 + [5] * 2) + 1):
             items.append(INGREDIENT())
     if random.choice([True] * 3 + [False] * 7): self.book = BOOK()
     if random.choice([True] * 4 + [False] * 6): self.light = LIGHT()
     if random.choice([True] * 1 + [False] * 9): self.altar = ALTAR()
Exemplo n.º 5
0
                    time.sleep(random.uniform(0.03, 0.18))
                print()


class STATES(Enum):
    """Maintains a list of possible states, so I don't forget to implement anything."""
    TITLE = 0
    INTRO = 1
    TUTORIAL = 2
    OCCUPY = 10
    EXPLORE = 20
    RUMMAGE = 21
    CHAT = 22
    TRADE = 23
    NEXTROOM = 30
    BROWSEINV = 40
    CRAFTING = 41
    CONSUME = 42
    STRUGGLE = 100


if __name__ == "__main__":
    game = MuderMansion()
    for i in "     ":
        game.act.do(ACTION.GETFREEWEAPON)
        game.act.do(ACTION.GETFREEITEM)
        game.act.crafter.select(ALTAR())
        game.act.do(ACTION.GETFREESPELL)
        game.act.do(ACTION.GETFREETOOL)
        game.act.do(ACTION.GETFREETRAP)
    game.start()
Exemplo n.º 6
0
class ingredients:
    def __init__(self):
        self.items = []

    def __str__(self):
        return "ingredients:\n" + "\n".join([e.__str__() for e in self.items])


class specials:
    def __init__(self):
        self.items = []

    def __str__(self):
        return "specials:\n" + "\n".join([e.__str__() for e in self.items])


if __name__ == "__main__":
    inv = inventory()
    for i in range(0, 10):
        c = _craft()
        print(c)
        if not inv.put_away(c):
            print("didn't go in")
    for i in range(0, 10):
        c = random.choice([BOOK(), ALTAR(), INGREDIENT()])
        if not inv.put_away(c):
            print("didn't go in")
    print(inv.current_weight)

    inv.show_subinv(item_type.WEAPON)
Exemplo n.º 7
0
                "Lucy Carroll\nTom Carroll\n"+\
                "Chloe\nMegan Lee"
            )

    def intro(self):
        return [
            " ",0,
            "You wake up in a strange place...", 3,
            "Your head feels fuzzy and your eyes can't see too well...", 1,
            "How did you get here?", 1, "You have a strange feeling.", 1, "Like there's someone else here.", 1, "Someone BAD.", 1,
            "You climb to your feet and try to take in the splendor of this place...", 3, "You're in some sort of intricate room. ", 0, 
            "Everything in here looks really expensive. This must be some kind of mansion...", 2]

if __name__ == "__main__":
    ## make a game
    ## increase character stats 
    ## make a room
    ## lock a door
    ## print character and doors
    game = action()
    game.title()
    game.crafter.select(ALTAR()) # adds an altar to the default character inventory
    new_trap = game.do(ACTION.GETFREETRAP) 
    new_spell = game.do(ACTION.GETFREESPELL)
    new_weapon = game.do(ACTION.GETFREEWEAPON) 
    new_tool = game.do(ACTION.GETFREETOOL) 
    print(game.game.char.inventory) # prints the inventory to show that it is in the trap section
    game.do(ACTION.PLACETRAP, new_trap, code="010") # places the HOMEALONE trap on doors
    game.do(ACTION.AMBUSH) # triggers the ambush (currently just shows door status)
    print(game.game.char.inventory) # print the inventory to show the trap is gone from the inventory
Exemplo n.º 8
0
 def __init__(self):
     self.selected = []
     self.ALTARTYPE = type(ALTAR())