本文整理汇总了Python中Zone.Zone.construct_model_from_dict方法的典型用法代码示例。如果您正苦于以下问题:Python Zone.construct_model_from_dict方法的具体用法?Python Zone.construct_model_from_dict怎么用?Python Zone.construct_model_from_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zone.Zone
的用法示例。
在下文中一共展示了Zone.construct_model_from_dict方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_load_zone_from_dict
# 需要导入模块: from Zone import Zone [as 别名]
# 或者: from Zone.Zone import construct_model_from_dict [as 别名]
def test_load_zone_from_dict(self):
from Zone import ZoneDBFields
zd = {
ZoneDBFields.DEFINITION_KEY: "gas"
}
z = Zone.construct_model_from_dict(zd)
self.assertEqual(z.get_fullName(),"Gas Planet Orbit")
示例2: check_in_and_get_notices
# 需要导入模块: from Zone import Zone [as 别名]
# 或者: from Zone.Zone import construct_model_from_dict [as 别名]
def check_in_and_get_notices(heroPk,accountPk,checkinTimeUtc,utcOffset):
"""
this should be called on page load and should be used to get any notices
for the use
args:
heroPk:
we want a pymongo objectId for the hero table
accountPk:
we want a pymongo objectId for the hero table
checkinTimeUtc:
this needs to be that the user check in and it needs to be utc
utcOffset:
the time-zone offset from UTC, in minutes, for the current locale.
returns:
we return a dict with two elements: 'story' which will be a list of
huge things of text and 'zoneChoice' which is a list of dicts each
of which contain 'zonePk','description'
but zoneChoice may be none.
"""
from Hero import Hero
from Account import Account
hero = Hero.construct_model_from_pk(heroPk)
account = Account.construct_model_from_pk(accountPk)
lastCheckinTime = account.lastCheckInTime
account.lastCheckInTime = checkinTimeUtc
account.save_changes()
if not lastCheckinTime:
messages = build_first_time_checkin_messages(hero)
hero.save_changes()
return messages
if hero.isInZoneLimbo:
autoPickedZoneDict = random.choice(hero.zone.nextZoneReferenceList)
hero.zone = Zone.construct_model_from_dict(autoPickedZoneDict)
hero.monster = Monster.construct_new_monster(hero.zone.definitionKey,hero.zone.lvl)
timeDiffInDays = (checkinTimeUtc - lastCheckinTime)/(60*60*24)
if timeDiffInDays >= 1:
pass
示例3: test_zone_properties_from_dict
# 需要导入模块: from Zone import Zone [as 别名]
# 或者: from Zone.Zone import construct_model_from_dict [as 别名]
def test_zone_properties_from_dict(self):
hpk = dbHelp.setup_test_hero_using_default_values()
zd = dbHelp.create_test_zone_dict()
testZoneKey = ZoneDefinitionFields.EMPTY_SPACE
z = Zone.construct_model_from_dict(zd)
self.assertEqual(z.definitionKey, testZoneKey)
self.assertEqual(z.get_fullName(), ZoneDefinition.get_name_for_key(testZoneKey) + " Alpha")
self.assertEqual(z.suffix,"Alpha")
self.assertEqual(z.monstersKilled, 2)
self.assertEqual(z.maxMonsters,15)
self.assertEqual(z.lvl, 3)
self.assertEqual(z.get_description(),ZoneDefinition.get_description_for_key(testZoneKey))
oldCount = tu.get_record_count_from_table(ZoneDBFields.COLLECTION_NAME)
z.save_changes(hpk)
newCount = tu.get_record_count_from_table(ZoneDBFields.COLLECTION_NAME)
self.assertEqual(oldCount +1, newCount)
oldCount = tu.get_record_count_from_table(ZoneDBFields.COLLECTION_NAME)
z.save_changes(hpk)
newCount = tu.get_record_count_from_table(ZoneDBFields.COLLECTION_NAME)
self.assertEqual(oldCount, newCount)
示例4: create_test_zone_obj
# 需要导入模块: from Zone import Zone [as 别名]
# 或者: from Zone.Zone import construct_model_from_dict [as 别名]
def create_test_zone_obj(zoneKey=None):
zoneDict = create_test_zone_dict(zoneKey)
zoneObj = Zone.construct_model_from_dict(zoneDict)
return zoneObj