当前位置: 首页>>代码示例>>Python>>正文


Python Formation.initialize方法代码示例

本文整理汇总了Python中core.formation.Formation.initialize方法的典型用法代码示例。如果您正苦于以下问题:Python Formation.initialize方法的具体用法?Python Formation.initialize怎么用?Python Formation.initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core.formation.Formation的用法示例。


在下文中一共展示了Formation.initialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create

# 需要导入模块: from core.formation import Formation [as 别名]
# 或者: from core.formation.Formation import initialize [as 别名]
    def create(cls, server_id, char_id, club_name, club_flag):
        from core.staff import StaffManger
        from core.formation import Formation
        from core.mail import MailManager
        from apps.config.models import Mail as ModelMail

        doc = MongoCharacter.document()
        doc['_id'] = char_id
        doc['create_at'] = arrow.utcnow().timestamp

        doc['name'] = club_name
        doc['flag'] = club_flag
        doc['gold'] = CHAR_INIT_GOLD
        doc['diamond'] = CHAR_INIT_DIAMOND
        doc['crystal'] = CHAR_INIT_CRYSTAL
        doc['gas'] = CHAR_INIT_GAS

        sm = StaffManger(server_id, char_id)

        formation_init_data = []
        for staff_id, unit_id in CHAR_INIT_STAFFS:
            uid = sm.add(staff_id, send_notify=False, trig_signal=False)
            formation_init_data.append((uid, unit_id))

        fm = Formation(server_id, char_id)
        fm.initialize(formation_init_data)

        MongoCharacter.db(server_id).insert_one(doc)

        # add welfare mail
        start_time = get_start_time_of_today()
        condition = Q(send_at__gte=start_time.format("YYYY-MM-DD HH:mm:ssZ")) &\
                    Q(send_at__lte=arrow.utcnow().format("YYYY-MM-DD HH:mm:ssZ"))
        mails = ModelMail.objects.filter(condition)

        m = MailManager(server_id, char_id)
        for m_obj in mails:
            if not m_obj.welfare:
                continue

            ok = False
            if m_obj.condition_type == 1:
                ok = True
            elif m_obj.condition_type == 2 and server_id in m_obj.get_parsed_condition_value():
                ok = True
            elif m_obj.condition_type == 3 and server_id not in m_obj.get_parsed_condition_value():
                ok = True

            if not ok:
                continue

            if m_obj.items:
                rc = ResourceClassification.classify(m_obj.get_parsed_items())
                attachment = rc.to_json()
            else:
                attachment = ""

            m.add(m_obj.title, m_obj.content, attachment=attachment, send_notify=False)
开发者ID:yueyoum,项目名称:dianjing,代码行数:60,代码来源:club.py


注:本文中的core.formation.Formation.initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。