本文整理汇总了Python中tp.server.model.Model.update方法的典型用法代码示例。如果您正苦于以下问题:Python Model.update方法的具体用法?Python Model.update怎么用?Python Model.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tp.server.model.Model
的用法示例。
在下文中一共展示了Model.update方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addResourcesToPlanet
# 需要导入模块: from tp.server.model import Model [as 别名]
# 或者: from tp.server.model.Model import update [as 别名]
def addResourcesToPlanet( self, planet ):
ResourceType = self.model.use( 'ResourceType' )
NaturalResourceTypes = [ ResourceType.ByName( name ) for name in [ 'Fruit Tree', 'Weird Artifact', 'Rock', 'Water' ] ]
# Add a random smattering of resources to planets...
for Type in self.random.sample( NaturalResourceTypes, self.randint(0, 4) ):
planet.resources[ Type ] = {
'accessible' : self.randint( 0, 10 ),
'extractable' : self.randint( 0, 100 ),
'inaccessible' : self.randint( 0, 1000 ) }
Model.update( planet )
示例2: addPlayer
# 需要导入模块: from tp.server.model import Model [as 别名]
# 或者: from tp.server.model.Model import update [as 别名]
def addPlayer( self, username, password, email = 'Unknown', comment = 'A Minisec Player' ):
"""
Create a Solar System, Planet, and initial Fleet for the player, positioned randomly within the Universe.
"""
user, system, planet, fleet = MinisecRuleset.addPlayer( self, username, password, email, comment )
ResourceType = self.model.use( 'ResourceType' )
# Get the player's planet object and add the empire capital
planet.resources = {
ResourceType.ByName('House') : { 'accessible' : 1 },
ResourceType.ByName('Empire Capital') : { 'accessible' : 1 } }
Model.update( planet )
示例3: populate
# 需要导入模块: from tp.server.model import Model [as 别名]
# 或者: from tp.server.model.Model import update [as 别名]
def populate(self, *args, **kwargs):
"""
Populate a universe with a number of systems and planets.
"""
Ruleset.populate(self, *args, **kwargs)
self.generator.initialise(*args)
Object = self.model.use("Object")
universe = Object.ByType("Universe")[0]
systems = self.generator.generateStarSystems(parent=universe)
for system in systems:
self.generator.generatePlanets(parent=system)
Model.update(universe)