def reset():
    logger = Logger('reset_friend_plunder_times.log')
    for f in MongoFriend.objects.all():
        friend = Friend(f.id)
        friend.daily_plunder_times_reset()

    logger.write("Friend Plunder Times Reset Done")
    logger.close()
Esempio n. 2
0
def reset():
    logger = Logger('reset_hang.log')

    for mh in MongoHang.objects.all():
        h = Hang(mh.id)
        try:
            h.cron_job()
        except:
            e = traceback.format_exc()
            logger.write("==== Exception ====")
            logger.write(e)

    logger.write("Hang Reset Done")
    logger.close()
Esempio n. 3
0
def reset():
    amount = MongoArenaWeek.objects.count()

    logger = Logger("reset_arena_week.log")
    logger.write("Reset Arena Week: Start. chars amount: {0}".format(amount))

    data = MongoArenaWeek.objects.all()
    MongoArenaWeek.objects.delete()

    for d in data:
        reward = _get_reward(d.rank)
        gold = reward.week_gold
        attachment = Attachment(d.id)
        attachment.save_to_attachment(3, gold=gold)

        achievement = Achievement(d.id)
        achievement.trig(10, d.rank)

        if d.rank in TOP_RANKS:
            try:
                top = MongoArenaTopRanks.objects.get(id=d.rank)
            except DoesNotExist:
                top = MongoArenaTopRanks(id=d.rank)

            char_name = Char(d.id).cacheobj.name
            top.name = char_name
            top.save()

    logger.write("Reset Arena Week: Complete")
    logger.close()
Esempio n. 4
0
def reset():
    logger = Logger('reset_prize.log')

    for att in MongoAttachment.objects.all():
        _changed = False
        for _rst in NEED_RESET_PRIZE_IDS:
            if _rst in att.prize_ids:
                att.prize_ids.remove(_rst)
                _changed = True

        if _changed:
            att.save()

    logger.write("Attachment Prize Reset Done")
    logger.close()
Esempio n. 5
0
def clean():
    logger = Logger("clean_active_players.log")
    logger.write("Start.")

    amount = ActivePlayers.clean_all()

    logger.write("Complete. Cleaned Amount: {0}".format(amount))
    logger.close()
Esempio n. 6
0
def clean():
    logger = Logger("clean_active_players.log")
    logger.write("Start.")

    result = ActivePlayers().clean()

    logger.write("Complete. {0}".format(result))
    logger.close()
Esempio n. 7
0
def reset():
    amount = MongoArenaWeek.objects.count()

    logger = Logger("reset_arena_week.log")
    logger.write("Reset Arena Week: Start. chars amount: {0}".format(amount))

    data = MongoArenaWeek.objects.all()
    MongoArenaWeek.objects.delete()


    for d in data:
        reward = _get_reward(d.rank)
        gold = reward.week_gold
        attachment = Attachment(d.id)
        attachment.save_to_attachment(3, gold=gold)

        achievement = Achievement(d.id)
        achievement.trig(10, d.rank)

        if d.rank in TOP_RANKS:
            try:
                top = MongoArenaTopRanks.objects.get(id=d.rank)
            except DoesNotExist:
                top = MongoArenaTopRanks(id=d.rank)

            char_name = Char(d.id).cacheobj.name
            top.name = char_name
            top.save()

    logger.write("Reset Arena Week: Complete")
    logger.close()
Esempio n. 8
0
def main():
    logger = Logger('add_plunder_times.log')
    logger.write("start")
    chars = MongoCharacter.objects.all()
    for char in chars:
        plunder = Plunder(char.id)
        plunder.change_current_plunder_times(change_value=1,
                                             allow_overflow=False)

    logger.write("add done")
    logger.close()
def clean():
    logger = Logger("clean_active_players.log")
    logger.write("Start.")

    amount = ActivePlayers.clean_all()

    logger.write("Complete. Cleaned Amount: {0}".format(amount))
    logger.close()
Esempio n. 10
0
def set_yueka():
    records = MongoPurchaseRecord.objects.all()
    logger = Logger('set_yueka.log')
    logger.write("start")

    for record in records:
        if record.yueka_remained_days > 0:
            # 发送奖励,并且days-1
            send_yueka_reward(record.id, record.yueka_sycee,
                              record.yueka_remained_days - 1)

            pa = PurchaseAction(record.id)
            try:
                pa.set_yueka_remained_days(-1)
            except YuekaLockTimeOut:
                logger.write(traceback.format_exc())

    logger.write("finish")
    logger.close()
Esempio n. 11
0
def reset():
    logger = Logger('reset_stage_elite.log')
    logger.write("Reset Stage Elite Times Start")
    for ms in MongoStage.objects.all():
        for k in ms.elites.keys():
            ms.elites[k] = 0

        ms.elites_buy = {}
        ms.save()

    logger.write("Done")
    logger.close()
Esempio n. 12
0
def main():
    logger = Logger('add_plunder_times.log')
    logger.write("start")
    chars = MongoCharacter.objects.all()
    for char in chars:
        plunder = Plunder(char.id)
        plunder.change_current_plunder_times(change_value=1, allow_overflow=False)

    logger.write("add done")
    logger.close()
Esempio n. 13
0
def set_yueka():
    records = MongoPurchaseRecord.objects.all()
    logger = Logger('set_yueka.log')
    logger.write("start")

    for record in records:
        if record.yueka_remained_days > 0:
            # 发送奖励,并且days-1
            send_yueka_reward(record.id, record.yueka_sycee, record.yueka_remained_days-1)

            pa = PurchaseAction(record.id)
            try:
                pa.set_yueka_remained_days(-1)
            except YuekaLockTimeOut:
                logger.write(traceback.format_exc())

    logger.write("finish")
    logger.close()
Esempio n. 14
0
def reset():
    for c in MongoCheckIn.objects.all():
        check = CheckIn(c.id)
        check.daily_reset()

    logger = Logger('reset_checkin.log')
    logger.write("MongoCheckin Daily Reset Done")
    logger.close()
Esempio n. 15
0
def reset():
    logger = Logger('reset_friend_plunder_times.log')
    for f in MongoFriend.objects.all():
        friend = Friend(f.id)
        friend.daily_plunder_times_reset()

    logger.write("Friend Plunder Times Reset Done")
    logger.close()
Esempio n. 16
0
def reset():
    logger = Logger('reset_arena_day.log')

    amount = redis_client.zcard(REDIS_ARENA_KEY)
    logger.write("Reset Arena Day: Start. chars amount: {0}".format(amount))

    arena_scores = redis_client.zrange(REDIS_ARENA_KEY, 0, -1, withscores=True)

    for char_id, score in arena_scores:
        attachment = _get_reward_by_score(score)
        if not attachment:
            continue

        char_id = int(char_id)
        mail = Mail(char_id)
        mail.add(MAIL_ARENA_DAY_REWARD_TITLE, MAIL_ARENA_DAY_REWARD_CONTENT, attachment=attachment)

    logger.write("Reset Arena Day: Complete")
    logger.close()
Esempio n. 17
0
def clean():
    logger = Logger("clean_mail.log")
    logger.write("Clean Mail Start.")

    DIFF = timezone.now() - datetime.timedelta(days=MAIL_KEEP_DAYS)
    mails = MongoMail.objects.all()
    amount = 0
    for m in mails:
        char_mail = Mail(m.id, mailobj=m)
        for k, v in m.mails.items():
            create_at = datetime.datetime.strptime(v.create_at, FORMAT)
            create_at = create_at.replace(tzinfo=pytz.utc)
            if create_at < DIFF:
                char_mail.delete(k)
                amount += 1

        if len(char_mail.mail.mails) == 0:
            m.delete()

    logger.write("Clean Mail Complete. Cleaned Amount: {0}".format(amount))
    logger.close()
Esempio n. 18
0
def clean():
    logger = Logger("clean_mail.log")
    logger.write("Clean Mail Start.")

    DIFF = arrow.utcnow().replace(days=-MAIL_KEEP_DAYS)
    mails = MongoMail.objects.all()
    amount = 0
    for m in mails:
        char_mail = Mail(m.id, mailobj=m)
        for k, v in m.mails.items():
            create_at = arrow.get(
                v.create_at, 'YYYY-MM-DD HH:mm:ss').replace(tzinfo=pytz.utc)
            if create_at < DIFF:
                char_mail.delete(k)
                amount += 1

        if len(char_mail.mail.mails) == 0:
            m.delete()

    logger.write("Clean Mail Complete. Cleaned Amount: {0}".format(amount))
    logger.close()
Esempio n. 19
0
def reset():
    amount = MongoArenaDay.objects.count()

    logger = Logger('reset_arena_day.log')
    logger.write("Reset Arena Day: Start. chars amount: {0}".format(amount))

    arena_day = MongoArenaDay.objects.all()
    MongoArenaDay.objects.delete()

    chars_data = []
    for ad in arena_day:
        char_id = ad.id
        char_score = ad.score
        char_power = Char(char_id).power
        chars_data.append((char_id, char_score, char_power))

    chars_data.sort(key=lambda item: (-item[1], -item[2]))

    for index, data in enumerate(chars_data):
        rank = index + 1
        char_id = data[0]
        score = data[1]

        try:
            arena_week = MongoArenaWeek.objects.get(id=char_id)
        except DoesNotExist:
            arena_week = MongoArenaWeek(id=char_id)
            arena_week.score = 0

        arena_week.score += score
        arena_week.rank = rank
        arena_week.save()

        # FIXME reward
        attachment = Attachment(char_id)
        attachment.save_to_attachment(2, gold=100)

    logger.write("Reset Arena Day: Complete")
    logger.close()
Esempio n. 20
0
def reset():
    logger = Logger('reset_prize.log')

    for att in MongoAttachment.objects.all():
        _changed = False
        for _rst in NEED_RESET_PRIZE_IDS:
            if _rst in att.prize_ids:
                att.prize_ids.remove(_rst)
                _changed = True

        if _changed:
            att.save()

    logger.write("Attachment Prize Reset Done")
    logger.close()
Esempio n. 21
0
def clean():
    logger = Logger("clean_mail.log")
    logger.write("Clean Mail Start.")

    DIFF = arrow.utcnow().replace(days=-MAIL_KEEP_DAYS)
    mails = MongoMail.objects.all()
    amount = 0
    for m in mails:
        char_mail = Mail(m.id, mailobj=m)
        for k, v in m.mails.items():
            create_at = arrow.get(v.create_at, 'YYYY-MM-DD HH:mm:ss').replace(tzinfo=pytz.utc)
            if create_at < DIFF:
                char_mail.delete(k)
                amount += 1

        if len(char_mail.mail.mails) == 0:
            m.delete()

    logger.write("Clean Mail Complete. Cleaned Amount: {0}".format(amount))
    logger.close()
Esempio n. 22
0
def reset():
    amount = redis_client.zcard(REDIS_ARENA_KEY)

    logger = Logger("reset_arena_week.log")
    logger.write("Reset Arena Week: Start. chars amount: {0}".format(amount))

    score_data = redis_client.zrevrange(REDIS_ARENA_KEY,
                                        0,
                                        -1,
                                        withscores=True)

    data = []
    for char_id, score in score_data:
        data.append((int(char_id), score, Char(int(char_id)).power))

    data.sort(key=lambda item: (-item[1], -item[2]))

    # 发送奖励
    for index, data in enumerate(data):
        rank = index + 1
        char_id = data[0]

        achievement = Achievement(char_id)
        achievement.trig(10, rank)

        attachment = _get_reward_by_rank(data[1], rank)
        if not attachment:
            continue

        mail = Mail(char_id)
        mail.add(MAIL_ARENA_WEEK_REWARD_TITLE,
                 MAIL_ARENA_WEEK_REWARD_CONTENT,
                 attachment=attachment)

    logger.write("Reset Arena Week: Complete")
    logger.close()
Esempio n. 23
0
def reset():
    amount = MongoArenaDay.objects.count()

    logger = Logger('reset_arena_day.log')
    logger.write("Reset Arena Day: Start. chars amount: {0}".format(amount))

    arena_day = MongoArenaDay.objects.all()
    MongoArenaDay.objects.delete()

    chars_data = []
    for ad in arena_day:
        char_id = ad.id
        char_score = ad.score
        char_power = Char(char_id).power
        chars_data.append((char_id, char_score, char_power))

    chars_data.sort(key=lambda item: (-item[1], -item[2]))

    for index, data in enumerate(chars_data):
        rank = index + 1
        char_id = data[0]
        score = data[1]

        try:
            arena_week = MongoArenaWeek.objects.get(id=char_id)
        except DoesNotExist:
            arena_week = MongoArenaWeek(id=char_id)
            arena_week.score = 0

        arena_week.score += score
        arena_week.rank = rank
        arena_week.save()

        # FIXME reward
        attachment = Attachment(char_id)
        attachment.save_to_attachment(2, gold=100)


    logger.write("Reset Arena Day: Complete")
    logger.close()
Esempio n. 24
0
def clean():
    now = datetime.datetime.now()
    DAY = now - datetime.timedelta(days=DAYS_DIFF)

    BATTLE_RECORD_PATH = settings.BATTLE_RECORD_PATH
    os.chdir(BATTLE_RECORD_PATH)
    amount = 0
    files = glob.glob('*.bin')
    for f in files:
        t = os.path.getctime(f)
        create_date = datetime.datetime.fromtimestamp(t)
        if create_date < DAY:
            os.unlink(f)
            amount += 1

    logger = Logger('clean_battle_record.log')
    logger.write("Clean Battle Record Done. Amount: {0}".format(amount))
    logger.close()
Esempio n. 25
0
def reset():
    MongoCounter.objects.delete()
    logger = Logger('reset_counter.log')
    logger.write("MongoCounter Clean Done")
    logger.close()
def reset():
    MongoStoreCharLimit.objects.delete()
    logger = Logger('reset_store_player_limit.log')
    logger.write("MongoStoreCharLimit Clean Done")
    logger.close()
Esempio n. 27
0
def reset():
    MongoTask.objects.delete()

    logger = Logger('reset_task.log')
    logger.write("MongoTask Clean Done")
    logger.close()