コード例 #1
0
ファイル: beta.py プロジェクト: ztripez/bravo
    def __init__(self, name):
        """
        Create a factory and world.

        ``name`` is the string used to look up factory-specific settings from
        the configuration.

        :param str name: internal name of this factory
        """

        log.msg("Initializing factory for world '%s'..." % name)

        self.name = name
        self.port = configuration.getint("world %s" % name, "port")
        if configuration.has_option("world %s" % name, "host"):
            self.interface = configuration.get("world %s" % name, "host")

        world_folder = configuration.get("world %s" % name, "path")
        self.world = World(world_folder)
        self.world.factory = self
        if configuration.getboolean("world %s" % name, "perm_cache"):
            self.world.enable_cache()

        self.protocols = dict()

        self.eid = 1
        self.entities = set()

        self.time_loop = LoopingCall(self.update_time)
        self.time_loop.start(2)

        authenticator = configuration.get("world %s" % name, "authenticator")
        selected = retrieve_named_plugins(IAuthenticator, [authenticator])[0]

        log.msg("Using authenticator %s" % selected.name)
        self.handshake_hook = selected.handshake
        self.login_hook = selected.login

        generators = configuration.getlist("bravo", "generators")
        generators = retrieve_named_plugins(ITerrainGenerator, generators)

        log.msg("Using generators %s" % ", ".join(i.name for i in generators))
        self.world.pipeline = generators

        self.chat_consumers = set()

        log.msg("Factory successfully initialized for world '%s'!" % name)
コード例 #2
0
ファイル: stdio.py プロジェクト: iamjagman/bravo
from twisted.internet.defer import Deferred
from twisted.internet.protocol import ClientCreator
from twisted.internet.stdio import StandardIO
from twisted.internet.task import LoopingCall
from twisted.protocols.amp import AMP
from twisted.protocols.basic import LineReceiver

from bravo.amp import Version, Worlds, RunCommand
from bravo.config import configuration
from bravo.utilities import fancy_console_name

try:
    import termios
    import tty
    fancy_console = os.isatty(sys.__stdin__.fileno())
    fancy_console = fancy_console and configuration.getboolean("bravo",
        "fancy_console")
except ImportError:
    fancy_console = False

typeToColor = {
    'identifier': '\x1b[31m',
    'keyword': '\x1b[32m',
    'parameter': '\x1b[33m',
    'variable': '\x1b[1;33m',
    'string': '\x1b[35m',
    'number': '\x1b[36m',
    'op': '\x1b[37m'
}

normalColor = '\x1b[0m'
コード例 #3
0
from twisted.internet.defer import Deferred
from twisted.internet.protocol import ClientCreator
from twisted.internet.stdio import StandardIO
from twisted.internet.task import LoopingCall
from twisted.protocols.amp import AMP
from twisted.protocols.basic import LineReceiver

from bravo.amp import Version, Worlds, RunCommand
from bravo.config import configuration
from bravo.utilities import fancy_console_name

try:
    import termios
    import tty
    fancy_console = os.isatty(sys.__stdin__.fileno())
    fancy_console = fancy_console and configuration.getboolean(
        "bravo", "fancy_console")
except ImportError:
    fancy_console = False

typeToColor = {
    'identifier': '\x1b[31m',
    'keyword': '\x1b[32m',
    'parameter': '\x1b[33m',
    'variable': '\x1b[1;33m',
    'string': '\x1b[35m',
    'number': '\x1b[36m',
    'op': '\x1b[37m'
}

normalColor = '\x1b[0m'
コード例 #4
0
ファイル: world.py プロジェクト: ztripez/bravo
from twisted.internet.defer import Deferred, succeed
from twisted.internet.task import coiterate, deferLater, LoopingCall
from twisted.python import log
from twisted.python.filepath import FilePath

from bravo.chunk import Chunk
from bravo.compat import product
from bravo.config import configuration
from bravo.serialize import LevelSerializer
from bravo.serialize import read_from_file, write_to_file, extension
from bravo.utilities import split_coords

try:
    from ampoule import deferToAMPProcess
    from bravo.remote import MakeChunk
    async = configuration.getboolean("bravo", "ampoule")
except ImportError:
    async = False

def base36(i):
    """
    Return the string representation of i in base 36, using lowercase letters.
    """

    letters = "0123456789abcdefghijklmnopqrstuvwxyz"

    if i < 0:
        i = -i
        signed = True
    elif i == 0:
        return "0"