Exemplo n.º 1
0
def step_up(request):
    char_id = request._char_id
    heros_dict = char_heros_dict(char_id)

    req = request._proto
    _id = req.id

    if _id not in heros_dict:
        raise SanguoException(
            errormsg.HERO_NOT_EXSIT,
            char_id,
            "Hero Step Up",
            "hero {0} not belong to char {1}".format(_id, char_id)
        )

    h = Hero(_id)
    h.step_up()

    response = HeroStepUpResponse()
    response.ret = 0
    response.id = _id
    response.step = h.step
    response.max_socket_amount = h.max_socket_amount
    response.current_socket_amount = h.current_socket_amount
    return pack_msg(response)
Exemplo n.º 2
0
def _hero_change(hero_id, **kwargs):
    hero = Hero(hero_id)
    hero.save_cache()

    update_hero_notify(
        hero.char_id,
        [hero,]
    )
Exemplo n.º 3
0
def wuxing_update(request):
    req = request._proto

    hero_id = req.hero_id
    wuxing_id = req.wuxing_id
    souls = [(s.id, s.amount) for s in req.souls]

    h = Hero(hero_id)
    h.wuxing_update(wuxing_id, souls)
    return None
Exemplo n.º 4
0
def wuxing_update(request):
    req = request._proto

    hero_id = req.hero_id
    wuxing_id = req.wuxing_id
    souls = [(s.id, s.amount) for s in req.souls]

    h = Hero(hero_id)
    h.wuxing_update(wuxing_id, souls)
    return None
Exemplo n.º 5
0
def _char_level_up(char_id, new_level, **kwargs):
    heros_dict = char_heros_dict(char_id)

    achievement = Achievement(char_id)
    achievement.trig(18, new_level)

    heros = []
    for hid in heros_dict.keys():
        h = Hero(hid)
        h.save_cache()
        heros.append(h)

    update_hero_notify(char_id, heros)

    activity_stage = ActivityStage(char_id)
    activity_stage.check(new_level)
Exemplo n.º 6
0
def _hero_add(char_id, hero_ids, hero_original_ids, send_notify, **kwargs):
    if send_notify:
        heros = [Hero.cache_obj(i) for i in hero_ids]
        add_hero_notify(char_id, heros)

    heros_dict = char_heros_dict(char_id)

    achievement = Achievement(char_id)
    achievement.trig(1, len(heros_dict), send_notify=send_notify)

    quality_one_heros_amount = 0
    quality_two_heros_amount = 0
    quality_three_heros_amount = 0
    gender_female_heros_amount = 0


    for h in heros_dict.values():
        original_hero = HEROS[h.oid]
        if original_hero.quality == 1:
            quality_one_heros_amount += 1
        if original_hero.quality == 2:
            quality_two_heros_amount += 1
        if original_hero.quality == 3:
            quality_three_heros_amount += 1
        if original_hero.gender == 2:
            gender_female_heros_amount += 1

    achievement.trig(2, quality_one_heros_amount, send_notify=send_notify)
    achievement.trig(3, quality_two_heros_amount, send_notify=send_notify)
    achievement.trig(4, quality_three_heros_amount, send_notify=send_notify)
    achievement.trig(5, gender_female_heros_amount, send_notify=send_notify)

    ActivityStatic(char_id).trig(2001)
    ActivityStatic(char_id).trig(8001)
    ActivityStatic(char_id).trig(30003)
Exemplo n.º 7
0
def _char_level_up(char_id, new_level, **kwargs):
    heros_dict = char_heros_dict(char_id)

    achievement = Achievement(char_id)
    achievement.trig(18, new_level)

    heros = []
    for hid in heros_dict.keys():
        h = Hero(hid)
        h.save_cache()
        heros.append(h)

    update_hero_notify(char_id, heros)

    activity_stage = ActivityStage(char_id)
    activity_stage.check(new_level)
Exemplo n.º 8
0
def _hero_add(char_id, hero_ids, hero_original_ids, send_notify, **kwargs):
    if send_notify:
        heros = [Hero.cache_obj(i) for i in hero_ids]
        add_hero_notify(char_id, heros)

    heros_dict = char_heros_dict(char_id)

    achievement = Achievement(char_id)
    achievement.trig(1, len(heros_dict), send_notify=send_notify)

    quality_one_heros_amount = 0
    quality_two_heros_amount = 0
    quality_three_heros_amount = 0
    gender_female_heros_amount = 0

    for h in heros_dict.values():
        original_hero = HEROS[h.oid]
        if original_hero.quality == 1:
            quality_one_heros_amount += 1
        if original_hero.quality == 2:
            quality_two_heros_amount += 1
        if original_hero.quality == 3:
            quality_three_heros_amount += 1
        if original_hero.gender == 2:
            gender_female_heros_amount += 1

    achievement.trig(2, quality_one_heros_amount, send_notify=send_notify)
    achievement.trig(3, quality_two_heros_amount, send_notify=send_notify)
    achievement.trig(4, quality_three_heros_amount, send_notify=send_notify)
    achievement.trig(5, gender_female_heros_amount, send_notify=send_notify)

    ActivityStatic(char_id).trig(2001)
    ActivityStatic(char_id).trig(8001)
    ActivityStatic(char_id).trig(30003)
Exemplo n.º 9
0
def step_up(request):
    char_id = request._char_id
    heros_dict = char_heros_dict(char_id)

    req = request._proto
    _id = req.id

    if _id not in heros_dict:
        raise SanguoException(
            errormsg.HERO_NOT_EXSIT,
            char_id,
            "Hero Step Up",
            "hero {0} not belong to char {1}".format(_id, char_id)
        )

    h = Hero(_id)
    h.step_up()
    return None
Exemplo n.º 10
0
 def power(self):
     f = Formation(self.id)
     hero_ids = f.in_formation_hero_ids()
     p = 0
     for hid in hero_ids:
         if hid == 0:
             continue
         h = Hero.cache_obj(hid)
         p += h.power
     return p
Exemplo n.º 11
0
 def power(self):
     f = Formation(self.id)
     hero_ids = f.in_formation_hero_ids()
     p = 0
     for hid in hero_ids:
         if hid == 0:
             continue
         h = Hero.cache_obj(hid)
         p += h.power
     return p
Exemplo n.º 12
0
def step_up(request):
    char_id = request._char_id
    heros_dict = char_heros_dict(char_id)

    req = request._proto
    _id = req.id

    if _id not in heros_dict:
        raise SanguoException(
            errormsg.HERO_NOT_EXSIT, char_id, "Hero Step Up",
            "hero {0} not belong to char {1}".format(_id, char_id))

    h = Hero(_id)
    h.step_up()

    response = HeroStepUpResponse()
    response.ret = 0
    response.id = _id
    response.step = h.step
    response.max_socket_amount = h.max_socket_amount
    response.current_socket_amount = h.current_socket_amount
    return pack_msg(response)
Exemplo n.º 13
0
    def _msg_friend(self, msg, fid, status):
        char_f = Char(fid)
        cache_f = char_f.cacheobj
        msg.id = fid
        msg.name = cache_f.name
        msg.level = cache_f.level
        msg.official = cache_f.official
        if status == FRIEND_OK or status == FRIEND_NOT:
            msg.power = char_f.power

        msg.status = status

        f = Formation(fid)
        in_formation_hero_ids = [h for h in f.in_formation_hero_ids() if h]
        hero_list = [(Hero.cache_obj(hid).power, hid) for hid in in_formation_hero_ids]
        hero_list.sort(key=lambda item: -item[0])
        leader_oid = Hero.cache_obj(hero_list[0][1]).oid

        if status == FRIEND_OK:
            f = Formation(fid)
            msg.formation.extend(f.in_formation_hero_original_ids())

        msg.leader = leader_oid
Exemplo n.º 14
0
    def _msg_friend(self, msg, fid, status):
        char_f = Char(fid)
        cache_f = char_f.cacheobj
        msg.id = fid
        msg.name = cache_f.name
        msg.level = cache_f.level
        msg.official = cache_f.official
        if status == FRIEND_OK or status == FRIEND_NOT:
            msg.power = char_f.power

        msg.status = status

        f = Formation(fid)
        in_formation_hero_ids = [h for h in f.in_formation_hero_ids() if h]
        hero_list = [(Hero.cache_obj(hid).power, hid)
                     for hid in in_formation_hero_ids]
        hero_list.sort(key=lambda item: -item[0])
        leader_oid = Hero.cache_obj(hero_list[0][1]).oid

        if status == FRIEND_OK:
            f = Formation(fid)
            msg.formation.extend(f.in_formation_hero_original_ids())

        msg.leader = leader_oid

        if status == FRIEND_OK and fid not in self.mf.plunder_gives:
            msg.can_give_plunder_times = True
        else:
            msg.can_give_plunder_times = False

        if fid in self.mf.plunder_senders:
            msg.got_plunder_times_status = MsgFriend.CAN_GET
        elif fid in self.mf.plunder_gots:
            msg.got_plunder_times_status = MsgFriend.ALREADY_GET
        else:
            msg.got_plunder_times_status = MsgFriend.CAN_NOT_GET
Exemplo n.º 15
0
    def __init__(self, _id):
        hero = Hero.cache_obj(_id)
        self.id = _id
        self.real_id = _id
        self.original_id = hero.oid
        self.attack = hero.attack
        self.defense = hero.defense
        self.hp = hero.hp
        self.crit = hero.crit
        self.dodge = 0

        self.anger = hero.anger

        self.level = hero.level
        self.skills = hero.skills

        self.default_skill = hero.default_skill

        super(BattleHero, self).__init__()
Exemplo n.º 16
0
    def __init__(self, _id):
        hero = Hero.cache_obj(_id)
        self.id = _id
        self.real_id = _id
        self.original_id = hero.oid
        self.attack = hero.attack
        self.defense = hero.defense
        self.hp = hero.hp
        self.crit = hero.crit
        self.dodge = 0

        self.anger = hero.anger

        self.level = hero.level
        self.skills = hero.skills

        self.default_skill = hero.default_skill

        super(BattleHero, self).__init__()
Exemplo n.º 17
0
    def __init__(self, _id):
        hero = Hero.cache_obj(_id)
        self.id = _id
        self.real_id = _id
        self.original_id = hero.oid
        self.attack = hero.attack
        self.defense = hero.defense
        self.hp = hero.hp
        self.crit = hero.crit
        self.dodge = 0

        self.anger = hero.anger

        self.level = hero.level
        self.skills = hero.skills

        self.default_skill = hero.default_skill
        self.wuxings = [(int(k), v.level) for k, v in hero.hero.wuxings.iteritems()]

        super(BattleHero, self).__init__()
Exemplo n.º 18
0
    def __init__(self, _id):
        hero = Hero.cache_obj(_id)
        self.id = _id
        self.real_id = _id
        self.original_id = hero.oid
        self.attack = hero.attack
        self.defense = hero.defense
        self.hp = hero.hp
        self.crit = hero.crit
        self.dodge = 0

        self.anger = hero.anger

        self.level = hero.level
        self.skills = hero.skills

        self.default_skill = hero.default_skill
        self.wuxings = [(int(k), v.level) for k, v in hero.hero.wuxings.iteritems()]

        super(BattleHero, self).__init__()