本文整理汇总了Python中bravo.world.World类的典型用法代码示例。如果您正苦于以下问题:Python World类的具体用法?Python World怎么用?Python World使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了World类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestWorld
class TestWorld(unittest.TestCase):
def setUp(self):
self.name = "unittest"
self.bcp = BravoConfigParser()
self.bcp.add_section("world unittest")
self.bcp.set("world unittest", "url", "")
self.bcp.set("world unittest", "serializer", "memory")
self.w = World(self.bcp, self.name)
self.w.pipeline = []
self.w.start()
def tearDown(self):
self.w.stop()
def test_trivial(self):
pass
def test_load_player_initial(self):
"""
Calling load_player() on a player which has never been loaded should
not result in an exception. Instead, the player should be returned,
wrapped in a Deferred.
"""
# For bonus points, assert that the player's username is correct.
d = self.w.load_player("unittest")
@d.addCallback
def cb(player):
self.assertEqual(player.username, "unittest")
return d
示例2: TestWorldConfig
class TestWorldConfig(unittest.TestCase):
def setUp(self):
self.name = "unittest"
self.bcp = BravoConfigParser()
self.bcp.add_section("world unittest")
self.bcp.set("world unittest", "url", "")
self.bcp.set("world unittest", "serializer", "memory")
self.w = World(self.bcp, self.name)
self.w.pipeline = []
def test_trivial(self):
pass
def test_world_configured_seed(self):
"""
Worlds can have their seed set via configuration.
"""
self.bcp.set("world unittest", "seed", "42")
self.w.start()
self.assertEqual(self.w.level.seed, 42)
self.w.stop()
示例3: __init__
def __init__(self, config, 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
"""
self.name = name
self.config = config
self.config_name = "world %s" % name
self.world = World(self.config, self.name)
self.world.factory = self
self.protocols = dict()
self.connectedIPs = defaultdict(int)
self.mode = self.config.get(self.config_name, "mode")
if self.mode not in ("creative", "survival"):
raise Exception("Unsupported mode %s" % self.mode)
self.limitConnections = self.config.getintdefault(self.config_name,
"limitConnections",
0)
self.limitPerIP = self.config.getintdefault(self.config_name,
"limitPerIP", 0)
self.vane = WeatherVane(self)
示例4: setUp
def setUp(self):
# Set up world.
self.name = "unittest"
self.d = tempfile.mkdtemp()
bravo.config.configuration.add_section("world unittest")
bravo.config.configuration.set("world unittest", "url",
"file://%s" % self.d)
bravo.config.configuration.set("world unittest", "serializer",
"alpha")
self.w = World(self.name)
self.w.pipeline = []
self.w.start()
# And finally the mock factory.
self.f = RedstoneMockFactory()
self.f.world = self.w
pp = {"factory": self.f}
self.p = retrieve_plugins(IDigHook, parameters=pp)
if "redstone" not in self.p:
raise unittest.SkipTest("Plugin not present")
self.hook = self.p["redstone"]
示例5: __init__
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
"""
self.name = name
self.config_name = "world %s" % name
self.world = World(self.name)
self.world.factory = self
self.protocols = dict()
self.connectedIPs = defaultdict(int)
self.limitConnections = configuration.getintdefault(self.config_name,
"limitConnections",
0)
self.limitPerIP = configuration.getintdefault(self.config_name,
"limitPerIP", 0)
self.furnace_manager = FurnaceManager(self)
self.vane = WeatherVane(self)
示例6: setUp
def setUp(self):
# Set up world.
self.name = "unittest"
self.d = tempfile.mkdtemp()
self.bcp = BravoConfigParser()
self.bcp.add_section("world unittest")
self.bcp.set("world unittest", "url", "file://%s" % self.d)
self.bcp.set("world unittest", "serializer", "alpha")
self.w = World(self.bcp, self.name)
self.w.pipeline = []
self.w.start()
# And finally the mock factory.
self.f = PhysicsMockFactory()
self.f.world = self.w
# Using dig hook to grab the plugin since the build hook was nuked in
# favor of the automaton interface.
pp = {"factory": self.f}
self.p = bravo.plugin.retrieve_plugins(IDigHook, parameters=pp)
if "water" not in self.p:
raise unittest.SkipTest("Plugin not present")
self.hook = self.p["water"]
示例7: setUp
def setUp(self):
self.name = "unittest"
self.bcp = BravoConfigParser()
self.bcp.add_section("world unittest")
self.bcp.set("world unittest", "url", "")
self.bcp.set("world unittest", "serializer", "memory")
self.w = World(self.bcp, self.name)
self.w.pipeline = []
示例8: setUp
def setUp(self):
self.name = "unittest"
self.d = tempfile.mkdtemp()
bravo.config.configuration.add_section("world unittest")
bravo.config.configuration.set("world unittest", "url", "file://%s" % self.d)
bravo.config.configuration.set("world unittest", "serializer",
"alpha")
self.w = World(self.name)
self.w.pipeline = []
self.w.start()
示例9: setUp
def setUp(self):
self.name = "unittest"
self.d = tempfile.mkdtemp()
self.bcp = BravoConfigParser()
self.bcp.add_section("world unittest")
self.bcp.set("world unittest", "url", "file://%s" % self.d)
self.bcp.set("world unittest", "serializer", "alpha")
self.w = World(self.bcp, self.name)
self.w.pipeline = []
self.w.start()
示例10: TestWorld
class TestWorld(unittest.TestCase):
def setUp(self):
self.name = "unittest"
self.d = tempfile.mkdtemp()
bravo.config.configuration.add_section("world unittest")
bravo.config.configuration.set("world unittest", "url", "file://%s" % self.d)
bravo.config.configuration.set("world unittest", "serializer",
"alpha")
self.w = World(self.name)
self.w.pipeline = []
self.w.start()
def tearDown(self):
self.w.stop()
del self.w
shutil.rmtree(self.d)
bravo.config.configuration.remove_section("world unittest")
def test_trivial(self):
pass
def test_load_player_initial(self):
"""
Calling load_player() on a player which has never been loaded should
not result in an exception. Instead, the player should be returned,
wrapped in a Deferred.
"""
# For bonus points, assert that the player's username is correct.
d = self.w.load_player("unittest")
@d.addCallback
def cb(player):
self.assertEqual(player.username, "unittest")
return d
示例11: __init__
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.config_name = "world %s" % name
self.port = configuration.getint(self.config_name, "port")
self.interface = configuration.getdefault(self.config_name, "host",
"")
self.world = World(name)
self.world.factory = self
if configuration.has_option(self.config_name, "perm_cache"):
cache_level = configuration.getint(self.config_name, "perm_cache")
self.world.enable_cache(cache_level)
self.protocols = dict()
self.eid = 1
self.time = self.world.time
self.time_loop = LoopingCall(self.update_time)
self.time_loop.start(2)
authenticator = configuration.get(self.config_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(self.config_name, "generators")
generators = retrieve_sorted_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)
示例12: setUp
def setUp(self):
self.bcp = BravoConfigParser()
self.bcp.add_section("world unittest")
self.bcp.set("world unittest", "url", "")
self.bcp.set("world unittest", "serializer", "memory")
self.w = World(self.bcp, "unittest")
self.w.pipeline = []
self.w.start()
self.f = GrassMockFactory()
self.f.world = self.w
self.w.factory = self.f
plugins = retrieve_plugins(IAutomaton, factory=self.f)
self.hook = plugins["grass"]
示例13: __init__
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
"""
self.name = name
self.config_name = "world %s" % name
self.world = World(self.name)
self.world.factory = self
self.protocols = dict()
self.vane = WeatherVane(self)
示例14: setUp
def setUp(self):
# Set up world.
self.name = "unittest"
self.bcp = BravoConfigParser()
self.bcp.add_section("world unittest")
self.bcp.set("world unittest", "url", "")
self.bcp.set("world unittest", "serializer", "memory")
self.w = World(self.bcp, self.name)
self.w.pipeline = []
self.w.start()
# And finally the mock factory.
self.f = RedstoneMockFactory()
self.f.world = self.w
self.p = retrieve_plugins(IDigHook, factory=self.f)
self.hook = self.p["redstone"]
示例15: setUp
def setUp(self):
plugins = retrieve_plugins(IAutomaton)
if "grass" not in plugins:
raise unittest.SkipTest("Plugin not present")
self.hook = plugins["grass"]
self.d = tempfile.mkdtemp()
configuration.add_section("world unittest")
configuration.set("world unittest", "url", "file://%s" % self.d)
configuration.set("world unittest", "serializer", "alpha")
self.w = World("unittest")
self.w.pipeline = []
self.f = GrassMockFactory()
self.f.world = self.w