コード例 #1
0
ファイル: room.py プロジェクト: ccaroon/scriptum
    def __init__(self,
                 name,
                 desc,
                 items=[],
                 objects=[],
                 north=None,
                 east=None,
                 south=None,
                 west=None):
        super().__init__(desc)
        self.name = name

        self.items = adventurelib.Bag()
        for item in items:
            self.items.add(item)

        self.objects = adventurelib.Bag()
        for obj in objects:
            self.objects.add(obj)

        self.north = north
        self.east = east
        self.south = south
        self.west = west
コード例 #2
0
ファイル: objects.py プロジェクト: ttocsneb/an_Adventure
    def __init__(self,
                 name: str,
                 desc: str,
                 items: list = None,
                 attrs: dict = None,
                 exits: dict = None,
                 item_desc: dict = None):
        object.__setattr__(self, '_init', False)
        super().__init__(desc)
        self.name = name
        self.desc = desc

        items = items or list()
        items = load_items(items)
        self._items = adventurelib.Bag(items)
        self._attrs = attrs or dict()
        self._exits = exits or dict()
        self._item_desc = item_desc or dict()

        if attrs is not None:
            for attr, value in attrs.items():
                setattr(self, attr, value)

        self._init = True
コード例 #3
0
#from adventurelib import *
import adventurelib as a
import random

a.Room.items = a.Bag()

current_room = starting_room = a.Room("""
You are in a dark room.
""")

valley = starting_room.north = a.Room("""
You are in a beautiful valley.
""")

magic_forest = valley.north = a.Room("""
You are in a enchanted forest where magic grows wildly.
""")

cave = magic_forest.north = a.Room("""
You are insde a dark cave.
You hear a waterfall nearby""")

waterfall = cave.east = a.Room("""
You are infornt of a waterfall!
You see a secret entrance.
Enter the room""")

secret_entrance = waterfall.south = a.Room("""
You are in a secret room.
There is a plane!
Board the plane!""")
コード例 #4
0
#from adventurelib import *
import adventurelib as a
import random

a.Room.items = a.Bag()

current_room = starting_room = a.Room("""
You are in a dark room.
""")

valley = starting_room.north = a.Room("""
You are in a beautiful valley.
""")

magic_forest = valley.north = a.Room("""
You are in a enchanted forest where magic grows wildly.
""")

mallet = a.Item('rusty mallet', 'mallet')
valley.items = a.Bag({
    mallet,
})

wizard = a.Item('wizard', 'the wizard', 'a wizard')
wizard.answers = ["Geht so", "jaja", "akra-ka-babra!"]

# a bag is a python SET !!
magic_forest.items = a.Bag({
    wizard,
})  # ITEMS must be in a bag