Пример #1
0
def getDaysReward(userId, days, gameId, nowDate=None):
    '''
    领取累计签到奖励
    @param userId: 用户ID
    @param days: 领取累计几天的奖励, 40表示满月的
    @param nowDate: 当前日期
    @return: MonthCheckinStatus
    '''
    nowDate = nowDate or datetime.now().date()
    status = loadStatus(userId, nowDate)
    if not status.addRewardDays(days):
        raise AlreadyGetRewardException()
    # TODO 发放累计奖励
    # 对days进行判断,是否满月,如果满月,设置days=40
    if isScriptDoGetReward(userId):
        raise AlreadyCheckinException('亲,签到奖励准备中,请玩几把再来领取吧!')

    _saveStatus(status)

    dayRewards = hallconf.getMonthCheckinConf().get('daysRewards', {})
    dayToGift(days, dayRewards, userId, gameId, status)

    ftlog.debug('getDaysReward userId =', userId, 'days =', days, 'gameId =',
                gameId, 'nowDate =', nowDate)
    return status
Пример #2
0
def getDaysReward(userId, days, gameId, nowDate=None):
    '''
    领取累计签到奖励
    @param userId: 用户ID
    @param days: 领取累计几天的奖励, 40表示满月的
    @param nowDate: 当前日期
    @return: MonthCheckinStatus
    '''
    nowDate = nowDate or datetime.now().date()
    status = loadStatus(userId, nowDate)
    if not status.addRewardDays(days):
        raise AlreadyGetRewardException()
    # TODO 发放累计奖励
    # 对days进行判断,是否满月,如果满月,设置days=40
    if isScriptDoGetReward(userId):
        raise AlreadyCheckinException('亲,签到奖励准备中,请玩几把再来领取吧!')

    _saveStatus(status)

    dayRewards = hallconf.getMonthCheckinConf().get('daysRewards', {})
    dayToGift(days, dayRewards, userId, gameId, status)

    ftlog.debug('getDaysReward userId =', userId
                , 'days =', days
                , 'gameId =', gameId
                , 'nowDate =', nowDate)
    return status
Пример #3
0
def checkin(userId, gameId, clientId, nowDate=None):
    '''
    用户签到
    @param userId: 用户ID
    @param nowDate: 当前日期
    @return: MonthCheckinStatus
    '''
    from hall.game import TGHall

    nowDate = nowDate or datetime.now().date()
    status = loadStatus(userId, nowDate)

    if not status.addCheckinDate(nowDate):
        raise AlreadyCheckinException()
    if isScriptDoGetReward(userId):
        raise AlreadyCheckinException('亲,签到奖励准备中,请玩几把再来领取吧!')
    _saveStatus(status)

    # 领取累计奖励
    _, clientVer, _ = strutil.parseClientId(clientId)

    if clientVer < client_ver_judge.client_ver_397:
        userToGetGift(userId, gameId, 0)
    else:
        checkinReward = hallconf.getMonthCheckinConf().get('checkinReward', {})
        userToGetGiftV401(userId, gameId, 0, checkinReward)

    if clientVer <= 3.76:
        # 自动领奖
        days = status.allCheckinCount
        getDaysReward(userId, days, gameId, nowDate)

    TGHall.getEventBus().publishEvent(
        MonthCheckinOkEvent(userId, gameId, status, nowDate))

    ftlog.debug('checkin userId =', userId, 'gameId =', gameId, 'clientId =',
                clientId)
    return status
Пример #4
0
def supplementCheckin(userId,
                      gameId,
                      clientId,
                      supplementDate=None,
                      nowDate=None):
    '''
    用户补签
    @param userId: 用户ID
    @param supDate: 补签日期,如果为None则表示补签最近一天
    @param nowDate: 当前日期
    @return: MonthCheckinStatus
    '''
    from hall.game import TGHall

    nowDate = nowDate or datetime.now().date()
    status = loadStatus(userId, nowDate)
    if isScriptDoGetReward(userId):
        raise AlreadyCheckinException('亲,签到奖励准备中,请玩几把再来领取吧!')
    # 检查最大补签数
    if status.supplementCheckinCount >= getConf().get(
            "maxSupplementCheckinCount"):
        raise SupplementOverException()

    if supplementDate:
        if not pktimestamp.isSameMonth(supplementDate, status.curDate):
            raise InvalidSupplementDateException()
    else:
        holeDateList = status._getHoleDateList()
        if not holeDateList:
            raise AlreadyCheckinException()
        supplementDate = holeDateList[0]

    if not status.addSupplementCheckinDate(supplementDate):
        raise AlreadyCheckinException()

    # 减少抽奖卡,消耗成功之后,发放奖励。
    userAssets = hallitem.itemSystem.loadUserAssets(userId)
    timestamp = pktimestamp.getCurrentTimestamp()

    _, consumeCount, _final = userAssets.consumeAsset(gameId, 'item:4168', 1,
                                                      timestamp,
                                                      'HALL_CHECKIN', 0)
    if consumeCount < 1:
        result = {}
        result["lessCard"] = "您的补签卡不足"
        return 1, result
    datachangenotify.sendDataChangeNotify(gameId, userId, 'item')
    _saveStatus(status)

    # 领取累计奖励
    _, clientVer, _ = strutil.parseClientId(clientId)

    if clientVer < client_ver_judge.client_ver_397:
        userToGetGift(userId, gameId, 0)
    else:
        supplementCheckinReward = hallconf.getMonthCheckinConf().get(
            'supplementCheckinReward', {})
        userToGetGiftV401(userId, gameId, 0, supplementCheckinReward)

    if clientVer <= 3.76:
        # 自动领奖
        days = status.allCheckinCount
        getDaysReward(userId, days, gameId, nowDate)

    TGHall.getEventBus().publishEvent(
        MonthSupCheckinOkEvent(userId, gameId, status, nowDate))

    ftlog.debug('supplementCheckin userId =', userId, 'gameId =', gameId,
                'clientId =', clientId, 'noeDate =', nowDate)
    return 0, status
Пример #5
0
def getConf():
    global _monthCheckinConf
    _monthCheckinConf = hallconf.getMonthCheckinConf()
    return _monthCheckinConf
Пример #6
0
def getConf():
    global _monthCheckinConf
    _monthCheckinConf = hallconf.getMonthCheckinConf()
    return _monthCheckinConf