本文整理汇总了Python中core.resource.ResourceClassification.load_from_json方法的典型用法代码示例。如果您正苦于以下问题:Python ResourceClassification.load_from_json方法的具体用法?Python ResourceClassification.load_from_json怎么用?Python ResourceClassification.load_from_json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.resource.ResourceClassification
的用法示例。
在下文中一共展示了ResourceClassification.load_from_json方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_station_notify
# 需要导入模块: from core.resource import ResourceClassification [as 别名]
# 或者: from core.resource.ResourceClassification import load_from_json [as 别名]
def send_station_notify(self):
notify = BaseStationNotify()
notify.level = self.doc['level']
notify.exp = self.doc['exp']
notify.next_reward_at = get_station_next_reward_at()
drop = self.doc.get('drop', '')
if drop:
notify.drop.MergeFrom(ResourceClassification.load_from_json(drop).make_protomsg())
notify.product_level = self.doc['product_level']
notify.product_lost_percent = self.doc['loss_percent']
MessagePipe(self.char_id).put(msg=notify)
示例2: send_notify
# 需要导入模块: from core.resource import ResourceClassification [as 别名]
# 或者: from core.resource.ResourceClassification import load_from_json [as 别名]
def send_notify(self, ids=None):
if ids:
projection = {"mails.{0}".format(i): 1 for i in ids}
act = ACT_UPDATE
else:
projection = {"mails": 1}
act = ACT_INIT
doc = MongoMail.db(self.server_id).find_one({'_id': self.char_id}, projection)
notify = MailNotify()
notify.act = act
limit_timestamp = get_mail_clean_time().timestamp
for k, v in doc['mails'].iteritems():
notify_mail = notify.mails.add()
notify_mail.id = k
if v['from_id']:
# char
notify_mail.mail_from.from_type = MAIL_FROM_USER
# XXX
notify_mail.mail_from.club.MergeFrom(Club(self.server_id, v['from_id']).make_protomsg())
else:
notify_mail.mail_from.from_type = MAIL_FROM_SYSTEM
notify_mail.title = v['title']
notify_mail.content = v['content']
notify_mail.has_read = v['has_read']
notify_mail.create_at = v['create_at']
notify_mail.function = v['function']
if v.get('data', None):
notify_mail.data = base64.b64decode(v['data'])
remained_seconds = v['create_at'] - limit_timestamp
if remained_seconds < 0:
remained_seconds = 0
notify_mail.remained_seconds = remained_seconds
if v['attachment']:
notify_mail.attachment.MergeFrom(ResourceClassification.load_from_json(v['attachment']).make_protomsg())
function = v.get('function', 0)
if function:
notify_mail.function = function
MessagePipe(self.char_id).put(msg=notify)
示例3: get_station_product
# 需要导入模块: from core.resource import ResourceClassification [as 别名]
# 或者: from core.resource.ResourceClassification import load_from_json [as 别名]
def get_station_product(self):
drop = self.doc.get('drop', '')
if not drop:
raise GameException(ConfigErrorMessage.get_error_id("INVALID_OPERATE"))
rc = ResourceClassification.load_from_json(drop)
rc.add(self.server_id, self.char_id, message="Plunder.get_station_product")
self.doc['drop'] = ''
MongoPlunder.db(self.server_id).update_one(
{'_id': self.char_id},
{'$set': {
'drop': ''
}}
)
self.send_station_notify()
return rc
示例4: get_attachment
# 需要导入模块: from core.resource import ResourceClassification [as 别名]
# 或者: from core.resource.ResourceClassification import load_from_json [as 别名]
def get_attachment(self, mail_id):
this_mail = self.get_mail(mail_id)
if not this_mail:
raise GameException(ConfigErrorMessage.get_error_id("MAIL_NOT_EXISTS"))
attachment = this_mail['attachment']
if not attachment:
raise GameException(ConfigErrorMessage.get_error_id("MAIL_HAS_NO_ATTACHMENT"))
rc = ResourceClassification.load_from_json(attachment)
rc.add(self.server_id, self.char_id, message="MailManager.get_attachment")
MongoMail.db(self.server_id).update_one(
{'_id': self.char_id},
{'$set': {'mails.{0}.attachment'.format(mail_id): ""}}
)
self.send_notify(ids=[mail_id])
return rc