def cutting(a): a.damage.type = CUTTING a.damage.multiplier = a.target.body.get_damage_multiplier( a.location, CUTTING) return a def damage_mod(mod): def f(a): a.damage.mod += mod return a return f al = Character(ST=11, DX=11) al.skills['Broadsword'] = +1 bob = Character() broadsword = Thing() broadsword.base = pipe(skill('Broadsword'), reach([1]), min_strength(9)) broadsword.thrust = pipe(broadsword.base, thrust_damage, damage_mod(+1), impaling) broadsword.swing = pipe(broadsword.base, swing_damage, damage_mod(+1), cutting) al_swing = pipe(al.attack, broadsword.swing, target_location(TORSO)) print(al_swing(bob))
def do_al_attack(self, target, location): return pipe(set_attacker(self.al), set_target(target), set_target_location(location), swing, resolve_attack)(init_attack())
sk = Skill.TABLE[skill_name] a.defense_skill += int(sk(a.target) / 2) a.defense = PARRY a.target.parries += 1 return a return f def defense_bonus(mod): def f(a): a.defense_skill += mod return a return f broadsword = Thing() broadsword.attack = pipe(uses_skill('Broadsword'), reach([1]), min_strength(9)) broadsword.thrust = pipe(broadsword.attack, thrust_damage, damage_mod(+1), impaling) broadsword.swing = pipe(broadsword.attack, swing_damage, damage_mod(+1), cutting) broadsword.parry = parry('Broadsword') staff = Thing() staff.attack = pipe(uses_skill('Staff'), reach([1, 2]), min_strength(6)) staff.thrust = pipe(staff.attack, thrust_damage, damage_mod(+2), crushing) staff.swing = pipe(staff.attack, swing_damage, damage_mod(+2), crushing) staff.parry = pipe(parry('Staff'), defense_bonus(+2))
stuck = True for function in flist: try: x = function(Branch(x)).commit() stuck = False except (AttributeError, KeyError): deferred.append(function) #not ready yet if stuck: x = deferred[0](x) #should raise AttributeError flist = deferred #try again with what is left return x return f apply_damage = pipe(injury, shock, stun, cripple) target_hit = pipe(roll_damage, penetration, ifelse(lambda a: a.damage.penetration > 0, apply_damage)) DEFENSES = [dodge, parry, block] def best_defense(a): #try them all, use branches to undo side effects of any unused ones # keep the ones that actually work valid_results = [ r for r in [d(Branch(a)) for d in DEFENSES] if r.defense_skill ] if len(valid_results):