def onWarFail(self, warObj, npcObj, w): '''战斗失败时 ''' customTask.onWarFail(self, warObj, npcObj, w) who = getRole(w.id) if who: firstExamObj = answer.getAnswerFirstExamObj() firstExamObj.answerWarFail(who, self)
def goAhead(self, who): '''前往 ''' if not holidayData.getCurrentHoliday(): self.doScript(who, None, "TP2013") task.removeTask(who, self.id) return customTask.goAhead(self, who)
def goAhead(self, who): '''前往 ''' wday = getDatePart()["wday"] if wday != 7: message.tips(who, "活动时间已过,自动删除任务") task.removeTask(who, self.id) return customTask.goAhead(self, who)
def completeTakeProps(self, who, npcObj, propsList=None): '''上交物品成功 ''' #物品品质 needQu = self.fetch("propsQu", 0) if needQu and propsList: propsQuality = getattr(propsList[0], "quality", 0) if propsQuality >= needQu: self.propsQuality = propsQuality customTask.completeTakeProps(self, who, npcObj, propsList)
def goAhead(self, who):#override '''前往 ''' firstExamObj = answer.getAnswerFirstExamObj() if not firstExamObj.isInAnswerTime(): message.tips(who, firstExamObj.getText(2326)) task.removeTask(who, self.id) return if who.inTeam(): message.tips(who, firstExamObj.getText(2321, who.id)) return customTask.goAhead(self, who)
def onBorn(self, who, npcObj, **kwargs): customTask.onBorn(self, who, npcObj, **kwargs) doublePoint = who.doublePoint if 0 < doublePoint: return fdp = who.getFrozenDoublePoint() if not fdp: return dp = min(fdp, 80 - doublePoint, 40) who.addDoublePoint(dp, "领取高倍点数", False) who.addFrozenDoublePoint(-dp, "领取高倍点数") activity.center.centerChange(who, "doublePoint", "frozenDoublePoint")
def abort(self, who): '''放弃任务 ''' customTask.abort(self, who) lv,taskList = self.findTaskGroupList(self.id) if lv: petCompleteNo = who.taskCtn.fetch("petCom", {}) comList = petCompleteNo.get(lv, []) for no in taskList: if no in comList: comList.remove(no) petCompleteNo[lv] = comList who.taskCtn.set("petCom", petCompleteNo) task.pett.autoPetTask(who)
def getValueByVarName(self, varName, who): if varName == "R": if who: ring = who.taskCtn.fetch("guildRing") % 10 return ring if ring else 10 return 0 return customTask.getValueByVarName(self, varName, who)
def getValueByVarName(self, varName, who): if varName == "R": if who: ring = who.taskCtn.fetch("schoolRing") % 10 return 10 if ring == 0 else ring return 0 return customTask.getValueByVarName(self, varName, who)
def getValueByVarName(self, varName, who): if varName == "F": if who: res = 1 - self.fetch("warFail") * 0.1 return max(0, res) return 1 return customTask.getValueByVarName(self, varName, who)
def isValid(self): '''是否有效 ''' wday = getDatePart()["wday"] if wday != 7: return 0 return customTask.isValid(self)
def transString(self, content, pid=0): '''转化字符串 ''' holidayId = self.fetch("holidayId") holidayName = holidayData.getConfig(holidayId, "节日名称") content = content.replace("$holiday", holidayName) return customTask.transString(self, content, pid)
def onBorn(self, who, npcObj, **kwargs): #override ''' ''' customTask.onBorn(self, who, npcObj, **kwargs) #定时 datePart = getDatePart() lEndTime = [] lEndTime.append(datePart["year"]) #年 lEndTime.append(datePart["month"]) #月 lEndTime.append(datePart["day"] + 1) #日 lEndTime.append(0) #时 lEndTime.append(0) #分 lEndTime.append(0) #秒 iEndTime = getSecond(*lEndTime) leftTime = iEndTime - getSecond() self.setTime(leftTime) # 计时任务
def transString(self, content, pid=0): if "$needCnt" in content: needCnt = self.getNeedMonsterCnt() content = content.replace("$needCnt", str(needCnt)) if "$hasCnt" in content: hasCnt = self.getHasMonsterCnt() content = content.replace("$hasCnt", str(hasCnt)) return customTask.transString(self, content, pid)
def validDoEventScript(self, who, npcObj, key): if key in ("点击", "回复"): if not who.isSingle(): if self.parentId == task.map.TASK_MAP_PARENT_ID: self.doScript(who, npcObj, "D1003") else: self.doScript(who, npcObj, "D2006") return 0 return customTask.validDoEventScript(self, who, npcObj, key)
def transIdxByGroup(self, idx): if idx != 9001: return customTask.transIdxByGroup(self, idx) npcIdx = self.fetch("npcIdx", 0) lst = list(self.getGroupInfo(idx)) if npcIdx: lst.remove(npcIdx) return lst[rand(len(lst))]
def isValid(self): '''是否有效 ''' actObj = activity.triones.getActivity() if actObj: if actObj.inNormalTime(): return 1 else: return 0 return customTask.isValid(self)
def getBranchCondition(self, who, npcObj, branchIdx, flag): if flag == "lv": lst = [info["条件"] for info in self.getBranchInfo(branchIdx)] lst.sort(reverse=True) for lv in lst: if who.level >= lv: return lv return customTask.getBranchCondition(self, who, npcObj, branchIdx, flag)
def isValid(self): '''是否有效 ''' holidayId = holidayData.getCurrentHoliday() if not holidayId or not self.fetch("holidayId"): return 0 if holidayId != self.fetch("holidayId"): self.set("holidayId", holidayId) return customTask.isValid(self)
def isValid(self): '''是否有效 ''' firstExamObj = answer.getAnswerFirstExamObj() if firstExamObj: if firstExamObj.isInAnswerTime(): return 1 else: return 0 return customTask.isValid(self)
def transString(self, content, pid=0): who = None if pid: who = getRole(pid) if who: if "$BOSS" in content: content = content.replace("$BOSS", self.getBossDesc(who)) return customTask.transString(self, content, pid)
def transString(self, content, pid=0): '''转化字符串 ''' who = None if pid: who = getRole(pid) if who: guildObj = who.getGuildObj() if "$union" in content: content = content.replace("$union", guildObj.name) return customTask.transString(self, content)
def transString(self, content, pid=0): #override '''转化字符串 ''' if "$monsterList" in content or "$allScene" in content: actObj = activity.triones.getActivity() if actObj: if "$monsterList" in content: lKillMonster = [] lTemp = [] who = None if pid: who = getRole(pid) if who: lKillMonster = who.day.fetch("trionesKill", []) #未战胜显示#C04 #已战胜显示#C05 for monsterIdx in xrange(1001, 1008): info = actObj.getNpcInfo(monsterIdx) if monsterIdx in lKillMonster: lTemp.append("#C0{}{}#n".format( 5, info.get("名称", ""))) else: lTemp.append("#C0{}{}#n".format( 4, info.get("名称", ""))) content = content.replace("$monsterList", "、".join(lTemp)) if "$allScene" in content: lTemp = [] lAllScene = actObj.getGroupInfo(9001) for iSceneId in lAllScene: sceneObj = scene.getScene(iSceneId) if sceneObj: lTemp.append("#C08{}#n".format(sceneObj.name)) content = content.replace("$allScene", "、".join(lTemp)) return customTask.transString(self, content, pid)
def onBorn(self, who, npcObj, **kwargs): customTask.onBorn(self, who, npcObj, **kwargs) dayRing = who.day.fetch("schoolRing") if dayRing > 0: who.taskCtn.set("schoolRing", dayRing % 10)
def onBorn(self, who, npcObj, **kwargs): customTask.onBorn(self, who, npcObj, **kwargs) self.autoGoAhead(who)
def abort(self, who): customTask.abort(self, who) who.taskCtn.delete("schoolRing")
def transNpcInfo(self, npcIdx, info, who=None): if "$name" in info["名称"]: info["名称"] = self.createRandName() if "$pos" in info["位置"]: info["位置"] = self.createRandPos() return customTask.transNpcInfo(self, npcIdx, info, who)
def __init__(self, _id): customTask.__init__(self, _id) self.iExamNo = self.id%20000
def getNpcByIdx(self, npcIdx): if npcIdx in xrange(1001,1021): return self.getTargetNpc() return customTask.getNpcByIdx(self, npcIdx)
def onBorn(self, who, npcObj, **kwargs): '''出生时初始化,只在给予任务时执行一次 ''' holidayId = holidayData.getCurrentHoliday() self.set("holidayId", holidayId) customTask.onBorn(self, who, npcObj, **kwargs)