Example #1
0
def heroCompose(request, response):
    """
    灵魂碎片合成英雄
    """
    player = request.player
    soul_id = getattr(request.logic_request, "soulId", 0)
    info = u"灵魂碎片合成英雄"

    soul = get_soul(soul_id)

    playersoul = player.souls.get(soul_id)
    if not playersoul or not playersoul.can_sub(soul.recruitCost):
        if not playersoul:
            player.delete_soul(soul_id)
        else:
            player.update_soul(playersoul)
        AlertHandler(
            player, response,
            AlertID.ALERT_HERO_COMPOSE_SOUL_NUMBER_NOT_ENOUGH,
            u"heroCompose:soul(%s) recruitCost(%s)" %
            (soul_id, soul.recruitCost))
        return response

    playerhero = player.heroes.get(soul.recruitHeroId)
    if playerhero:
        player.update_hero(playerhero)
        AlertHandler(
            player, response, AlertID.ALERT_HERO_ALREADY_EXSIT,
            u"heroCompose:soul(%s) recruitHeroId(%s) existed" %
            (soul_id, soul.recruitHeroId))
        return response

    playersoul.sub(soul.recruitCost, info=info)

    star = int(str(soul.warrior_id)[-2:])

    new_id = soul.warrior_id / 100 * 100

    acquire_hero(player, new_id, info=info, star=star)

    if player.tutorial_id == Static.TUTORIAL_ID_HEROCOMPOSE_10:
        player.tutorial_complete()
        player.next_tutorial_open()

    return response
Example #2
0
def heroDecompose(request, response):
    """
    献祭
    """
    player = request.player
    # 包含主键数量的一个字典形式
    soul_ids = getattr(request.logic_request, "soulIds", [])

    info = u"献祭"

    soul_ids_len = len(soul_ids)

    soul_ids = dict(zip(soul_ids[0:soul_ids_len:2],
                        soul_ids[1:soul_ids_len:2]))

    for pk, number in soul_ids.items():
        playersoul = player.souls.get(pk)
        if playersoul and playersoul.can_sub(number):
            soul = get_soul(pk)
            player.add_couragepoint(soul.couragePoint * number, info=info)
            player.add_gold(soul.gold * number, info=info)
            playersoul.sub(number, info=info)

    return response
Example #3
0
 def soul(self):
     return get_soul(self.soul_id)
Example #4
0
 def soul(self):
     from module.soul.api import get_soul
     return get_soul(self.type)
Example #5
0
def acquire_hero(player, warrior_or_warrior_id, info="", **argvs):
    ''' 
    acquire player hero
    return playerhero
    return playersoulfragment
    '''
    if isinstance(warrior_or_warrior_id, Warrior):
        warrior = warrior_or_warrior_id
    elif is_digits(warrior_or_warrior_id):
        warrior = get_warrior(warrior_or_warrior_id)
        if not warrior:
            return None
    if player.heroes.get(warrior.cardId):
        soul = get_soul(warrior.hero.soulId)
        playersoul = acquire_soul(player,
                                  warrior.hero.soulId,
                                  soul.breakCost,
                                  info=info)
        return playersoul

    skillhero = get_heroskill(warrior.cardId)
    argvs["normSkillGid"] = skillhero.skill0
    argvs["normSkillLevel"] = skillhero.skill0Lv

    for i in range(0, len(skillhero.skillinfo) / 3):
        skillGiId, _, upgrade = skillhero.skillinfo[i * 3:(i + 1) * 3]
        if upgrade == 0:
            argvs["skill%sLevel" % (i + 1)] = 1
        else:
            argvs["skill%sLevel" % (i + 1)] = 0
        argvs["skill%sGid" % (i + 1)] = skillGiId

    playerhero = player.heroes.create(pk=warrior.cardId,
                                      cardId=warrior.cardId,
                                      warrior_id=warrior.id,
                                      **argvs)

    heroteamId = playerhero.warrior.hero.heroTeamId
    playerheroteam = player.heroteams.get(heroteamId)
    if not playerheroteam:
        playerheroteam = player.heroteams.create(pk=heroteamId,
                                                 teamId=heroteamId)
        player.update_heroteam(playerheroteam, True)

    player.update_hero(playerhero, True)

    player.seven_days_task_going(Static.SEVEN_TASK_CATEGORY_ACQUIRE_HREO,
                                 number=1,
                                 is_incr=True,
                                 is_series=True)
    ActionLogWriter.hero_acquire(player,
                                 playerhero.id,
                                 warrior.id,
                                 warrior.cardId,
                                 info=info)

    # 获得也可以获得高星级的英雄。同时这个也算是完成相应的任务,七天乐或者成就等
    if playerhero.star >= 3:
        player.seven_days_task_going(
            Static.SEVEN_TASK_CATEGORY_HERO_STAR_UP_GREEN3,
            number=1,
            is_incr=True,
            is_series=True)

    if playerhero.star >= 5:
        player.seven_days_task_going(
            Static.SEVEN_TASK_CATEGORY_HERO_STAR_UP_GREEN5,
            number=1,
            is_incr=True,
            is_series=True)

    if playerhero.star >= 6:
        player.task_going(Static.TASK_CATEGORY_HERO_STAR2_UPGRADE,
                          number=1,
                          is_incr=True,
                          is_series=True)

    if playerhero.star >= 7:
        player.seven_days_task_going(
            Static.SEVEN_TASK_CATEGORY_HERO_STAR_UP_BLUE2,
            number=1,
            is_incr=True,
            is_series=True)

    if playerhero.star >= 10:
        player.seven_days_task_going(
            Static.SEVEN_TASK_CATEGORY_HERO_STAR_UP_BLUE5,
            number=1,
            is_incr=True,
            is_series=True)

    if playerhero.star >= 11:
        player.task_going(Static.TASK_CATEGORY_HERO_STAR3_UPGRADE,
                          number=1,
                          is_incr=True,
                          is_series=True)
        player.seven_days_task_going(
            Static.SEVEN_TASK_CATEGORY_HERO_STAR_UP_PURPLE,
            number=1,
            is_incr=True,
            is_series=True)

    if playerhero.star >= 16:
        player.task_going(Static.TASK_CATEGORY_HERO_STAR5_UPGRADE,
                          number=1,
                          is_incr=True,
                          is_series=True)

    return playerhero