本文整理汇总了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)