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