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) userToGetGift(userId, gameId, state=0) # 领取累计奖励 _, clientVer, _ = strutil.parseClientId(clientId) 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
def supplementCheckin(userId, gameId, clientId, supplementDate=None, nowDate=None): ''' 用户补签 @param userId: 用户ID @param supDate: 补签日期,如果为None则表示补签最近一天 @param nowDate: 当前日期 @return: MonthCheckinStatus ''' nowDate = nowDate or datetime.now().date() status = monthcheckin.loadStatus(userId, nowDate) if monthcheckin.isScriptDoGetReward(userId): raise monthcheckin.AlreadyCheckinException('非法签到') # 检查最大补签数 if status.supplementCheckinCount >= monthcheckin._monthCheckinConf.get( "maxSupplementCheckinCount"): raise monthcheckin.SupplementOverException() if supplementDate: if not pktimestamp.isSameMonth(supplementDate, status.curDate): raise monthcheckin.InvalidSupplementDateException() else: supplementDate = status._getHoleDateList() if not supplementDate: raise monthcheckin.AlreadyCheckinException() if not status.addSupplementCheckinDate(supplementDate[0]): raise monthcheckin.AlreadyCheckinException() # TODO 发放补签奖励 # TODO publish event #减少抽奖卡,消耗成功之后,发放奖励。 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') monthcheckin._saveStatus(status) monthcheckin.userToGetGift(userId, gameId, state=0) #领取累计奖励 _, clientVer, _ = strutil.parseClientId(clientId) if clientVer <= 3.76: #自动领奖 days = status.allCheckinCount monthcheckin.getDaysReward(userId, days, gameId) ftlog.info('supplementCheckin userId =', userId, 'gameId =', gameId, 'clientId =', clientId, 'noeDate =', nowDate) return 0, status
def adjust(self, curDate): assert (isinstance(curDate, date)) if not pktimestamp.isSameMonth(curDate, self.curDate): del self._checkinDateList[:] del self._supplementCheckinDateList[:] del self._rewardDaysList[:] del self._holeDateList[:] else: self._holeDateList = self._getHoleDateList()[:] self._curDate = curDate return self
def addCheckinDate(self, checkinDate): ''' 增加签到日期 ''' assert (isinstance(checkinDate, date)) if (pktimestamp.isSameMonth(checkinDate, self.curDate) and checkinDate <= self.curDate and not self.isCheckined(checkinDate)): sortedlist.insert(self._checkinDateList, checkinDate) return True return False
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