def add_attack(self, name, specifier, attack_type, card): #Major attack card case if card.id >= 48 and card.id <= 61: current_major_attacks = self.get_major_attack_number() if current_major_attacks == 0: #Add major attack attack = Attack(name, specifier, attack_type) self.attacks.append(attack) self.effects.append(card.effect_message) if card.name == "Bone Metastasis": self.bone_metastasis = 1 else: attack = Attack(name, specifier, attack_type) self.attacks.append(attack) self.effects.append(card.effect_message) self.effects.append("About to die!!!") self.about_to_die = 1 #Indirect attack card case elif card.id >= 62 and card.id <= 69: attack = Attack(name, specifier, attack_type) self.attacks.append(attack) new_effect = card.effect_message self.blocked_cards.extend(card.blocked_cards) self.effects.append(new_effect)
def __init__(self, HTTP, xmlRepGenerator): Attack.__init__(self, HTTP, xmlRepGenerator) user_config_dir = os.getenv('HOME') or os.getenv('USERPROFILE') user_config_dir += "/config" if not os.path.isdir(user_config_dir): os.makedirs(user_config_dir) try: fd = open(user_config_dir + "/" + self.CONFIG_FILE) reader = csv.reader(fd) self.nikto_db = [l for l in reader if l != [] and l[0].isdigit()] fd.close() except IOError: try: print(_("Problem with local nikto database.")) print(_("Downloading from the web...")) resp = self.HTTP.send( "http://cirt.net/nikto/UPDATES/2.1.5/db_tests") page = resp.getRawPage() csv.register_dialect("nikto", quoting=csv.QUOTE_ALL, doublequote=False, escapechar="\\") reader = csv.reader(page.split("\n"), "nikto") self.nikto_db = [ l for l in reader if l != [] and l[0].isdigit() ] fd = open(user_config_dir + "/" + self.CONFIG_FILE, "w") writer = csv.writer(fd) writer.writerows(self.nikto_db) fd.close() except socket.timeout: print(_("Error downloading Nikto database"))
def __init__(self, HTTP, xmlRepGenerator): Attack.__init__(self, HTTP, xmlRepGenerator) user_config_dir = os.getenv('HOME') or os.getenv('USERPROFILE') user_config_dir += "/config" if not os.path.isdir(user_config_dir): os.makedirs(user_config_dir) try: fd = open(user_config_dir + "/" + self.CONFIG_FILE) reader = csv.reader(fd) self.nikto_db = [l for l in reader if l!=[] and l[0].isdigit()] fd.close() except IOError: try: print _("Problem with local nikto database.") print _("Downloading from the web...") resp = self.HTTP.send("http://cirt.net/nikto/UPDATES/2.1.1/db_tests") page = resp.getPage() csv.register_dialect("nikto", quoting=csv.QUOTE_ALL, doublequote=False, escapechar="\\") reader = csv.reader(page.split("\n"), "nikto") self.nikto_db = [l for l in reader if l!=[] and l[0].isdigit()] fd = open(user_config_dir + "/" + self.CONFIG_FILE, "w") writer = csv.writer(fd) writer.writerows(self.nikto_db) fd.close() except socket.timeout: print _("Error downloading Nikto database")
def main(args): # initialize dataset audio_dataset = AudioDataset(args.manifest, batch_size=args.batch_size, root_dir=args.root_dir) audio_dataloader = audio_dataset.dataloader() attack = Attack(args.model_path, batch_size=args.batch_size, lr_stage1=args.lr_stage1, lr_stage2=args.lr_stage2, num_iter_stage1=args.num_iter_stage1, num_iter_stage2=args.num_iter_stage2) # initialize attack class attack.attack_stage1(audio_dataloader) for idx, batch in enumerate(audio_dataloader): #print(idx, batch) for key, value in batch.items(): try: print(key, ':', value.shape) except AttributeError: print(key, ':', value) exit()
def create_dragon(): attacks = [ Attack("Coup de griffe", 8, 10), Attack("Crache des flammes", 5, 20), Attack("Coup de patte", 9, 5) ] return Monster("Dragon", 100, 50, 200, attacks)
def main(argv): foe = Monster('scyter', 123, 0, 100, 100) ally = Monster('bulbasaur', 1, 0, 100, 100) battle = Battle(foe, ally) att = Attack('splash', 0, 100, False, True) for effect in att.effects(): sys.stdout.write(effect(battle)) sys.stdout.write('\n')
def main(): attack = Attack(URL) res = attack.run(PAYLOAD) if res: msg = "The app is vulnerable" else: msg = "You are in good hands" return (res, msg)
def __init__(self, level): hp, attackDamage, exp, gold = OrcLeader.set_stats(level) super().__init__('Orc Leader', level, hp, 0) self.add_attack(Attack('Bash', attackDamage, 90, False, 0)) self.add_attack(Attack('Toss', attackDamage * 2, 45, False, 0)) self.exp = exp self.gold = gold self.behavior = {'attack': 70, 'defend': 25, 'nothing': 5} self.defendModifier = 1.5
def attack(self): if self.action == "S" or self.action == "W" or self.action== "R": self.sword_sound.play() if self.direction=="R": self.attack_list.add(Attack(self.rect.right,self.rect.y)) else: self.attack_list.add(Attack(self.rect.left - 20,self.rect.y)) self.action = "A" self.change_x = 0 self.reset_anim()
def read_file(): f = open("attack_payload", "r") data = f.read() f.close() #print(data) payload = json.loads(data) payload_data = payload["data"] attack_attributes = payload_data["attributes"] print("PAYLOAD:{}".format(payload)) #check if ongoing if attack_attributes["ongoing"] == "True": try: print("New/Ongoing Attack ID :{} \n Ongoing waiting".format( payload_data['id'])) except: print(payload_data) else: attack_id = payload_data["id"] attack = Attack(attack_id) start_time = attack_attributes["start_time"] attack.start_time = attack_attributes["start_time"] attack.stop_time = attack_attributes["stop_time"] attack_subobjects = attack_attributes["subobject"] attack.peak_pps = attack_subobjects["impact_pps"] attack.peak_bps = attack_subobjects["impact_bps"] attack.misuse_types = attack_subobjects["misuse_types"] attack.source_ips = get_source_ips(attack_id=attack.id) print("Attack ID:{} \n Finished".format(attack_id)) print("JSON:{}".format(attack.output())) send_event(attack) return 'hello'
def __init__(self, name): startHP = 25 startMana = 0 super().__init__(name, 1, startHP, startMana) self.kind = 'Warrior' self.add_attack(Attack('Hit', 5, 100, False, 0)) self.levelUpStats = {'HP': 5 + int(self.level / 2), 'Mana': 0} self.defendModifier = 3 self.levelUpMoves[3] = Attack('Slash', 8, 90, False, 0) self.levelUpMoves[6] = Attack('Stab', 10, 85, False, 0)
def __init__(self, name): startHP = 20 startMana = 0 super().__init__(name, 1, startHP, startMana) self.kind = 'Berserker' self.add_attack(Attack('Smash', 7, 85, False, 0)) self.levelUpStats = {'HP': 3 + int(self.level / 2), 'Mana': 0} self.defendModifier = 2 self.berserkChance = 20 self.levelUpMoves[4] = Attack('Slam', 12, 70, False, 0) self.levelUpMoves[9] = Attack('Wallop', 20, 85, False, 0)
class Formation: """ Defines formation """ def __init__(self): self.defence_line_ = Defence() self.midfield_line_ = Midfield() self.attack_line_ = Attack() def get(self): return {"defence": self.defence_line_, "midfield": self.midfield_line_, "attack": self.attack_line_} def get_slot_list(self): return self.defence_line_.slots() + self.midfield_line_.slots() + self.attack_line_.slots() def players_count(self): count = 0 count += self.defence_line_.players_count() count += self.midfield_line_.players_count() count += self.attack_line_.players_count() return count def player_present(self, player): return self.defence_line_.player_present(player) or self.midfield_line_.player_present(player) or self.attack_line_.player_present(player) def __str__(self): stringa = "defence: " + str(self.defence_line_) stringa += "\nmidfield: " + str(self.midfield_line_) stringa += "\nattack: " + str(self.attack_line_) return stringa @staticmethod def create_random_formation(schema, team): form = Formation() idx = 0 line = schema[0] for i in range(0,line): slt = form.defence_line_.slots()[i] form.defence_line_.set_player(team[idx], slt, "neutral") idx += 1 line = schema[1] for i in range(0,line): slt = form.midfield_line_.slots()[i] form.midfield_line_.set_player(team[idx], slt, "neutral") idx += 1 line = schema[2] for i in range(0,line): slt = form.attack_line_.slots()[i] form.attack_line_.set_player(team[idx], slt, "neutral") idx += 1 return form
def __init__(self, projectileType, direction, position, damage): Sprite.__init__(self) Attack.__init__(self, damage) self.speed = 15 self.direction = direction self.frame = 0 self.size = 48 self.spriteSheet = pygame.image.load(projectileType.value) self.prapareSprite(self.frame) self.rect = self.image.get_rect() self.rect.x = position[0] self.rect.y = position[1] self.timelapsed = 0 self.animationDirection = 1
def __init__(self, rpg_type): self.life = 100 self.inventory = [] self.rpg_type = rpg_type self.attack = [] if rpg_type == RPGType.warrior: self.strength = 10 self.defence = 5 self.attack.append(Attack("Coup de bouclier", 7, 15)) self.attack.append(Attack("Coup d'épée", 6, 20)) elif rpg_type == RPGType.mage: self.strength = 5 self.defence = 3 self.attack.append(Attack("Eclair", 3, 50)) self.attack.append(Attack("Boule de feu", 8, 20))
def __init__(self, name): startHP = 15 startMana = 10 super().__init__(name, 1, startHP, startMana) self.kind = 'Mage' self.add_attack(Attack('Bash', 3, 75, False, 0)) self.add_attack(Attack('Sparks', 7, 100, True, 3)) self.levelUpStats = { 'HP': 3 + int(self.level / 3), 'Mana': 3 + int(self.level / 3) } self.defendModifier = 1.5 self.levelUpMoves[3] = Attack('Flames', 10, 90, True, 5) self.levelUpMoves[6] = Attack('Firebolt', 15, 95, True, 8)
def create(self): new_action = Attack() new_action.attacker = self.attacker ability_dice = [] ability_modifier = - self.attacker.wounds fighting_skill = self.attacker.get_skill('lutar') if fighting_skill is None: ability_dice.append(4) modificador = - 2 else: dados.append(atacante.get_skill('lutar')) modificador = 0 ataque.attack_roll = SWRoll(dados, modificador) ataque.damage_roll = SWRoll([atacante.get_attribute('forca')], 0) return ataque
def attacks(): hit_roller = Roller('d20') dmg_seed = arg_value('dmg_seed', 2) attacker = Attack([ Roller("d{dmg}".format(dmg=dmg_seed)) for _ in range(arg_value('n_dmg_rollers', 1)) ], damage_modifier=arg_value('dmg_modifier', 0)) attacks = attacker.attacks(hit_roller, arg_value('n_attacks', 1), risk_buffer=arg_value('risk_buffer', 0), dc=arg_value('dc', 0), modifier=arg_value('hit_modifier', 0), critical=arg_value('critical', 20)) return jsonify({'return': attacker.html_attacks(attacks)}), 200
def __init__(self, name): startHP = 15 startMana = 10 super().__init__(name, 1, startHP, startMana) self.kind = 'Sage' self.add_attack(Attack('Bash', 3, 75, False, 0)) self.add_heal(Heal('Heal-1', 5, 95, True, 4)) self.levelUpStats = { 'HP': 2 + int(self.level / 3), 'Mana': 3 + int(self.level / 3) } self.defendModifier = 1 self.levelUpMoves[3] = Heal('Heal-2', 10, 90, True, 6) self.levelUpMoves[6] = Attack('Stab', 10, 85, False, 0)
def __init__(self, params): self.params = Params(**params) self.times = { 'backward': list(), 'forward': list(), 'step': list(), 'scales': list(), 'total': list(), 'poison': list() } if self.params.random_seed is not None: self.fix_random(self.params.random_seed) self.make_folders() self.make_task() self.make_synthesizer() self.attack = Attack(self.params, self.synthesizer) if 'neural_cleanse' in self.params.loss_tasks: self.nc = True # if 'spectral_evasion' in self.params.loss_tasks: # self.attack.fixed_model = deepcopy(self.task.model) self.best_loss = float('inf')
def attack(self, x, y): now = pygame.time.get_ticks() if now - self.last_attack > ATTACK_RATE: self.last_attack = now self.attacking = True dir = self.pos + vec(x, y) Attack(dir, self.model)
def __init__(self, level): hp, attackDamage, exp, gold = Orc.set_stats(level) super().__init__('Orc', level, hp, 0) self.add_attack(Attack('Bash', attackDamage, 90, False, 0)) self.exp = exp self.behavior = {'attack': 80, 'defend': 0, 'nothing': 20} self.gold = gold
def __init__(self, level): hp, attackDamage, exp, gold = Goblin.set_stats(level) super().__init__('Goblin', level, hp, 0) self.add_attack(Attack('Scratch', attackDamage, 100, False, 0)) self.exp = exp self.behavior = {'attack': 70, 'defend': 20, 'nothing': 10} self.defendModifier = 1.5
def test_attack(self): correct = 0 self.load_checkpoint(best=self.best) self.model.eval() # prepare adv attack attacker = Attack(self.model, self.loss, self.attack_type, self.attack_eps) adv_data, num_examples = extract_adv_images( attacker, self.test_loader, self.targeted, DATASET_CONFIGS[self.config.dataset]["classes"]) with torch.no_grad(): for i, (x, y) in enumerate(adv_data): x, y = x.to(device), y.to(device) out = self.model(x) # compute accuracy pred = torch.max(out, 1)[1] correct += pred.eq(y.data.view_as(pred)).cpu().sum() if self.targeted: success = correct else: success = num_examples - correct perc = (100. * success.data.item()) / (num_examples) print( '[*] Attack success rate ({}, targeted={}, eps={}): {}/{} ({:.2f}% - {:.2f}%)' .format(self.attack_type, self.targeted, self.attack_eps, success, num_examples, perc, 100. - perc))
def __init__(self, klass, name, colour, level, attack, range_, alphatocolour=None, **_): # largeicon = PICS['weapons']['large_icon'][klass][repr(level)][ # colour] # smallicon = PICS['weapons']['small_icon'][klass][repr(level)][ # colour] if isinstance(attack, dict): # we got an instance from loading a json file. convert the # attack here. attack = Attack(**attack) self.klass = klass self.name = name self.colour = colour self.level = level self.attack = attack self.range_ = range_ licon = '/'.join(('weapons', 'large_icon', klass, str(level), colour)) sicon = '/'.join(('weapons', 'small_icon', klass, str(level), colour)) largeicon = '/'.join((klass, str(level))) smallicon = largeicon if alphatocolour is not None: change_alpha_to_colour(largeicon, alphatocolour) change_alpha_to_colour(smallicon, alphatocolour) self.largeicon_surf = PICS['weapons']['large_icon'][klass][str( level)][colour] rect = self.largeicon_surf.get_rect() pos = rect.bottomright[0] - 4, rect.bottomright[1] - 9 font = pygame.font.Font('freesansbold.ttf', 8) surf = font.render(repr(level), True, COLOURS['black']) self.largeicon_surf.blit(surf, pos) self.smallicon_surf = PICS['weapons']['small_icon'][klass][str( level)][colour] super().__init__( ItemFlag.WEAPON, name=name, klass=klass, colour=colour, level=level, attack=attack, range_=range_, alphatocolour=alphatocolour, licon=licon, sicon=sicon, )
def __init__(self, level): hp, attackDamage, exp, gold = OrcBerserker.set_stats(level) super().__init__('Orc Berserker', level, hp, 0) self.add_attack(Attack('Smash', attackDamage, 85, False, 0)) self.exp = exp self.behavior = {'attack': 90, 'defend': 0, 'nothing': 10} self.gold = gold self.berserkChance = 25 + int(level / 2)
def apply_command_tick2(self, cmd): self.apply_command_tick(cmd) self.arena.attacks.clear() coords = cmd[2] for a in coords.split("|"): pos = parse_coord(a) self.arena.attacks.append(Attack(pos[0], pos[1], pos[2]))
def insert_attack(host, port): Base.metadata.create_all(engine) session = Session() attack = Attack(host, port) session.add(attack) session.commit() session.close()
def __init__(self, level): hp, mana, attackDamage, healPower, exp, gold = OrcShaman.set_stats( level) super().__init__('Orc Shaman', level, hp, mana) self.add_attack(Attack('Bash', attackDamage, 70, False, 0)) self.add_heal(Heal('Heal', healPower, 90, True, 4)) self.exp = exp self.behavior = {'attack': 30, 'defend': 20, 'heal': 40, 'nothing': 10} self.defendModifier = 1
def __init__(self): self.cam = cv2.VideoCapture(0) self.cam.set(cv2.CAP_PROP_FRAME_WIDTH, 600) self.cam.set(cv2.CAP_PROP_FRAME_HEIGHT, 400) self.count = 0 self.soul = LostSoul() self.smile = False self.fireballs = [] self.hp = 100 self.mana = 10 self.is_alive = True self.attack_my = Attack([200, 0, 200]) self.attack_cyber = Attack([0, 0, 255]) self.demon = Cacodemon() self.cyber = Cyber() self.current_point_prev = [0, 0] self.current_point = [0, 0] self.points = 0
class Mario: # Here we have a list of attacks! attacks = [Attack("Jump", 10), Attack("Fireball", 30)] def __init__(self, hp, coins): self.hp = hp self.coins = coins self.damage = 20 def attack(self, name): return self.get_attack_by_name(name).attacks() def get_attack_by_name(self, name): # We can clean this up when we learn about maps! For now, we can do this with if statements if name == "Fireball": return self.attacks[1] else: return self.attacks[0]
def get_phox_attacks(phox, attackDB, familyDB): for string in phox.attack_strings: attack = Attack() db_info = attackDB.find({"name": string}) for doc in db_info: attack.name = doc["name"] attack.family = doc["family"] attack.style = doc["style"] attack.damage = doc["damage"] attack.cost = doc["cost"] attack.effect = doc["effect"] attack.plain_text_effect = doc["plain text effect"] get_advantages(attack, familyDB) phox.attacks.append(attack) phox.attack_strings = []
class Bowser: # Technically we don't need a list here, since we just have one item in our list # But this allows us to add more attacks later if we want to attacks = [Attack("Flamethrower", 50)] def __init__(self): self.damage = 100 def attack(self): return self.attacks[0].attack()
def __init__(self, HTTP, xmlRepGenerator): Attack.__init__(self, HTTP, xmlRepGenerator) try: fd = open(self.CONFIG_DIR + "/" + self.CONFIG_FILE) reader = csv.reader(fd) self.nikto_db = [l for l in reader if l != [] and l[0].isdigit()] fd.close() except IOError: try: print _("Problem with local nikto database.") print _("Downloading from the web...") page = urllib2.urlopen("http://cirt.net/nikto/UPDATES/2.1.0/db_tests") csv.register_dialect("nikto", quoting=csv.QUOTE_ALL, doublequote=False, escapechar="\\") reader = csv.reader(page, "nikto") self.nikto_db = [l for l in reader if l != [] and l[0].isdigit()] page.close() fd = open(self.CONFIG_DIR + "/" + self.CONFIG_FILE, "w") writer = csv.writer(fd) writer.writerows(self.nikto_db) fd.close() except socket.timeout: print _("Error downloading Nikto database")
def __init__(self): self.defence_line_ = Defence() self.midfield_line_ = Midfield() self.attack_line_ = Attack()
class App: def __init__(self): self.cam = cv2.VideoCapture(0) self.cam.set(cv2.CAP_PROP_FRAME_WIDTH, 600) self.cam.set(cv2.CAP_PROP_FRAME_HEIGHT, 400) self.count = 0 self.soul = LostSoul() self.smile = False self.fireballs = [] self.hp = 100 self.mana = 10 self.is_alive = True self.attack_my = Attack([200, 0, 200]) self.attack_cyber = Attack([0, 0, 255]) self.demon = Cacodemon() self.cyber = Cyber() self.current_point_prev = [0, 0] self.current_point = [0, 0] self.points = 0 def __del__(self): self.cam.release() def run(self): vis = cv2.imread("graphics/title.png") cv2.putText(vis, 'If you want to live just smile :)', (120, 300), cv2.FONT_HERSHEY_PLAIN, 1.6, (255, 255, 255)) cv2.imshow('lk_track', vis) cv2.waitKey() smiles = [] while self.is_alive: ret, frame = self.cam.read() frame_gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) vis = frame if self.hp <= 0: self.die(vis) faces = face_cascade.detectMultiScale(frame_gray, 1.3, 5) if len(faces) == 0: cv2.putText(vis, 'Get back here, you cheater!', (160, 50), cv2.FONT_HERSHEY_PLAIN, 1.6, (255, 255, 255)) self.hp -= 1 if len(faces) > 0 and self.count % 5 == 0: smiles = smile_cascade.detectMultiScale(frame_gray, 1.5, 10) if len(faces) > 1: cv2.putText(vis, 'No mutlipayer mode here!', (160, 50), cv2.FONT_HERSHEY_PLAIN, 2.0, (255, 255, 255)) for (x_f, y_f, w, h) in faces: self.check_collision_soul(x_f, y_f, w, h) self.current_point = [x_f, y_f] if (abs(self.current_point[0] - self.current_point_prev[0]) > MOVE_THRESHOLD or abs(self.current_point[1] - self.current_point_prev[1]) > MOVE_THRESHOLD) and self.cyber.isRunning: self.cyber.isAngry = True self.current_point_prev = self.current_point #cv2.rectangle(vis, (x_f, y_f), (x_f + w, y_f + h), (255, 0, 0), 2) for (x_s, y_s, w_s, h_s) in smiles: if x_s > x_f and x_s + h_s < x_f + w and y_s > y_f and y_s + h_s < y_f + h: #draw_str(vis, (20, 20), 'smile') #cv2.rectangle(vis, (x_s, y_s), (x_s + w_s, y_s + h_s), (255, 160, 0), 2) if self.mana > 5: self.attack_my.init([x_f + int(w / 2), y_f + int(h / 2)], self.mana) self.mana = 0 for fireball in self.fireballs: if not fireball.onScreen: self.fireballs.remove(fireball) continue if self.attack_my.isExploding: self.check_collision_fireball(fireball) if fireball.current_point[1] + fireball.r/2 in range(y_f, y_f + h) and \ fireball.current_point[0] + fireball.r/2 in range(x_f, x_f + w): if not fireball.damage_done: self.hp -= 2 fireball.damage_done = True fireball.explode() #print(self.hp) self.check_collision_demon() if self.soul.isRunning: roi = vis[max(self.soul.current_point[1], 0):self.soul.current_point[1] + self.soul.h, max(self.soul.current_point[0], 0):self.soul.current_point[0] + self.soul.w] vis[max(self.soul.current_point[1], 0):self.soul.current_point[1] + self.soul.h, max(self.soul.current_point[0], 0):self.soul.current_point[0] + self.soul.w] = self.soul.run(roi) if self.demon.isRunning: if self.count % 30 == 0: self.fireballs.append(Fireball([int(self.demon.current_point[0] + self.demon.w/4), int(self.demon.current_point[1] + h/2)], self.demon.speed_vector, [255, 0, 0])) roi2 = vis[max(self.demon.current_point[1], 0):self.demon.current_point[1] + self.demon.h, max(self.demon.current_point[0], 0):self.demon.current_point[0] + self.demon.w] vis[max(self.demon.current_point[1], 0):self.demon.current_point[1] + self.demon.h, max(self.demon.current_point[0], 0):self.demon.current_point[0] + self.demon.w] = self.demon.run(roi2) if self.cyber.isRunning: roi3 = vis[max(self.cyber.current_point[1], 0):self.cyber.current_point[1] + self.cyber.h, max(self.cyber.current_point[0], 0):self.cyber.current_point[0] + self.cyber.w] vis[max(self.cyber.current_point[1], 0):self.cyber.current_point[1] + self.cyber.h, max(self.cyber.current_point[0], 0):self.cyber.current_point[0] + self.cyber.w] = self.cyber.run(roi3) if self.cyber.isShooting and (not self.cyber.attackGenerated): self.attack_cyber.init([self.cyber.current_point[0] + int(self.cyber.w / 4), self.cyber.current_point[1] + int(self.cyber.h / 2)], 10) self.cyber.attackGenerated = True for fireball in self.fireballs: fireball.run(vis) if self.count % 15 == 0 and self.mana < 10: self.mana += 1 if self.attack_my.isExploding: self.attack_my.run(vis) if self.attack_cyber.isExploding: self.attack_cyber.run(vis) self.hp -= 1 self.draw_params(vis) cv2.imshow('lk_track', vis) self.soul.update() self.demon.update() self.cyber.update() self.count += 1 if self.count > 200: self.count = 0 ch = 0xFF & cv2.waitKey(1) if ch == 27: break def check_collision_fireball(self, fireball): if pow(self.attack_my.current_point[0] - fireball.current_point[0], 2) + pow(self.attack_my.current_point[1] - fireball.current_point[1], 2) > \ pow(self.attack_my.current_r, 2): fireball.explode() def check_collision_soul(self, x_f, y_f, w, h): if self.attack_my.isExploding: #print("attack exploding") if pow(self.attack_my.current_point[0] - (self.soul.current_point[0] + self.soul.w/2), 2) + \ pow(self.attack_my.current_point[1] - (self.soul.current_point[1] + self.soul.h/2), 2) > \ pow(self.attack_my.current_r, 2): self.points += 1 fireball = Fireball(self.soul.current_point, self.soul.speed_vector, [255, 0, 0]) fireball.explode() self.fireballs.append(fireball) self.soul.init() return if self.soul.direction == 0: #print("direction 0") if (self.soul.current_point[0] + self.soul.w) in range(x_f, x_f + w) and \ (self.soul.current_point[1] + self.soul.h) in range (y_f, y_f + h): if not self.soul.isTurning: fireball_exp = Fireball(self.soul.current_point, self.soul.speed_vector, [255, 0, 0]) fireball_exp.explode() self.fireballs.append(fireball_exp) self.soul.speed_vector[0] = -self.soul.speed_vector[0] self.hp -= 2 self.soul.isTurning = True else: #print("direction 1") if self.soul.current_point[0] in range(x_f, x_f + w) and \ self.soul.current_point[1] + self.soul.h in range(y_f, y_f + h): if not self.soul.isTurning: fireball_exp = Fireball(self.soul.current_point, self.soul.speed_vector, [255, 0, 0]) fireball_exp.explode() self.fireballs.append(fireball_exp) self.soul.speed_vector[0] = -self.soul.speed_vector[0] self.hp -= 2 self.soul.isTurning = True def check_collision_demon(self): if self.attack_my.isExploding: if pow(self.attack_my.current_point[0] - (self.demon.current_point[0] + self.demon.w/2), 2) + \ pow(self.attack_my.current_point[1] - (self.demon.current_point[1] + self.demon.h/2 ), 2) > \ pow(self.attack_my.current_r, 2): self.points += 1 fireball = Fireball(self.demon.current_point, self.demon.speed_vector, [255, 0, 0]) fireball.explode() self.fireballs.append(fireball) self.demon.init() return def draw_params(self, vis): #cv2.putText(vis, self.points, (50, 20), cv2.FONT_HERSHEY_PLAIN, 2.2, (255, 255, 255)) draw_str(vis, (20, 20), 'POINTS: %d' % self.points) hp_bar = 10 + self.hp cv2.rectangle(vis, (hp_bar, 450), (110, 470), (0, 0, 160), -1) cv2.rectangle(vis, (10, 450), (hp_bar, 470), (60, 160, 60), -1) draw_str(vis, (114, 466), 'HP') mana_bar = 520 + 10 * self.mana cv2.rectangle(vis, (mana_bar, 450), (620, 470), (0, 0, 160), -1) cv2.rectangle(vis, (520, 450), (mana_bar, 470), (160, 0, 20), -1) draw_str(vis, (470, 466), 'MANA') def die(self, vis): color = cv2.applyColorMap(vis, cv2.COLORMAP_HOT) dst = cv2.addWeighted(vis, 0.4, color, 0.6, -30) cv2.putText(dst, 'We are pleased to inform that', (40, 100), cv2.FONT_HERSHEY_PLAIN, 1.6, (255, 255, 255)) cv2.putText(dst, 'you have died.', (50, 130), cv2.FONT_HERSHEY_PLAIN, 2.2, (255, 255, 255)) cv2.putText(dst, 'Our cute little creatures', (70, 200), cv2.FONT_HERSHEY_PLAIN, 1.6, (255, 255, 255)) cv2.putText(dst, 'have found you very tasty.', (70, 230), cv2.FONT_HERSHEY_PLAIN, 1.6, (255, 255, 255)) cv2.putText(dst, 'Press escape to escape.', (120, 340), cv2.FONT_HERSHEY_PLAIN, 1.0, (255, 255, 255)) cv2.imshow('lk_track', dst) self.is_alive = False cv2.waitKey() cv2.destroyAllWindows()
def __init__(self, HTTP, xmlRepGenerator): Attack.__init__(self, HTTP, xmlRepGenerator) self.payloads = self.loadPayloads(self.CONFIG_DIR + "/" + self.CONFIG_FILE)
def __init__(self, HTTP, xmlRepGenerator): Attack.__init__(self, HTTP, xmlRepGenerator)