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