Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
 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
Exemplo n.º 4
0
 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()
Exemplo n.º 5
0
    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)
Exemplo n.º 6
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)
Exemplo n.º 7
0
 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))
Exemplo n.º 8
0
    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)
Exemplo n.º 9
0
    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)
Exemplo n.º 10
0
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()
Exemplo n.º 11
0
 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)
Exemplo n.º 12
0
 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
Exemplo n.º 13
0
 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
Exemplo n.º 14
0
    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))
Exemplo n.º 15
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')
Exemplo n.º 16
0
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'
Exemplo n.º 17
0
    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,
        )
Exemplo n.º 18
0
    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]))
Exemplo n.º 19
0
 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)
Exemplo n.º 20
0
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')
Exemplo n.º 21
0
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)
Exemplo n.º 22
0
def insert_attack(host, port):
    Base.metadata.create_all(engine)
    session = Session()

    attack = Attack(host, port)
    session.add(attack)

    session.commit()
    session.close()
Exemplo n.º 23
0
 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
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]
class Goomba:
    # 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("Touch", 10)]

    def __init__(self):
        self.damage = 10

    def attack(self):
        return self.attacks[0].attack()
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()
Exemplo n.º 27
0
    def completions(self, caf, arguments_to_add=None, relations_to_add=None):
        """ Return all possible completions of a given caf.

        Also has the possibility to add extra arguments or attack
        relations to all completions this function returns. This can be
        useful when calculating the completions of a caf under a certain
        control configuration.
        """

        if arguments_to_add is None:
            arguments_to_add = set()
        if relations_to_add is None:
            relations_to_add = set()

        all_comp = set()

        # For every combination of uncertain arguments,
        for u_comb in self.powerset(caf.arg_u):
            u_comb = set(u_comb)
            this_args = caf.arg_f | u_comb | set(arguments_to_add)

            # Find all combination of uncertain attacks for this
            # combination of arguments
            u_attack_combs = self.powerset([
                u_attack for u_attack in caf.att_u
                if u_attack.arg_start in this_args
                and u_attack.arg_end in this_args
            ])

            for u_attack_comb in u_attack_combs:
                u_attack_comb = set(u_attack_comb)
                this_attacks = caf.att_f | u_attack_comb | relations_to_add
                bidir_combs = self.powerset([
                    bidir for bidir in caf.att_b if
                    bidir.arg_start in this_args and bidir.arg_end in this_args
                ])

                # Find all combination of bidirectional attacks for this
                # combination of arguments and uncertain attacks
                for bidir_comb in bidir_combs:
                    # For every bidirectional, add one of the two
                    # directions. Note inversion of start and end!
                    all_comp.add(
                        AF(args=this_args,
                           attacks=this_attacks | {
                               bidir if bidir in bidir_comb else Attack(
                                   arg_start=bidir.arg_end,
                                   arg_end=bidir.arg_start)
                               for bidir in caf.att_b
                           }))
        return all_comp
Exemplo n.º 28
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 = []
Exemplo n.º 29
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)

        self.nc = True if 'neural_cleanse' in self.params.loss_tasks else False
        self.best_loss = float('inf')
Exemplo n.º 30
0
 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