def immediateFinishPractice(self, payType, payNum): '''立即完成修炼''' id = self._owner.baseInfo.id gold = self._owner.finance.getGold() coupon = self._owner.finance.getCoupon() exp = self._owner.level.getExp() if payType == 'gold': gold -= payNum else: coupon -= payNum if gold < 0: return {'result': False, 'reason': u'您的黄金不够'} if coupon < 0: return {'result': False, 'reason': u'您的礼券不够'} record = dbaccess.getPlayerPracticeRecord(id) countHit = record[3] totalExp = record[3] * record[6] exp += totalExp monster = loader.getById('npc', record[2], '*') monsterName = monster['name'] for i in range(0, countHit): self._owner.quest.onSuccessKillOneMonster(record[2], 'battle') # break # if item: # self._owner.pack.putOneItemIntoTempPackage(item,1) self.placePracticeItems(countHit, monster) self._owner.level.setExp(exp) if not self._owner.level.updateLevel(): dbaccess.updatePlayerInfo(id, { 'status': 1, 'gold': gold, 'coupon': coupon, 'exp': exp }) else: dbaccess.updatePlayerInfo(id, { 'status': 1, 'gold': gold, 'coupon': coupon }) self._owner.baseInfo.setStatus(1) self._owner.finance.setGold(gold) self._owner.finance.setCoupon(coupon) return {'result':True, 'data':{'monsterName':monsterName, 'totalExp':totalExp, 'countHit':countHit, \ 'gold':gold, 'coupon':coupon, 'status':self._owner.baseInfo.getStatus(), \ 'level':self._owner.level.getLevel()}}
def getPracticeInfo(self): '''获取玩家修炼的信息''' id = self._owner.baseInfo.id record = dbaccess.getPlayerPracticeRecord(id) monsterName = loader.getById('npc', record[2], ['name']) if not monsterName: return {'result':False, 'reason':u'没有找到修炼的怪物'} monsterName = monsterName['name'] countHit = record[3] finishTime = record[5] seconds = (finishTime - datetime.datetime.now()).seconds singleMonsterExpBonus = record[6] totalExp = singleMonsterExpBonus * countHit return {'countHit':countHit, 'seconds':seconds, 'totalExp':totalExp, 'monsterName':monsterName}
def immediateFinishPractice(self, payType, payNum): '''立即完成修炼''' id = self._owner.baseInfo.id gold = self._owner.finance.getGold() coupon = self._owner.finance.getCoupon() exp = self._owner.level.getExp() if payType == 'gold': gold -= payNum else: coupon -= payNum if gold < 0 : return {'result':False, 'reason':u'您的黄金不够'} if coupon < 0: return {'result':False, 'reason':u'您的礼券不够'} record = dbaccess.getPlayerPracticeRecord(id) countHit = record[3] totalExp = record[3] * record[6] exp += totalExp monster = loader.getById('npc', record[2], '*') monsterName = monster['name'] for i in range(0,countHit): self._owner.quest.onSuccessKillOneMonster(record[2],'battle') # break # if item: # self._owner.pack.putOneItemIntoTempPackage(item,1) self.placePracticeItems(countHit, monster) self._owner.level.setExp(exp) if not self._owner.level.updateLevel(): dbaccess.updatePlayerInfo(id, {'status':1, 'gold':gold, 'coupon':coupon, 'exp':exp}) else: dbaccess.updatePlayerInfo(id, {'status':1, 'gold':gold, 'coupon':coupon}) self._owner.baseInfo.setStatus(1) self._owner.finance.setGold(gold) self._owner.finance.setCoupon(coupon) return {'result':True, 'data':{'monsterName':monsterName, 'totalExp':totalExp, 'countHit':countHit, \ 'gold':gold, 'coupon':coupon, 'status':self._owner.baseInfo.getStatus(), \ 'level':self._owner.level.getLevel()}}
def getPracticeInfo(self): '''获取玩家修炼的信息''' id = self._owner.baseInfo.id record = dbaccess.getPlayerPracticeRecord(id) monsterName = loader.getById('npc', record[2], ['name']) if not monsterName: return {'result': False, 'reason': u'没有找到修炼的怪物'} monsterName = monsterName['name'] countHit = record[3] finishTime = record[5] seconds = (finishTime - datetime.datetime.now()).seconds singleMonsterExpBonus = record[6] totalExp = singleMonsterExpBonus * countHit return { 'countHit': countHit, 'seconds': seconds, 'totalExp': totalExp, 'monsterName': monsterName }
def terminatePractice(self): ''' 终止玩家修炼 ''' id = self._owner.baseInfo.id exp = self._owner.level.getExp() record = dbaccess.getPlayerPracticeRecord(id) monsterId = record[2] startTime = record[4] finishTime = record[5] singleExpBonus = record[6] now = datetime.datetime.now() currentCountHit = int((now - startTime).seconds / (60 * 3)) int((finishTime - startTime).seconds / 60) currentExp = currentCountHit * singleExpBonus monster = loader.getById('npc', monsterId, '*') if not monster: return {'result':False, 'message':Lg().g(441)} for i in range(0, currentCountHit): pass # self._owner.quest.onSuccessKillOneMonster(monsterId) # break # if item: # self._owner.pack.putOneItemIntoTempPackage(item, currentCountHit) # pushMessage(str(self._owner.baseInfo.id),'newTempPackage') # self.placePracticeItems(currentCountHit, monster) monsterName = monster['name'] self._owner.level.setExp(exp + currentExp) dbaccess.updatePlayerInfo(id, {'status':1}) self._owner.baseInfo.setStatus(1) return {'result':True, 'data':{'monsterName':monsterName, 'currentExp':currentExp, \ 'currentCountHit':currentCountHit, 'status':self._owner.baseInfo.getStatus(), \ 'level':self._owner.level.getLevel()}}
def doWhenPracticeFinsihed(self, attrs): '''当修炼结束时''' id = self._owner.baseInfo.id practiceRecord = dbaccess.getPlayerPracticeRecord(id) monsterId = practiceRecord[2] countHit = practiceRecord[3] finishTime = practiceRecord[5] now = datetime.datetime.now() if not finishTime or (finishTime - now).seconds < 0: return self._owner.level.updateExp(attrs['exp']) # if not self._owner.level.updateLevel(): # dbaccess.updatePlayerInfo(id, attrs) self._owner.baseInfo.setStatus(1) npc = loader.getById('npc', monsterId, '*') if npc: # for i in range(0, countHit): # self._owner.quest.onSuccessKillOneMonster(monsterId) self.placePracticeItems(countHit, npc) practiceFinsihed(id)
def terminatePractice(self): ''' 终止玩家修炼 ''' id = self._owner.baseInfo.id exp = self._owner.level.getExp() record = dbaccess.getPlayerPracticeRecord(id) monsterId = record[2] startTime = record[4] finishTime = record[5] singleExpBonus = record[6] now = datetime.datetime.now() currentCountHit = int((now - startTime).seconds / (60 * 3)) int((finishTime - startTime).seconds / 60) currentExp = currentCountHit * singleExpBonus monster = loader.getById('npc', monsterId, '*') if not monster: return {'result': False, 'message': Lg().g(441)} for i in range(0, currentCountHit): pass # self._owner.quest.onSuccessKillOneMonster(monsterId) # break # if item: # self._owner.pack.putOneItemIntoTempPackage(item, currentCountHit) # pushMessage(str(self._owner.baseInfo.id),'newTempPackage') # self.placePracticeItems(currentCountHit, monster) monsterName = monster['name'] self._owner.level.setExp(exp + currentExp) dbaccess.updatePlayerInfo(id, {'status': 1}) self._owner.baseInfo.setStatus(1) return {'result':True, 'data':{'monsterName':monsterName, 'currentExp':currentExp, \ 'currentCountHit':currentCountHit, 'status':self._owner.baseInfo.getStatus(), \ 'level':self._owner.level.getLevel()}}