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