Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
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())
Exemplo n.º 4
0
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)
Exemplo n.º 5
0
 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
Exemplo n.º 6
0
 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
Exemplo n.º 7
0
def getDefenderDamage(person, target):
    person = utils.jidStrip(person)
    return config.defenderDamage
Exemplo n.º 8
0
def getDamage(person, target, question):
    person = utils.jidStrip(person)
    return int(forHacker(config.offenderDamage, person)*config.questionFactor[question.level])
Exemplo n.º 9
0
def isValidTarget(person, target):
    person = utils.jidStrip(person)
    return target in gData["targets"]
Exemplo n.º 10
0
def getHackerLevel(hacker):
    name = str(hacker)
    if '@' in name:
        name = utils.jidStrip(hacker)
    return int(gData["hackers"][name]["level"])
Exemplo n.º 11
0
def policeNotifyOnKill(hacker):
    hacker = utils.jidStrip(hacker)  
    lvl = getHackerLevel(hacker)
    return lvl == 3
Exemplo n.º 12
0
def getDirectAttackCooldown(person):
    person = utils.jidStrip(person)
    return config.directAttackCooldown
Exemplo n.º 13
0
def getDirectAttackCooldown(person):
    person = utils.jidStrip(person)
    return config.directAttackCooldown
Exemplo n.º 14
0
def getDefenderDamage(person, target):
    person = utils.jidStrip(person)
    return config.defenderDamage
Exemplo n.º 15
0
def canEnter(who):
    who = unicode(who)
    if '@' in who: 
        who = utils.jidStrip(who)
    return not (who in gCooldowns) or gCooldowns[who][0] > 0
Exemplo n.º 16
0
def getDamage(person, target):
    person = utils.jidStrip(person)
    return forHacker(config.offenderDamage, person)
Exemplo n.º 17
0
def getVitalityDefend(person, target):
    person = utils.jidStrip(person)
    return forHacker(config.defenderVitality, person)
Exemplo n.º 18
0
def getVitalityOffend(person, target):
    person = utils.jidStrip(person)
    return forHacker(forTarget(config.offenderVitality, target), person, True)
Exemplo n.º 19
0
def isValidTarget(person, target):
    person = utils.jidStrip(person)
    return target in gData["targets"]
Exemplo n.º 20
0
def getHackerLevel(hacker):
    name = str(hacker)
    if '@' in name:
        name = utils.jidStrip(hacker)
    return int(gData["hackers"][name]["level"])
Exemplo n.º 21
0
def getCooldownOnKilled(person):
    person = utils.jidStrip(person)
    return config.cooldownOnKilled
Exemplo n.º 22
0
def policeNotifyOnKill(hacker):
    hacker = utils.jidStrip(hacker)
    lvl = getHackerLevel(hacker)
    return lvl == 3
Exemplo n.º 23
0
def getCooldownOnAttack(person):
    person = utils.jidStrip(person)
    return config.cooldownOnAttack
Exemplo n.º 24
0
def getDamage(person, target, question):
    person = utils.jidStrip(person)
    return int(
        forHacker(config.offenderDamage, person) *
        config.questionFactor[question.level])