本文整理匯總了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)