def _effect_from_data(self, effect_data: Dict, effect_label: str, player: Player) -> Effect: effect_label = Effects(effect_label) if effect_label == Effects.EQUIP_AND_USE_MOD: mod_label = effect_data['mod'] mod = Mod(ModData(**load_mod_data_kwargs(mod_label))) effect = effects.EquipAndUseMod(mod) elif effect_label == Effects.RANDOM_SOUND: sound_files = effect_data['sound files'] effect = effects.PlayRandomSound(sound_files) elif effect_label == Effects.FACE_AND_PURSUE: effect = effects.FaceAndPursueTarget(player) elif effect_label == Effects.STOP_MOTION: effect = effects.StopMotion() elif effect_label == Effects.DROP_ITEM: item_label = effect_data['item_label'] effect = effects.DropItem(item_label) elif effect_label == Effects.KILL: effect = effects.Kill() elif effect_label == Effects.PLAY_SOUND: effect = effects.PlaySound(effect_data['sound_file']) elif effect_label == Effects.DRAW_ON_MAP: image_file = effect_data['image_file'] angled = 'angled' in effect_data effect = effects.DrawOnScreen(image_file, angled) elif effect_label == Effects.FACE: effect = effects.FaceTarget(player) else: raise NotImplementedError( 'Unrecognized effect label %s' % (effect_label,)) return effect
def shield_of_strength_mod(champ): assert isinstance(champ, Gillan), 'Attempt to add shield_of_strength_mod Mod() to non-Gillan champ' def next_turn(): champ.abl3_active=False mod = Mod(priority=5, turn=next_turn, lifetime=1, ) return mod
def ult_slow(): def modify(speed): return speed * 0.4 mod = Mod( priority=32, mod=modify, lifetime=3, ) return mod
def test_mod_str_output(self) -> None: description = 'banana hammock' mod_data = ModData('legs', 'pistol', 'no_image', 'no_image', description) hammock_mod = Mod(mod_data) self.assertEqual(hammock_mod.description, description) self.assertEqual(str(hammock_mod), description) mod_data = ModData('legs', 'pistol', 'no_image', 'no_image', description, buffs=[Buffs.DAMAGE], proficiencies=[Proficiencies.STEALTH]) nice_mod = Mod(mod_data) self.assertIn('damage', str(nice_mod)) self.assertIn('stealth', str(nice_mod))
def charge_mod(champ): # Return Mod that handles ability assert isinstance(champ, Gillan), 'Attempt to add charge_mod Mod() to non-Gillan champ' start_speed = .5 decrement=.1 if start_damage%decrement != 0: raise Exception d = {'speed':start_damage} def modify(speed): return speed+d['speed'] def next_turn(): d['speed'] -= decrement mod = Mod(priority=5, mod=modify, turn=next_turn, lifetime=start_speed//decrement, ) return mod
non è possibile - 200 health. the next Lungo has inf range.''' if self.health <= 200: self.game.alert('Not Enough Health') return ANGELO_NOT_ENOUGH_HEALTH self.damage(amount=200, defend=False) self.ult_active=True return SUCCESS def tira_forte_attack(champ): assert isinstance(champ, Angelo), 'Attempt to apply tira forte attack mod to non-Angelo champ' def modify(attack): return attack + champ.tira_forte*15 mod = Mod( priority=32, mod=modify, liftime=float('inf'), ) return mod d = { 'health':565, 'max_health':565, 'health_regen':10, 'defense':5, 'speed':2.7, 'attack':20, 'attack_range':2.5, 'attack_delay':0, 'mana':0, 'max_mana':0,
direct_a = (direct[0])/a[0]*a[1] - direct[1] direct_b = (direct[0])/b[0]*b[1] - direct[1] return target_a*direct_a > 0 and target_b*direct_b > 0 def mark_speed(champ): assert isinstance(champ, DarkAtKnight), 'Attempt to add mark_speed Mod() to non-DarkAtKnight champ' def modify(x): increment = 0 for target, marks in champ.marked.items(): if within_direction(champ.loc, target.loc, champ.direction): increment += marks return x + increment*0.1 mod = Mod( priority = 5, mod = modify, lifetime = float('inf') ) return mod def mark_damage(champ): assert isinstance(champ, DarkAtKnight), 'Attempted to add mark_damage Mod() to non-DarkAtKnight champ' def modify(x): increment = 0 for target, marks in champ.marked.items(): if within_direction(champ.loc, target.loc, champ.direction): increment += marks return x + increment*3 mod = Mod( priority = 5,
'max_mana':70, 'mana_regen':3, 'magic_mod':0, 'magic_resist':0, } def vault_speed(champ): assert isinstance(champ, Stubby), 'Attempt to add vault speed boast to non-Stubby champion' def modify(speed): if champ.vaulting: return speed + 2.7 # 1.3 + 2.7 == 4 return speed mod = Mod( priority=5, mod=modify, lifetime=float('inf'), ) return mod def ult_slow(): def modify(speed): return speed * 0.4 mod = Mod( priority=32, mod=modify, lifetime=3, ) return mod def create(game, player): # Return instance of Stubby, used by champion select
def __init__(self, item_data: ItemData, pos: Vector2) -> None: mod = Mod(item_data.mod_data) self._image_file = item_data.image_file super().__init__(mod, pos)