def noticeDaily(self, dailytype, associatedId, count): '''目标通知 @param dailytype: int 目标类型 @param associatedId: int 关联的ID @param count: int 变更的数量 ''' dailylist = dbdaily.getDailyForToday(dailytype, self._owner.creatTime) #符合今日的目标 characterId = self._owner.baseInfo.id if not dailylist: return for daily in dailylist: if daily['dailytype'] != dailytype or ( associatedId != 0 and associatedId != daily['associatedId']): continue if not self.dailygoal.has_key(daily['id']): self.dailygoal[daily['id']] = {'current': 0, 'received': 0} dbdaily.insertCharacterDaily(characterId, daily['id']) mydaily = self.dailygoal.get(daily['id']) if count < 0: count = mydaily['current'] - count if mydaily['current'] < daily['goal']: mydaily['current'] = min(count, daily['goal']) dbdaily.updateCharacterDaily(characterId, daily['id'], {'current': mydaily['current']})
def receiveBound(self, dailyId): '''领取奖励 @param dailyId: int 目标ID ''' dailyInfo = dbdaily.ALL_DAILY.get(dailyId) if not dailyInfo: return {'result': False, 'message': Lg().g(285)} if not self.checkFinished(dailyId): return {'result': False, 'message': Lg().g(286)} mydaily = self.dailygoal.get(dailyId) if mydaily['received']: return {'result': False, 'message': Lg().g(287)} expbound = dailyInfo.get('expbound') coinbound = dailyInfo.get('coinbound') goldbound = dailyInfo.get('goldbound') itembound = eval('[%s]' % dailyInfo.get('itembound')) spacerequired = len(itembound) if self._owner.pack._package._PropsPagePack.findSparePositionNum( ) < spacerequired: return {'result': False, 'message': Lg().g(16)} self._owner.level.addExp(expbound) self._owner.finance.addCoin(coinbound) self._owner.finance.addGold(goldbound) for item in itembound: self._owner.pack.putNewItemsInPackage(item[0], item[1]) self.dailygoal[dailyId]['received'] = 1 dbdaily.updateCharacterDaily(self._owner.baseInfo.id, dailyId, {'received': 1}) return {'result': True, 'message': Lg().g(288)}
def receiveBound(self,dailyId): '''领取奖励 @param dailyId: int 目标ID ''' dailyInfo = dbdaily.ALL_DAILY.get(dailyId) if not dailyInfo: return {'result':False,'message':Lg().g(285)} if not self.checkFinished(dailyId): return {'result':False,'message':Lg().g(286)} mydaily = self.dailygoal.get(dailyId) if mydaily['received']: return {'result':False,'message':Lg().g(287)} expbound = dailyInfo.get('expbound') coinbound = dailyInfo.get('coinbound') goldbound = dailyInfo.get('goldbound') itembound = eval('[%s]'%dailyInfo.get('itembound')) spacerequired = len(itembound) if self._owner.pack._package._PropsPagePack.findSparePositionNum()<spacerequired: return {'result':False,'message':Lg().g(16)} self._owner.level.addExp(expbound) self._owner.finance.addCoin(coinbound) self._owner.finance.addGold(goldbound) for item in itembound: self._owner.pack.putNewItemsInPackage(item[0],item[1]) self.dailygoal[dailyId]['received'] = 1 dbdaily.updateCharacterDaily(self._owner.baseInfo.id, dailyId, {'received':1}) return {'result':True,'message':Lg().g(288)}
def noticeDaily(self,dailytype,associatedId,count): '''目标通知 @param dailytype: int 目标类型 @param associatedId: int 关联的ID @param count: int 变更的数量 ''' dailylist = dbdaily.getDailyForToday(dailytype,self._owner.creatTime)#符合今日的目标 characterId = self._owner.baseInfo.id if not dailylist: return for daily in dailylist: if daily['dailytype']!=dailytype or (associatedId !=0 and associatedId !=daily['associatedId']): continue if not self.dailygoal.has_key(daily['id']): self.dailygoal[daily['id']] = {'current':0,'received':0} dbdaily.insertCharacterDaily(characterId, daily['id']) mydaily = self.dailygoal.get(daily['id']) if count<0: count = mydaily['current']-count if mydaily['current']<daily['goal']: mydaily['current'] = min(count,daily['goal']) dbdaily.updateCharacterDaily(characterId, daily['id'], {'current':mydaily['current']})