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