當前位置: 首頁>>代碼示例>>Python>>正文


Python Achievement.has_prizes方法代碼示例

本文整理匯總了Python中core.achievement.Achievement.has_prizes方法的典型用法代碼示例。如果您正苦於以下問題:Python Achievement.has_prizes方法的具體用法?Python Achievement.has_prizes怎麽用?Python Achievement.has_prizes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在core.achievement.Achievement的用法示例。


在下文中一共展示了Achievement.has_prizes方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_attachment

# 需要導入模塊: from core.achievement import Achievement [as 別名]
# 或者: from core.achievement.Achievement import has_prizes [as 別名]
    def get_attachment(self, prize_id, param=0):
        # prizie_id == 1 掛機不在這裏
        if prize_id == 4:
            # 成就
            from core.achievement import Achievement

            ach = Achievement(self.char_id)
            att_msg = ach.get_reward(param)
            if ach.has_prizes():
                prize_id = None

        elif prize_id == 5:
            # 任務
            from core.task import Task

            task = Task(self.char_id)
            att_msg = task.get_reward(param)
            if task.has_prizes():
                prize_id = None

        elif prize_id == 6:
            # 官職每日登錄
            # from core.daily import OfficialDailyReward
            # od = OfficialDailyReward(self.char_id)
            # att_msg = od.get_reward()
            att_msg = None
        elif prize_id == 7:
            # 團隊本
            att_msg = None

        else:
            try:
                attachment = self.attachment.attachments[str(prize_id)]
            except KeyError:
                raise SanguoException(
                    errormsg.ATTACHMENT_NOT_EXIST, self.char_id, "Attachment Get", "{0} not exist".format(prize_id)
                )

            attachment = json.loads(attachment)
            resource = Resource(self.char_id, "Prize {0}".format(prize_id))
            standard_drop = resource.add(**attachment)

            self.attachment.attachments.pop(str(prize_id))
            self.attachment.save()

            att_msg = standard_drop_to_attachment_protomsg(standard_drop)

        # 刪除此prize_id
        if prize_id:
            if prize_id in self.attachment.prize_ids:
                self.attachment.prize_ids.remove(prize_id)
            if str(prize_id) in self.attachment.attachments:
                self.attachment.attachments.pop(str(prize_id))

        self.attachment.save()
        self.send_notify()

        return att_msg
開發者ID:yaosj,項目名稱:sanguo-server,代碼行數:60,代碼來源:attachment.py


注:本文中的core.achievement.Achievement.has_prizes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。