def forHacker(v, hacker, decrease=False): name = str(hacker) if '@' in name: name = utils.jidStrip(hacker) lvl = float(gData["hackers"][name]["level"]) if decrease: return v / math.pow(2, lvl) else: return v * math.pow(2, lvl)
def forHacker(v, hacker, decrease = False): name = str(hacker) if '@' in name: name = utils.jidStrip(hacker) lvl = float(gData["hackers"][name]["level"]) if decrease: return v / math.pow(2, lvl) else: return v * math.pow(2, lvl)
def setCooldown(who, hits): who = unicode(who) if '@' in who: who = utils.jidStrip(who) global gCooldowns if who in gCooldowns: newhits = gCooldowns[who][0] else: newhits = logic.getVitality(who) gCooldowns[who] = (newhits - hits, time.time())
def getVitality(who): who = unicode(who) if '@' in who: who = utils.jidStrip(who) if who in gCooldowns: hits = gCooldowns[who][0] #assert hits > 0 return hits else: return logic.getVitality(who)
def onPresence(self, person, nickname, is_alive): nickname = unicode(nickname) jid = person.getStripped() hackername = utils.jidStrip(jid) if is_alive: if nickname in self.persons: logging.info(u"there is already %s with nickname %s", self.persons[nickname], nickname) self.persons[nickname] = person self.real_persons[hackername] = person logging.info(u"Registering %s with nickname %s" % (self.persons[nickname], nickname)) else: if nickname in self.persons: del self.persons[nickname] del self.real_persons[hackername] return False return True
def getDefenderDamage(person, target): person = utils.jidStrip(person) return config.defenderDamage
def getDamage(person, target, question): person = utils.jidStrip(person) return int(forHacker(config.offenderDamage, person)*config.questionFactor[question.level])
def isValidTarget(person, target): person = utils.jidStrip(person) return target in gData["targets"]
def getHackerLevel(hacker): name = str(hacker) if '@' in name: name = utils.jidStrip(hacker) return int(gData["hackers"][name]["level"])
def policeNotifyOnKill(hacker): hacker = utils.jidStrip(hacker) lvl = getHackerLevel(hacker) return lvl == 3
def getDirectAttackCooldown(person): person = utils.jidStrip(person) return config.directAttackCooldown
def canEnter(who): who = unicode(who) if '@' in who: who = utils.jidStrip(who) return not (who in gCooldowns) or gCooldowns[who][0] > 0
def getDamage(person, target): person = utils.jidStrip(person) return forHacker(config.offenderDamage, person)
def getVitalityDefend(person, target): person = utils.jidStrip(person) return forHacker(config.defenderVitality, person)
def getVitalityOffend(person, target): person = utils.jidStrip(person) return forHacker(forTarget(config.offenderVitality, target), person, True)
def getCooldownOnKilled(person): person = utils.jidStrip(person) return config.cooldownOnKilled
def getCooldownOnAttack(person): person = utils.jidStrip(person) return config.cooldownOnAttack
def getDamage(person, target, question): person = utils.jidStrip(person) return int( forHacker(config.offenderDamage, person) * config.questionFactor[question.level])