Beispiel #1
0
def vipRewardsGet(request, response):
    player = request.player
    vip_level = getattr(request.logic_request, "vipLevel", 0)
    vip_level = int(vip_level)

    if not player.can_buy_vip_bag(vip_level) and vip_level > 0:

        AlertHandler(
            player, response, AlertID.ALERT_VIP_CAN_NOT_BUY,
            u"vipRewardsGet:vipLevel(%s) playerVipLevel(%s) can_buy_vip_bag" %
            (vip_level, player.vip_level))
        return response

    vip = get_vip(vip_level)
    if player.yuanbo < vip.giftBagDiamond:
        AlertHandler(
            player, response, AlertID.ALERT_DIAMOND_NOT_ENOUGH,
            u"vipRewardsGet:vipLevel(%s) playerVipLevel(%s) price(%s) playerYuanbo(%s)"
            % (vip_level, player.vip_level, vip.giftBagDiamond, player.yuanbo))
        return response

    player.buy_vip_bag(vip_level)
    rewards = vip.giftRewards
    info = u"VIP礼包:%s" % vip_level
    for reward in rewards:
        reward_send(player, reward, info)
    player.sub_yuanbo(vip.giftBagDiamond, info)
    response.common_response.player.set("vip", player.vip)
    return response
Beispiel #2
0
def pvpResetCount(request, response):
    '''
    pvp
    '''
    player = request.player

    #玩家没有到达PVP建筑开启等级
    if not player.isOpenArena:
        AlertHandler(
            player, response, AlertID.ALERT_LEVEL_SHORTAGE,
            u"pvpOpps:playerLevel(%s) startLevel(%s)" %
            (player.level, Static.PVP_LEVEL))
        return response

    vip = get_vip(player.vip_level)

    if player.PVP.resetCount >= vip.resetPVPCount:
        AlertHandler(
            player, response, AlertID.ALERT_RESET_PVP_COUNT_NOT_ENOUGH,
            u"pvpResetCount:player pvpResetCount(%s) >= now VIP can have (%s)"
            % (player.PVP.resetCount, vip.resetPVPCount))
    needDiamond = player.PVP.resetCost

    if player.yuanbo < needDiamond:
        AlertHandler(
            player, response, AlertID.ALERT_DIAMOND_NOT_ENOUGH,
            u"pvpResetCount:player has (%s) reset PVP need (%s)" %
            (player.yuanbo, needDiamond))
        return response

    player.PVP.resetPVPCount()
    player.sub_yuanbo(needDiamond, info=u"竞技场重置")
    response.common_response.player.set("arena", player.PVP.to_dict())

    return response
Beispiel #3
0
def taskDailyReward(request, response):
    """
    日常任务领取
    """
    player = request.player
    task_id = getattr(request.logic_request, "taskId", 0)
    task_id = int(task_id)
    task = get_dailytask(task_id)

    if player.dailytask_is_done(task.category):
        player.dailytask_done(task.category)

        #扫荡券
        if task.is_vip_sweep:
            vip = get_vip(player.vip_level)
            acquire_item(player,
                         Static.ITEM_SWEEP_ID,
                         number=vip.sweepCount,
                         info=u"VIP领取")
        else:
            for reward in task.rewards:
                reward_send(player, reward, info=u"日常任务领取")
    else:
        player.update_dailytask(task.category)
        AlertHandler(player, response, AlertID.ALERT_DAILYTASK_UNDONE,
                     u"taskDailyReward:taskGid(%s) is not done" % (task_id))

    return response
Beispiel #4
0
def instanceReset(request, response):
    '''
    刷新副本次数
    '''
    #type = 1 普通 2 精英
    player = request.player
    level_id = getattr(request.logic_request, "instanceId", 0)
    category = getattr(request.logic_request, "category", 0)


    if category == 1:
        isElite = False
        instancelevel = get_instancelevel(level_id)
    elif category == 2:
        isElite = True
        instancelevel = get_eliteinstancelevel(level_id)
    else:
        raise ErrorException(player, u"instance reset category error (%s)" % level_id)

    if isElite:
        playerinstancelevel = player.eliteinstancelevels.get(instancelevel.pk)
    else:
        playerinstancelevel = player.instancelevels.get(instancelevel.pk)

    if not playerinstancelevel:
        AlertHandler(player, response, AlertID.ALERT_INSTANCE_NOT_OPEN, u"instanceReset:instance(%s) is not open" % level_id)
        return response


    vip = get_vip(player.vip_level)
    if playerinstancelevel.refreshCount >= vip.resetElitInstanceCount:
        AlertHandler(player, response, AlertID.ALERT_INSTANCE_REFRESH_COUNT_EXCEED_MAX, u"instanceReset:instance(%s) refresh count(%s) exceed max(%s)" % (level_id, playerinstancelevel.refreshCount , vip.resetElitInstanceCount))
        return response

    cost_diamond = Static.REFRESH_INSTANCE_COST * (playerinstancelevel.refreshCount + 1)

    if player.yuanbo < cost_diamond:
        AlertHandler(player, response, AlertID.ALERT_DIAMOND_NOT_ENOUGH, u"instanceReset:instance(%s) refresh costDiamond(%s) playerDiamond(%s)" % (level_id, cost_diamond,  player.yuanbo ))
        return response

    player.sub_yuanbo(cost_diamond, info=u"重置副本次数")
    playerinstancelevel.refresh_count()

    if isElite:
        player.update_eliteinstancelevel(playerinstancelevel, True)
    else:
        player.update_instancelevel(playerinstancelevel, True)

    return response
Beispiel #5
0
def buildingPlantBuild(request, response):
    """
    创建植物
    """
    centerX = getattr(request.logic_request, "centerX", 0)
    centerY = getattr(request.logic_request, "centerY", 0)
    building_id = getattr(request.logic_request, "buildingId", -1) # building 表主键
    player = request.player

    buildingplant = get_buildingplant_by_buildingid(building_id)
    if not buildingplant:
        raise ErrorException(player, u"buildingBuild:plant(%s) is not existed" % building_id)

    building = get_building(building_id)
    #检查单个植物总数
    building_count = get_building_count_by_level(building, player.castleLevel)
    if building_count <= 0:
        raise ErrorException(player, u"buildingBuild:plant(%s) create allow number is %s" % (building_id, building_count))
        return response
    playerbuilding_count = player.get_plants_count(buildingplant.pk)
    if playerbuilding_count >= building_count:
        AlertHandler(player, response, AlertID.ALERT_BUILDING_BUILD_OVER_MAX_NUMBER, u"buildingBuild:building(%s) create allow number is %s , already building number is %s" % (building_id, building_count, playerbuilding_count))
        return response
    #检查植物总数
    vip = get_vip(player.vip_level)
    if len(player.buildingplants.all()) >= vip.plantCount:
        AlertHandler(player, response, AlertID.ALERT_BUILDING_BUILD_OVER_MAX_NUMBER, u"buildingBuild:building(%s) create allow number is %s , already building number is %s" % (building_id, vip.plantCount, len(player.buildingplants.all())))
        return response
    #创建消耗检查
    costs = buildingplant.costs
    for cost in costs:  
        playeritem = player.items.get(cost.type)
        if not playeritem:
            raise ErrorException(player, u"itemUse:playeritem(%s) no existed" % (playeritem.pk))
        if not playeritem.can_sub(cost.count):
            #更新数据
            player.update_item(playeritem)
            AlertHandler(player, response, AlertID.ALERT_ITEM_NOT_ENOUGH,  u"itemUse:item(%s) playeritem(%s) useCount(%s) count(%s)" % (playeritem.item_id,cost.type, cost.count, playeritem.count))
            return response
        playeritem.sub(cost.count, u"物品使用")
    info = u"创建植物"
    playerbuildingplant = acquire_buildingplant(player, buildingplant, centerX = centerX, centerY = centerY, status = 0, buildingId = building_id)
    ActionLogWriter.building_create(player, playerbuildingplant.pk, playerbuildingplant.plantId, info)

    return response
Beispiel #6
0
def get_player_open_raidinstance(player):
    '''
    过去开放的活动副本数据
    '''
    open_player_raidinstances = []
    # 先取得所有活动副本的信息。
    raidinstances = get_raidinstances()
    for raidinstance in raidinstances:
        # 通过里面的experiment1这个字段取判断活动副本是否开启
        if not raidinstance.experiment1 or check_player_in_experiment_by_experimentname(
                player.id, raidinstance.experiment1):
            _, playerraidinstance = player.raidinstances.get_or_create(
                raidinstance.id)
            data = {}
            data["type"] = playerraidinstance.level_id
            data["playCount"] = playerraidinstance.succeedCount
            # 根据vip等级限定次数
            vip = get_vip(player.vip_level)
            data["maxCount"] = vip.titanCount
            data["isDouble"] = check_player_in_experiment_by_experimentname(
                player.id, raidinstance.experiment2)
            open_player_raidinstances.append(data)

    return open_player_raidinstances
Beispiel #7
0
def buildingBuild(request, response):
    '''
    创建建筑
    '''
    centerX = getattr(request.logic_request, "centerX", 0)
    centerY = getattr(request.logic_request, "centerY", 0)
    building_id = getattr(request.logic_request, "buildingId", -1)

    player = request.player

    building = get_building(building_id)
    if not building:
        raise ErrorException(
            player, u"buildingBuild:building(%s) is not existed" % building_id)

    building_upgrade = get_building_upgrade_by_building_and_level(building, 0)
    #能否升级等级检查
    if not building_upgrade:
        raise ErrorException(
            player,
            u"buildingBuild:building(%s) can not be created" % building_id)

    if building.is_castle:
        if building_upgrade.userLevel > player.level:
            AlertHandler(
                player, response, AlertID.ALERT_PLAYER_LEVEL_NOT_ENOUGH,
                u"buildingBuild:building(%s) upgrade  needlevel(%s) playerlevel(%s)"
                % (building_id, building_upgrade.userLevel, player.level))
            return response

    elif building_upgrade.castleLevel > player.castleLevel:
        AlertHandler(
            player, response, AlertID.ALERT_BUILDING_CASTLE_LEVEL_NOT_ENOUGH,
            u"buildingBuild:building(%s) upgrade  needlevel(%s) playercastlelevel(%s)"
            % (building_id, building_upgrade.castleLevel, player.castleLevel))
        return response

    #建造数量检查
    building_count = get_building_count_by_level(building, player.castleLevel)
    if building_count <= 0:
        AlertHandler(
            player, response, AlertID.ALERT_PLAYER_LEVEL_NOT_ENOUGH,
            u"buildingBuild:building(%s) create allow number is %s" %
            (building_id, building_count))
        return response
    #建造数量上限检查
    playerbuilding_count = player.get_buildings_count(building.pk)
    if playerbuilding_count >= building_count:
        AlertHandler(
            player, response, AlertID.ALERT_BUILDING_BUILD_OVER_MAX_NUMBER,
            u"buildingBuild:building(%s) create allow number is %s , already building number is %s"
            % (building_id, building_count, playerbuilding_count))
        return response

    #能否升级消耗检查
    for cost in building_upgrade.costs:
        if not reward_cost_check(player, cost):
            if building.is_statue:
                AlertHandler(
                    player, response,
                    AlertID.ALERT_BUILDING_MATERIAL_NOT_ENOUGH,
                    u"buildingBuild:building(%s) create cost(%s) is error" %
                    (building_id, cost.pk))
                return response
            AlertHandler(
                player, response, AlertID.ALERT_BUILDING_MATERIAL_NOT_ENOUGH,
                u"buildingBuild:building(%s) create cost(%s) is error" %
                (building_id, cost.pk))
            return response

    #建造神像数量检查
    if building.is_statue:
        #神像总数的检查
        vip = get_vip(player.vip_level)
        if player.get_statue_count(building_id) >= vip.statueCount:
            AlertHandler(
                player, response, AlertID.ALERT_BUILDING_BUILD_OVER_MAX_NUMBER,
                u"buildingBuild:building(%s) create allow number is %s , already building number is %s"
                % (building_id, Static.STATUE_MAX_COUNT,
                   player.get_statue_count()))
            return response

    info = u"建造:%s" % building.name
    for cost in building_upgrade.costs:
        reward_cost(player, cost, info)

    playerbuilding = acquire_building(player,
                                      building,
                                      centerX=centerX,
                                      centerY=centerY,
                                      status=0,
                                      info=info)
    #神像刚建造时
    building_upgrade = get_building_upgrade_by_building_and_level(
        playerbuilding.building, playerbuilding.level)

    # 建造铁匠铺
    if building.is_blacksmith:
        if player.tutorial_id == Static.TUTORIAL_ID_BLACK_SMITH_5:
            player.tutorial_complete()
            player.next_tutorial_open()
    #  建造金矿
    if building.is_goldmine:
        if player.tutorial_id == Static.TUTORIAL_ID_GOLDEN_7:
            player.tutorial_complete()
            player.next_tutorial_open()
    # 建造伐木场
    if building.is_loggingfield:
        if player.tutorial_id == Static.TUTORIAL_ID_LOGFIELD_8:
            player.tutorial_complete()

    if building.is_tarven:
        if player.tutorial_id == Static.TUTORIAL_ID_TAVERN_9:
            player.tutorial_complete()
            player.next_tutorial_open()

    if building.is_arena:
        if player.tutorial_id == Static.TUTORIAL_ID_ARENA_BUILD_17:
            player.tutorial_complete()
        player.setArenaOpen()  #玩家可以被其他人搜索到
        player.PVP.reset_daily_data()
        player.arenashop.refresh_auto()
        response.common_response.player.set("honorShop",
                                            player.arenashop.to_dict())
        response.common_response.player.set("arena", player.PVP.to_dict())

    if building.is_elementtower:
        player.elementTower.init()
        response.common_response.player.set("elementTower",
                                            player.elementTower.to_dict())

    # 战争图腾建造 开启1700新手引导
    if building.is_hordelab:
        player.start_tutorial_by_id(Static.TUTORIAL_ID_INSTANCE_16)

    # 上古遗迹建造 开启1800新手引导
    if building.is_taitan:
        player.start_tutorial_by_id(Static.TUTORIAL_ID_INSTANCE_17)

    # 全视之眼建造 开启1900新手引导
    if building.is_radar:
        player.start_tutorial_by_id(Static.TUTORIAL_ID_INSTANCE_18)
        player.setSiegeOpen()  #玩家可以被其他人搜到
        #城墙
        acquire_building(player,
                         1002002,
                         level=1,
                         centerX=0,
                         centerY=0,
                         status=0,
                         info=info)
        #城墙配置点
        point = player.castleLevel < 10 and range(1, 4) or range(0, 5)
        defenseSiegeSoldierIds = player.castleLevel < 10 and [-1, 0, 0, 0, -1
                                                              ] or [
                                                                  0, 0, 0, 0, 0
                                                              ]
        for i in point:
            acquire_building(player,
                             1002003,
                             level=1,
                             centerX=i,
                             centerY=0,
                             status=0,
                             info=info)
        #防御塔配置点
        for i in range(2):
            acquire_building(player,
                             1002004,
                             level=1,
                             centerX=i,
                             centerY=0,
                             status=0,
                             info=info)
        player.update_siege_defenseSoldierIds(defenseSiegeSoldierIds)
        response.common_response.player.set("defenseSiegeSoldierIds",
                                            defenseSiegeSoldierIds)
        response.common_response.player.set("siegeBattle",
                                            player.SiegeBattle.to_dict())

    return response
Beispiel #8
0
def raceInstanceStart(request, response):
    """
    活动副本结算
    """
    player = request.player
    raidinstance_id = getattr(request.logic_request, "raidId", 0)
    level_id = getattr(request.logic_request, "instanceId", 0)
    waveCount = getattr(request.logic_request, "waveCount", 0)
    star = getattr(request.logic_request, "star", 0)
    isWin = getattr(request.logic_request, "isWin", False)
    heroLayoutData = getattr(request.logic_request, "heroLayoutData", [])
    percentage = getattr(request.logic_request, "percentage", 0.0)
    summary = getattr(request.logic_request, "summary", {})

    if percentage > 1:
        percentage = 0

    # 活动副本章节
    raidinstance = get_raidinstance(raidinstance_id)

    if not raidinstance:
        raise ErrorException(player, u"raceInstanceStart:raid instance id error (%s)" % raidinstance_id)
    if level_id not in raidinstance.raidLevel_ids:
        raise ErrorException(player, u"raceInstanceStart:raid instance level id error (%s)" % level_id)

    raidlevel = get_raidlevel(level_id)
    if raidlevel.minUserLevel > player.level:
        AlertHandler(player, response, AlertID.ALERT_LEVEL_SHORTAGE, u"raceInstanceStart:instance(%s) openlevel(%s) playerlevel(%s)" % (level_id, raidlevel.minUserLevel, player.level))
        return response

    #次数check
    _, playerraidinstance = player.raidinstances.get_or_create(raidinstance_id)
    vip = get_vip(player.vip_level)
    # 爬塔没有次数限制
    if playerraidinstance.succeedCount >= vip.titanCount and not raidinstance.category == 6:
        AlertHandler(player, response, AlertID.ALERT_INSTANCE_FIGHT_COUNT_EXCEED_MAX, u"raceInstanceStart:instance(%s) level_id(%s) fight number(%s) exceed maxCount(%s)" % (raidinstance.id, level_id, playerraidinstance.succeedCount, vip.titanCount))
        return response
    player.update_hero_layout(heroLayoutData)


    data = playerraidinstance.fight(raidlevel, isWin, percentage)
    player.update_raidinstance(playerraidinstance, True)
    if isWin:
        # raidinstance.powerCost 消耗的体力 现改为消耗耐力
        player.sub_stamina(raidinstance.powerCost)

        #if raidinstance.category == 6:
        #    if level_id > player.lastRaidId:
        #        # 记录最新的塔id
        #        player.lastRaidId = level_id
        #        player.set_update("lastRaidId")

        #    # 记录当前的波数
        #    player.dailyWaveCount = waveCount
        #    player.set_update("dailyWaveCount")
        #    # 副本完成状态

        #    # 记录当前一共有的星星的数
        #    player.towerStar += star
        #    player.set_update("towerStar")
        #    # 顺序记录副本的通关星星状态
        #    # todo 这里没想好怎么做。暂时先屏蔽了
        #    # player.towerSweep.append(level_id)
        #    # player.towerSweep.append(star)

        #    player.set_update("towerSweep")
        #    # -1 继续进副本战斗 0去开箱领奖 1-5领了几层箱子
        #    if waveCount % 3 == 0:
        #        # 记录当前一层完成状态更改
        #        player.towerStatus = 0
        #        player.set_update("towerStatus")
        #        player.choiceBuffs()
        #        response.logic_response.set("buffs", player.buyBuffsList)

        #    player.seven_days_task_going(Static.SEVEN_TASK_CATEGORY_RACE_INSTANCE, number=player.dailyWaveCount, is_incr=False, with_top=True, is_series=True)

        #else:
        player.dailytask_going(Static.DAILYTASK_CATEGORY_RACE_INSTANCE, number=1, is_incr=True, is_series=True)

    #if raidinstance.category == 6:
    #    player.dailytask_going(Static.DAILYTASK_CATEGORY_EXPEDITION_SUCCESS, number=1, is_incr=True, is_series=True)



    rewards = data["rewards"]
    heroLevelUp  = []
    heroLevelUp = data["heroLevelUp"]
    number = data["number"]
    for rewardDict in rewards:
        rewardTemp = CommonReward(rewardDict["type"], rewardDict["count"], 0)
        rewardDict["count"] *= number
        reward_send(player, rewardTemp, info=u"活动副本结算:%s:%s" % (raidinstance_id,level_id), number=number)

    response.logic_response.set("rewards", rewards)
    response.logic_response.set("heroLeveleUp",heroLevelUp)
    response.logic_response.set("summary",summary)
    #response.common_response.player.set("towerStar", player.towerStar)
    #response.common_response.player.set("towerStatus", player.towerStatus)
    #response.common_response.player.set("buyBuffsList", player.buyBuffsList)
    response.common_response.player.set("soldiers", player.armies.to_dict())
    response.common_response.player.set("populationCost", player.populationCost)
    response.common_response.player.set("raidInstance", {"instances":get_player_open_raidinstance(player)})

    return response
Beispiel #9
0
def raceInstanceSetUp(request, response):
    """
    活动副本阵容
    """
    player = request.player
    data = {}
    # 活动副本的id,通过活动副本里面配置的字段去找对应的活动副本关卡的信息
    raidinstancelevel_id = getattr(request.logic_request, "raidId", 0)



    # 活动副本关卡id
    level_id = getattr(request.logic_request, "instanceId", 0)
    raidinstance = get_raidinstance(raidinstancelevel_id)


    # 验证没有这个章节
    if not raidinstance:
        raise ErrorException(player, u"raid instance id error (%s)" % raidinstancelevel_id)

    # 验证关卡是否包含在章节中
    if level_id not in raidinstance.raidLevel_ids:
        raise ErrorException(player, u"raid instance level id error (%s)" % level_id)

    # 活动副本关卡对象
    raidlevel = get_raidlevel(level_id)

    if raidlevel.minUserLevel > player.level:
        AlertHandler(player, response, AlertID.ALERT_PLAYER_LEVEL_NOT_ENOUGH, u"raceInstanceSetUp:instance(%s) openlevel(%s) playerlevel(%s)" % (level_id, raidlevel.minUserLevel, player.level))
        return response

    # 检查活动副本是否开启,黑名单,白名单,时间之类的检查。
    if raidinstance.experiment1 and not check_player_in_experiment_by_experimentname(player.id, raidinstance.experiment1):
        AlertHandler(player, response, AlertID.ALERT_RAID_INSTANCE_IS_NOT_OPEN, u"raceInstanceSetUp:instance(%s) is not open" % (level_id))
        return response

    _, playerraidinstance = player.raidinstances.get_or_create(raidinstance.id)
    vip = get_vip(player.vip_level)
    if playerraidinstance.succeedCount >= vip.titanCount and not raidinstance.category == 6:
        AlertHandler(player, response, AlertID.ALERT_INSTANCE_FIGHT_COUNT_EXCEED_MAX, u"raceInstanceStart:instance(%s) level_id(%s) fight number(%s) exceed maxCount(%s)" % (raidinstance.id, level_id, playerraidinstance.succeedCount, vip.titanCount))
        return response
    #if raidinstance.category == 6:
    #    enemyId = raidlevel.enemyIds[(player.dailyWaveCount/3 * 3 + 2)] * 10
    #    Towerrewards = get_raidenemytoreward(enemyId)
    #    if Towerrewards:
    #        rewards = Towerrewards.get_towerrewards()
    #        towerrewards = [reward.to_dict() for reward in rewards]

    #    else:
    #        towerrewards = []

    #    # 记录当前的奖励
    #    player.towerRewardsId = enemyId
    #    player.set_update("towerRewardsId")

    # 检查通过以后返回活动副本关卡的敌方阵容
    enemies = raidlevel.enemies
    #difficulties = []
    #monsterId = []

    #if not enemies:
    #    response.logic_response.set("enemies", [])
    #else:
        # 如果是爬塔模式,历史波数定制
        #if raidinstance.category == 6:
        #    response.logic_response.set("rewards", towerrewards)
        #    # -1 代表未完成完整的一层,一层三波。
        #    if player.towerStatus == -1:
        #        enemies = enemies[player.dailyWaveCount/3*3:player.dailyWaveCount/3*3+3]
        #        enemyDiffIds = raidlevel.enemyIds[player.dailyWaveCount/3*3:player.dailyWaveCount/3*3+3]
        #        for enemyid in enemyDiffIds:
        #            difficulties.extend(get_raidenemytoreward(enemyid).get_difficulties())
        #            Towerrewards = get_raidenemytoreward(enemyid)
        #            monsterId.append(Towerrewards.monsterId)

        #    else:
        #        enemies = enemies[player.dailyWaveCount/3*3 - 3:player.dailyWaveCount/3*3]
        #        for enemy in enemies:
        #            monsterId.append(get_raidenemytoreward(enemy.pk).monsterId)


        # 这个塔一共有多少层
        #response.logic_response.set("towerLevel", len(raidlevel.enemyIds) / 3)
        #response.logic_response.set("difficulties", difficulties)
    response.logic_response.set("enemies", [enemy.to_dict() for enemy in enemies])
    response.logic_response.set("experiment2", raidinstance.experiment2)

        #response.logic_response.set("monsterIds", monsterId)

    return response
Beispiel #10
0
    def get_rewards(self, rule_value):
        '''
        获得奖励
        '''
        is_right = False
        rewards = []
        data = {}
        number = 1
        activity = self.activity
        #签到
        if activity.isCountinueLogin:
            if rule_value == self.value1:
                if not self.received:
                    self.received = True
                    self.getTime = datetime.datetime.now()
                    self.player.update_activity(self, True)
                    #vip 等级高,奖励多倍
                    for rule in activity.rules:
                        if rule.value1 == rule_value:
                            rewards = rule.giftPackage.rewards
                            if self.player.vip_level >= rule.value2:
                                number = rule.value3
                            is_right = True
                            break

        #新手等级
        elif activity.isNewerLevel:
            if rule_value <= self.player.level and rule_value not in self.valueIntArray:
                if self.checkGet(rule_value):
                    for rule in activity.rules:
                        if rule.value1 == rule_value:
                            rewards = rule.giftPackage.rewards
                            self.valueIntArray.append(rule_value)
                            self.player.update_activity(self, True)
                            is_right = True
                            break

        #用户成长
        elif activity.isUserGrowUp:
            #可能逻辑不同,分开写吧
            if self.received:
                if rule_value <= self.player.level and rule_value not in self.valueIntArray:
                    if self.checkGet(rule_value):
                        for rule in activity.rules:
                            if rule.value2 == rule_value:
                                rewards = rule.giftPackage.rewards
                                self.valueIntArray.append(rule_value)
                                self.player.update_activity(self, True)
                                is_right = True
                                break
            else:
                vip = get_vip(self.player.vip_level)
                if vip.growthFund and self.player.yuanbo >= Static.GROW_GOLD_ACTIVITY_MOJO:
                    self.player.sub_yuanbo(Static.GROW_GOLD_ACTIVITY_MOJO,
                                           info=u"成长基金")
                    self.received = True
                    self.player.update_activity(self, True)

        if not is_right:
            rewards = []
        data["rewards"] = rewards
        data["number"] = number

        return data
Beispiel #11
0
 def diamondLeftCount(self):
     vip = get_vip(self.player.vip_level)
     leftCount = vip.timeGateCount - self.diamondCount
     return leftCount if leftCount > 0 else 0
Beispiel #12
0
 def free_number(self):
     vip = get_vip(self.player.vip_level)
     return vip.refreshMysteryShopCount