def test_match(self): staff_ids = ConfigStaff.INSTANCES.keys() staff_ids = random.sample(staff_ids, 10) sm = StaffManger(1, 1) for i in staff_ids: sm.add(i) Club(1, 1).set_match_staffs(staff_ids) Challenge(1, 1).start()
def test_match(self): staff_ids = ConfigStaff.INSTANCES.keys() staff_ids = random.sample(staff_ids, 10) sm = StaffManger(1, 1) for i in staff_ids: sm.add(i) Club(1, 1).set_match_staffs(staff_ids) Challenge(1, 1).start()
def test_set_staffs(self): staff_ids = random.sample(ConfigStaff.INSTANCES.keys(), 10) sm = StaffManger(1, 1) for sid in staff_ids: sm.add(sid) Club(1, 1).set_match_staffs(staff_ids) assert len(Club(1, 1).match_staffs) == 5 assert len(Club(1, 1).tibu_staffs) == 5 for c in Club(1, 1).match_staffs: assert c != 0 for c in Club(1, 1).tibu_staffs: assert c != 0
def test_set_staffs(self): staff_ids = random.sample(ConfigStaff.INSTANCES.keys(), 10) sm = StaffManger(1, 1) for sid in staff_ids: sm.add(sid) Club(1, 1).set_match_staffs(staff_ids) assert len(Club(1, 1).match_staffs) == 5 assert len(Club(1, 1).tibu_staffs) == 5 for c in Club(1, 1).match_staffs: assert c != 0 for c in Club(1, 1).tibu_staffs: assert c != 0
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)