Exemple #1
0
    def get_plunder_times(self, sender_id):
        if sender_id not in self.mf.plunder_senders:
            raise SanguoException(
                errormsg.FRIEND_GET_PLUNDER_TIMES_NOT_EXIST, self.char_id,
                "Friend Get Plunder Times",
                "{0} try to get plunder times, buy {1} not give".format(
                    self.char_id, sender_id))

        if sender_id in self.mf.plunder_gots:
            raise SanguoException(
                errormsg.FRIEND_GET_PLUNDER_TIMES_ALREADY_GOT, self.char_id,
                "Friend Get Plunder Times",
                "{0} try to get plunder times, buy already got from {1}".
                format(self.char_id, sender_id))

        if len(self.mf.plunder_gots) >= self.max_amount:
            raise SanguoException(
                errormsg.PLUNDER_GET_TIMES_FULL, self.char_id,
                "Friend Get Plunder Times",
                "{0} try to get plunder times, buy already reach max friends amount"
                .format(self.char_id))

        self.mf.plunder_senders.remove(sender_id)
        self.mf.plunder_gots.append(sender_id)
        self.mf.save()

        p = Plunder(self.char_id)
        p.change_current_plunder_times(change_value=1, allow_overflow=True)

        self.send_update_friend_notify(sender_id)
Exemple #2
0
    def get_plunder_times(self, sender_id):
        if sender_id not in self.mf.plunder_senders:
            raise SanguoException(
                errormsg.FRIEND_GET_PLUNDER_TIMES_NOT_EXIST,
                self.char_id,
                "Friend Get Plunder Times",
                "{0} try to get plunder times, buy {1} not give".format(self.char_id, sender_id)
            )

        if sender_id in self.mf.plunder_gots:
            raise SanguoException(
                errormsg.FRIEND_GET_PLUNDER_TIMES_ALREADY_GOT,
                self.char_id,
                "Friend Get Plunder Times",
                "{0} try to get plunder times, buy already got from {1}".format(self.char_id, sender_id)
            )

        if len(self.mf.plunder_gots) >= self.max_amount:
            raise SanguoException(
                errormsg.PLUNDER_GET_TIMES_FULL,
                self.char_id,
                "Friend Get Plunder Times",
                "{0} try to get plunder times, buy already reach max friends amount".format(self.char_id)
            )


        self.mf.plunder_senders.remove(sender_id)
        self.mf.plunder_gots.append(sender_id)
        self.mf.save()

        p = Plunder(self.char_id)
        p.change_current_plunder_times(change_value=1, allow_overflow=True)

        self.send_update_friend_notify(sender_id)
Exemple #3
0
def _vip_change(char_id, old_vip, new_vip, **kwargs):
    Prison(char_id).vip_changed(new_vip)
    m = Mail(char_id)
    m.add(name=MAIL_VIP_CHANGED_TITLE, content=MAIL_VIP_CHANGED_CONTENT.format(new_vip))

    # 增加掠夺次数
    plunder_times_change_value = VIP_FUNCTION[new_vip].plunder - VIP_FUNCTION[old_vip].plunder
    if plunder_times_change_value:
        plunder = Plunder(char_id)
        plunder.change_current_plunder_times(plunder_times_change_value, allow_overflow=True)

    vip_activies = []
    if has_activity(22001):
        vip_activies.append(22001)
    if has_activity(40007):
        vip_activies.append(40007)
    if has_activity(40008):
        vip_activies.append(40008)
    if has_activity(50006):
        vip_activies.append(50006)

    if vip_activies:
        ActivityStatic(char_id).send_update_notify(activity_ids=vip_activies)

    ae = ActivityEntry(char_id, 50006)
    if ae and ae.is_valid():
        ae.enable(new_vip)
        ActivityStatic(char_id).send_update_notify(activity_ids=[50006])
Exemple #4
0
def _vip_change(char_id, old_vip, new_vip, **kwargs):
    Prison(char_id).vip_changed(new_vip)
    m = Mail(char_id)
    m.add(name=MAIL_VIP_CHANGED_TITLE, content=MAIL_VIP_CHANGED_CONTENT.format(new_vip))

    # 增加掠夺次数
    plunder_times_change_value = VIP_FUNCTION[new_vip].plunder - VIP_FUNCTION[old_vip].plunder
    if plunder_times_change_value:
        plunder = Plunder(char_id)
        plunder.change_current_plunder_times(plunder_times_change_value, allow_overflow=True)
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()
Exemple #6
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()
Exemple #7
0
def add_times(signum):
    hour = arrow.utcnow().to(settings.TIME_ZONE).hour
    if hour >= 1 and hour < 8:
        return

    logger = Logger('add_plunder_times.log')
    logger.write("Start")

    char_ids = get_char_ids_by_last_login(limit=3)
    for char_id in char_ids:
        plunder = Plunder(char_id)
        try:
            plunder.change_current_plunder_times(change_value=1, allow_overflow=False)
        except:
            logger.error(traceback.format_exc())

    logger.write("add done")
    logger.close()
def add_times(signum):
    hour = arrow.utcnow().to(settings.TIME_ZONE).hour
    if hour >= 1 and hour < 8:
        return

    logger = Logger('add_plunder_times.log')
    logger.write("Start")

    char_ids = get_char_ids_by_last_login(limit=3)
    for char_id in char_ids:
        plunder = Plunder(char_id)
        try:
            plunder.change_current_plunder_times(change_value=1,
                                                 allow_overflow=False)
        except:
            logger.error(traceback.format_exc())

    logger.write("add done")
    logger.close()