def pq_doublestrike(user, target): """Perform a Doublestrike -- two attacks at -2""" hit1 = max([0, atk_roll(user.combat['atk'], target.combat['dfn'], \ user.temp['stats'].get("Attack", 0)-2, \ target.temp['stats'].get("Defense", 0))]) hit2 = max([0, atk_roll(user.combat['atk'], target.combat['dfn'], \ user.temp['stats'].get("Attack", 0)-2, \ target.temp['stats'].get("Defense", 0))]) hit = hit1 + hit2 return (hit > 0, hit)
def pq_backstab(user, target): """Perform a Backstab -- a single attack which does x2 damage if you succeed at Skill vs Fortitude""" check = atk_roll([0, user.stats[5]], [0, target.stats[3]], \ user.temp['stats'].get("Skill", 0), \ target.temp['stats'].get("Fortitude", 0)) hit = atk_roll(user.combat['atk'], target.combat['dfn'], \ user.temp['stats'].get("Attack", 0), \ target.temp['stats'].get("Defense", 0)) if hit > 0 and check > 0: return (hit > 0, hit * 2) return (hit > 0, hit)
def pq_petrify(user, target): """Perform a Petrify vs Fortitude.""" hit1 = atk_roll([0, user.stats[5]], [0, target.stats[3]], \ user.temp['stats'].get("Skill", 0), \ target.temp['stats'].get("Fortitude", 0)) hit2 = atk_roll([0, user.stats[5]], [0, target.stats[3]], \ user.temp['stats'].get("Skill", 0), \ target.temp['stats'].get("Fortitude", 0)) hit3 = atk_roll([0, user.stats[5]], [0, target.stats[3]], \ user.temp['stats'].get("Skill", 0), \ target.temp['stats'].get("Fortitude", 0)) hit = hit1 > 0 and hit2 > 0 and hit3 > 0 damage = user.hitpoints[0] if hit else 0 return (hit, damage)
def pq_charm(user, target): """Perform a Charm vs Mind.""" hit1 = atk_roll([0, user.stats[5]], [0, target.stats[4]], \ user.temp['stats'].get("Skill", 0), \ target.temp['stats'].get("Mind", 0)) hit2 = atk_roll([0, user.stats[5]], [0, target.stats[4]], \ user.temp['stats'].get("Skill", 0), \ target.temp['stats'].get("Mind", 0)) if hit1 > 0 and hit2 > 0: targstring = "The monster is " if hasattr(user, "gear") \ else "You are " send_to_console(targstring + "charmed!") target.temp['condition']["charmed"] = 4 return (True, 0) return (False, 0)
def pq_dominate(user, target): """Perform a Dominate (Skill vs Mind); if successful, enemy attacks self""" affect = atk_roll([0, user.stats[5]], [0, target.stats[4]], \ user.temp['stats'].get("Skill", 0), \ target.temp['stats'].get("Mind", 0)) if affect > 0: hit = atk_roll(target.combat['atk'], target.combat['dfn'], \ target.temp['stats'].get("Attack", 0) + affect, \ target.temp['stats'].get("Defense", 0)) targstring = "The monster is " if hasattr(user, "gear") \ else "You are " targstring2 = "s itself!" if hasattr(user, "gear") else " yourself!" print targstring + "dominated, and attack" + targstring2 return (hit > 0, hit) return (affect > 0, 0)
def pq_telekinesis(user, target): """Perform a TK (Skill vs Ref); if successful, enemy attacks self""" affect = atk_roll([0, user.stats[5]], [0, target.stats[3]], \ user.temp['stats'].get("Skill", 0), \ target.temp['stats'].get("Reflexes", 0)) if affect > 0: hit = atk_roll(target.combat['atk'], target.combat['dfn'], \ target.temp['stats'].get("Attack", 0) + affect, \ target.temp['stats'].get("Defense", 0)) targstring = "The monster is " if hasattr(user, "gear") \ else "You are " targstring2 = "s itself!" if hasattr(user, "gear") else " yourself!" print targstring + "manipulated, and attack" + targstring2 return (hit > 0, hit) return (affect > 0, 0)
def pq_dominate(user, target): """Perform a Dominate (Skill vs Mind); if successful, enemy attacks self""" affect = atk_roll([0, user.stats[5]], [0, target.stats[4]], \ user.temp['stats'].get("Skill", 0), \ target.temp['stats'].get("Mind", 0)) if affect > 0: hit = atk_roll(target.combat['atk'], target.combat['dfn'], \ target.temp['stats'].get("Attack", 0) + affect, \ target.temp['stats'].get("Defense", 0)) targstring = "The monster is " if hasattr(user, "gear") \ else "You are " targstring2 = "s itself!" if hasattr(user, "gear") else " yourself!" send_to_console(targstring + "dominated, and attack" + targstring2) return (hit > 0, hit) return (affect > 0, 0)
def pq_charm(user, target): """Perform a Charm vs Mind.""" hit1 = atk_roll([0, user.stats[5]], [0, target.stats[4]], \ user.temp['stats'].get("Skill", 0), \ target.temp['stats'].get("Mind", 0)) hit2 = atk_roll([0, user.stats[5]], [0, target.stats[4]], \ user.temp['stats'].get("Skill", 0), \ target.temp['stats'].get("Mind", 0)) if hit1 > 0 and hit2 > 0: targstring = "The monster is " if hasattr(user, "gear") \ else "You are " print targstring + "charmed!" target['condition']["charmed"] = 4 return (True, 0) return (False, 0)
def pq_telekinesis(user, target): """Perform a TK (Skill vs Ref); if successful, enemy attacks self""" affect = atk_roll([0, user.stats[5]], [0, target.stats[3]], \ user.temp['stats'].get("Skill", 0), \ target.temp['stats'].get("Reflexes", 0)) if affect > 0: hit = atk_roll(target.combat['atk'], target.combat['dfn'], \ target.temp['stats'].get("Attack", 0) + affect, \ target.temp['stats'].get("Defense", 0)) targstring = "The monster is " if hasattr(user, "gear") \ else "You are " targstring2 = "s itself!" if hasattr(user, "gear") else " yourself!" send_to_console(targstring + "manipulated, and attack" + targstring2) return (hit > 0, hit) return (affect > 0, 0)
def pq_rage(user, target): """Perform a Rage -- a single attack with +Skill buff, and -2 Defense self-debuff for 2 rounds""" hit = atk_roll(user.combat['atk'], target.combat['dfn'], \ user.temp['stats'].get("Attack", 0) + user.stats[5], \ target.temp['stats'].get("Defense", 0)) user.temp_bonus(["Defense"], -2, 4) return (hit > 0, hit)
def pq_smite(user, target): """Perform a Smite -- a single attack with a buff of 1dSkill""" temp_atk = user.combat['atk'] temp_atk[1] += random.randint(1, user.stats[5]) hit = atk_roll(temp_atk, target.combat['dfn'], \ user.temp['stats'].get("Attack", 0), \ target.temp['stats'].get("Defense", 0)) return (hit > 0, hit)
def pq_precog(user, target): """Passive skill: Mind vs Mind for 1-round buff to attack and defense""" buff = atk_roll([0, user.stats[4]], [0, target.stats[4]], \ user.temp['stats'].get("Mind", 0), \ target.temp['stats'].get("Mind", 0)) if buff > 0: targstring = "You predict the enemy's actions!" if \ hasattr(user, "gear") else "The enemy predicts your actions!" user.temp_bonus(["Attack", "Defense"], buff, 2) send_to_console(targstring) return
def pq_precog(user, target): """Passive skill: Mind vs Mind for 1-round buff to attack and defense""" buff = atk_roll([0, user.stats[4]], [0, target.stats[4]], \ user.temp['stats'].get("Mind", 0), \ target.temp['stats'].get("Mind", 0)) if buff > 0: targstring = "You predict the enemy's actions!" if \ hasattr(user, "gear") else "The enemy predicts your actions!" user.temp_bonus(["Attack", "Defense"], buff, 2) print targstring return
def pq_missile(user, target): """Perform a Missile -- a single attack, Skill vs Reflexes""" num_missile = user.level[1]/3 + 1 targstring = "You send " if hasattr(user, "gear") \ else "The monster sends " print targstring + str(num_missile) +" missiles!" hit = 0 for i in range(num_missile): hit += max([0, atk_roll([0, user.stats[5]], [0, target.stats[2]], \ user.temp['stats'].get("Skill", 0), \ target.temp['stats'].get("Reflex", 0))]) return (hit > 0, hit)
def pq_missile(user, target): """Perform a Missile -- a single attack, Skill vs Reflexes""" num_missile = user.level[1] / 3 + 1 targstring = "You send " if hasattr(user, "gear") \ else "The monster sends " send_to_console(targstring + str(num_missile) + " missiles!") hit = 0 for i in range(num_missile): hit += max([0, atk_roll([0, user.stats[5]], [0, target.stats[2]], \ user.temp['stats'].get("Skill", 0), \ target.temp['stats'].get("Reflex", 0))]) return (hit > 0, hit)
def pq_burn(user, target): """Perform a Burn (Atk vs Ref, applies Burning condition which re-calls the skill each turn for 1dSkill turns.""" hit = atk_roll(user.combat['atk'], [0, target.stats[3]], \ user.temp['stats'].get("Attack", 0), \ target.temp['stats'].get("Reflexes", 0)) if hit > 0 and "burning" not in target.temp['condition']: targstring = "The monster is " if hasattr(user, "gear") \ else "You are " send_to_console(targstring + "burning!") target.temp['condition']["burning"] = 4 return (hit > 0, hit)
def pq_cure(user, target): """Perform a Cure (healing 1dSkill + level), followed by a normal attack.""" cure = random.randint(1, user.stats[5] + \ user.temp['stats'].get("Skill", 0)) + user.level[1] user.cure(cure) hit = atk_roll(user.combat['atk'], target.combat['dfn'], \ user.temp['stats'].get("Attack", 0), \ target.temp['stats'].get("Defense", 0)) targstring = "You are " if hasattr(user, "player") else "The monster is " print targstring + "cured for " + str(cure) + " hp! An attack follows." return (hit > 0, hit)
def pq_cure(user, target): """Perform a Cure (healing 1dSkill + level), followed by a normal attack.""" cure = random.randint(1, user.stats[5] + \ user.temp['stats'].get("Skill", 0)) + user.level[1] user.cure(cure) hit = atk_roll(user.combat['atk'], target.combat['dfn'], \ user.temp['stats'].get("Attack", 0), \ target.temp['stats'].get("Defense", 0)) targstring = "You are " if hasattr(user,"player") else "The monster is " print targstring+"cured for "+str(cure)+" hp! An attack follows." return (hit > 0, hit)
def pq_burn(user, target): """Perform a Burn (Atk vs Ref, applies Burning condition which re-calls the skill each turn for 1dSkill turns.""" hit = atk_roll(user.combat['atk'], [0, target.stats[3]], \ user.temp['stats'].get("Attack", 0), \ target.temp['stats'].get("Reflexes", 0)) if hit > 0 and "burning" not in target.temp['condition']: targstring = "The monster is " if hasattr(user, "gear") \ else "You are " print targstring + "burning!" target.temp['condition']["burning"] = 4 return (hit > 0, hit)
def pq_acidspray(user, target): """Perform an Acidspray -- Fort vs Def, full damage + 1/2 damage as Def debuff for 2 rounds""" hit = atk_roll([0, user.stats[3]], target.combat['dfn'], \ user.temp['stats'].get("Fortitude", 0), \ target.temp['stats'].get("Defense", 0)) if hit > 0: debuff = max([hit / 2, 1]) targstring = "The monster is " if hasattr(user, "gear") \ else "You are " send_to_console(targstring + "sprayed with acid!") target.temp_bonus(["Defense"], debuff, 4) return (hit > 0, hit)
def pq_leech(user, target): """Perform a Leech -- a single attack which cures for half the damage it deals, up to Skill""" hit = atk_roll(user.combat['atk'], [0, target.stats[3]], \ user.temp['stats'].get("Attack", 0), \ target.temp['stats'].get("Fortitude", 0)) if hit > 0: cure = max([hit / 2, 1]) targstring = "You drain " if hasattr(user, "gear") \ else "The monster drains " send_to_console(targstring + str(cure) + " hit points!") user.cure(cure) return (hit > 0, hit)
def pq_acidspray(user, target): """Perform an Acidspray -- Fort vs Def, full damage + 1/2 damage as Def debuff for 2 rounds""" hit = atk_roll([0, user.stats[3]], target.combat['dfn'], \ user.temp['stats'].get("Fortitude", 0), \ target.temp['stats'].get("Defense", 0)) if hit > 0: debuff = max([hit/2, 1]) targstring = "The monster is " if hasattr(user, "gear") \ else "You are " print targstring + "sprayed with acid!" target.temp_bonus(["Defense"], debuff, 4) return (hit > 0, hit)
def pq_fear(user, target): """Perform a Fear (Skill vs Mind) to debuff.""" hit = atk_roll([0, user.stats[5]], [0, target.stats[4]], \ user.temp['stats'].get("Skill", 0), \ target.temp['stats'].get("Mind", 0)) if hit > 0: hit = max([1, hit/2]) targstring = "The monster is " if hasattr(user, "gear") \ else "You are " print targstring + "frightened!" target.temp_bonus(["Attack"," Defense"], -hit, 4) return (True, 0) return (False, 0)
def pq_entangle(user, target): """Perform an Entangle (Skill vs Reflexes) to debuff.""" hit = atk_roll([0, user.stats[5]], [0, target.stats[2]], \ user.temp['stats'].get("Skill", 0), \ target.temp['stats'].get("Reflex", 0)) if hit > 0: targstring = "The monster is " if hasattr(user, "gear") \ else "You are " print targstring + "entangled!" target.temp['condition']["entangled"] = 4 target.temp_bonus(["Attack", "Defense"], -hit, 4) return (True, 0) return (False, 0)
def pq_leech(user, target): """Perform a Leech -- a single attack which cures for half the damage it deals, up to Skill""" hit = atk_roll(user.combat['atk'], [0, target.stats[3]], \ user.temp['stats'].get("Attack", 0), \ target.temp['stats'].get("Fortitude", 0)) if hit > 0: cure = max([hit/2, 1]) targstring = "You drain " if hasattr(user, "gear") \ else "The monster drains " print targstring + str(cure) + " hit points!" user.cure(cure) return (hit > 0, hit)
def pq_fear(user, target): """Perform a Fear (Skill vs Mind) to debuff.""" hit = atk_roll([0, user.stats[5]], [0, target.stats[4]], \ user.temp['stats'].get("Skill", 0), \ target.temp['stats'].get("Mind", 0)) if hit > 0: hit = max([1, hit / 2]) targstring = "The monster is " if hasattr(user, "gear") \ else "You are " send_to_console(targstring + "frightened!") target.temp_bonus(["Attack", " Defense"], -hit, 4) return (True, 0) return (False, 0)
def pq_entangle(user, target): """Perform an Entangle (Skill vs Reflexes) to debuff.""" hit = atk_roll([0, user.stats[5]], [0, target.stats[2]], \ user.temp['stats'].get("Skill", 0), \ target.temp['stats'].get("Reflex", 0)) if hit > 0: targstring = "The monster is " if hasattr(user, "gear") \ else "You are " send_to_console(targstring + "entangled!") target.temp['condition']["entangled"] = 4 target.temp_bonus(["Attack", "Defense"], -hit, 4) return (True, 0) return (False, 0)
def pq_cure(user, target): """Perform a Cure (healing 1dSkill + level), followed by a normal attack.""" #logger.debug(user.name) cure = random.randint(1, user.stats[5] + \ user.temp['stats'].get("Skill", 0)) + user.level[1] user.cure(cure) hit = atk_roll(user.combat['atk'], target.combat['dfn'], \ user.temp['stats'].get("Attack", 0), \ target.temp['stats'].get("Defense", 0)) targstring = "You are " if (len(user.name) > 1) else "The monster is " send_to_console(targstring + "cured for " + str(cure) + " hp! An attack follows.") return (hit > 0, hit)
def pq_prismspray(user, target): """Perform a Prismatic Spray (Skill vs random stat to debuff that stat""" effectstring = ('blunted', 'diminished', 'made sluggish', \ 'weakened', 'befuddled', 'disconcerted') statpick = random.choice([random.randint(0, 5) for i in range(6)]) affect = atk_roll([0, user.stats[5]], [0, target.stats[statpick]], \ user.temp['stats'].get("Skill", 0), \ target.temp['stats'].get(pq_reverse_stats[statpick], 0)) if affect > 0: targstring = "The monster is " if hasattr(user, "gear") \ else "You are " print targstring + effectstring[statpick] + "!" target.temp_bonus([pq_reverse_stats[statpick]], -affect, 4) return (affect > 0, 0)
def pq_prismspray(user, target): """Perform a Prismatic Spray (Skill vs random stat to debuff that stat""" effectstring = ('blunted', 'diminished', 'made sluggish', \ 'weakened', 'befuddled', 'disconcerted') statpick = random.choice([random.randint(0, 5) for i in range(6)]) affect = atk_roll([0, user.stats[5]], [0, target.stats[statpick]], \ user.temp['stats'].get("Skill", 0), \ target.temp['stats'].get(pq_reverse_stats[statpick], 0)) if affect > 0: targstring = "The monster is " if hasattr(user, "gear") \ else "You are " send_to_console(targstring + effectstring[statpick] + "!") target.temp_bonus([pq_reverse_stats[statpick]], -affect, 4) return (affect > 0, 0)
def attack_enemy(self, user, target): """Just a simple attack, Attack vs Defense. Basic, lovely.""" if "charmed" in user.temp['condition']: targstring = "You are " if user == self.char else "The monster is " print targstring + "charmed, and cannot attack!" return hit = atk_roll(user.combat['atk'], target.combat['dfn'], \ user.temp['stats'].get("Attack", 0), \ target.temp['stats'].get("Defense", 0)) if hit > 0: self.be_hit(target, hit) return else: print "The attack is unsuccessful." return
def pq_confusion(user, target): """Perform a Confuse (Mind vs Mind); if successful, deal 1dSkill skill points damage""" affect = atk_roll([0, user.stats[4]], [0, target.stats[4]], \ user.temp['stats'].get("Mind", 0), \ target.temp['stats'].get("Mind", 0)) if affect > 0: damage = max([0, random.choice([random.randint(1, user.stats[5]) \ for i in range(0, 6)]) + user.temp['stats'].get("Skill", 0)]) targstring = "The monster is " if hasattr(user, "gear") \ else "You are " pl = "s" if hasattr(user, "gear") else "" send_to_console(targstring + "confused, and lose" + pl + " " + str(damage) \ + " skill points!") target.huh(damage) return (affect > 0, 0)
def pq_trip(user, target): """Perform a Trip -- a single attack for half damage + debuff Attack 1dSkill""" hit = atk_roll(user.combat['atk'], target.combat['atk'], \ user.temp['stats'].get("Attack", 0), \ target.temp['stats'].get("Attack", 0)) if hit > 0: hit = max([hit / 2, 1]) targstring = "The monster is " if hasattr(user, "gear") \ else "You are " send_to_console(targstring + "tripped!") target.temp['condition']["tripped"] = 2 debuff = max([0, random.choice([random.randint(0, user.stats[5]) \ for i in range(0, 6)]) + user.temp['stats'].get("Skill", 0)]) target.temp_bonus(["Attack"], debuff, 4) return (hit > 0, hit)
def pq_trip(user, target): """Perform a Trip -- a single attack for half damage + debuff Attack 1dSkill""" hit = atk_roll(user.combat['atk'], target.combat['atk'], \ user.temp['stats'].get("Attack", 0), \ target.temp['stats'].get("Attack", 0)) if hit > 0: hit = max([hit/2, 1]) targstring = "The monster is " if hasattr(user, "gear") \ else "You are " print targstring + "tripped!" target.temp['condition']["tripped"] = 2 debuff = max([0, random.choice([random.randint(0, user.stats[5]) \ for i in range(0, 6)]) + user.temp['stats'].get("Skill", 0)]) target.temp_bonus(["Attack"], debuff, 4) return (hit > 0, hit)
def pq_confusion(user, target): """Perform a Confuse (Mind vs Mind); if successful, deal 1dSkill skill points damage""" affect = atk_roll([0, user.stats[4]], [0, target.stats[4]], \ user.temp['stats'].get("Mind", 0), \ target.temp['stats'].get("Mind", 0)) if affect > 0: damage = max([0, random.choice([random.randint(1, user.stats[5]) \ for i in range(0, 6)]) + user.temp['stats'].get("Skill", 0)]) targstring = "The monster is " if hasattr(user, "gear") \ else "You are " pl= "s" if hasattr(user, "gear") else "" print targstring + "confused, and lose" + pl + " " + str(damage) \ + " skill points!" target.huh(damage) return (affect > 0, 0)
def trialofbeing(self): """Run character through the Trial of Being.""" sta = random.sample(["Attack", "Defense", "Reflexes", "Fortitude", "Mind", "Skill"], 3) with open("data/pq_trialmsg.json") as f: trials = json.load(f) for i, s in enumerate(sta): time.sleep(1) print textwrap.fill( "The " + ("first", "second", "third")[i] + " challenge begins. " + trials["tests"][s] ), "\n" result = atk_roll([0, self.char.stats[pq_stats[s]]], [0, self.trial_num], 0, 0) if result < 0: print trials["lose"][s], "\n" self.damage = result self.failure() return else: print trials["win"][s], "\n" self.knowledge += self.trial_num self.success()
def trialofbeing(self): """Run character through the Trial of Being.""" sta = random.sample(['Attack', 'Defense', 'Reflexes', 'Fortitude', \ 'Mind', 'Skill'], 3) with open('data/pq_trialmsg.json') as f: trials = json.load(f) for i, s in enumerate(sta): time.sleep(0.5) send_to_console(textwrap.fill("The " + ("first", "second", "third")[i] + \ " challenge begins. " + trials['tests'][s]), '\n') result = atk_roll([0, self.char.stats[pq_stats[s]]], \ [0, self.trial_num], 0, 0) if result < 0: send_to_console(trials['lose'][s], '\n') self.damage = result self.failure() return else: send_to_console(trials['win'][s], '\n') self.knowledge += self.trial_num self.success()
def __init__(self, lvl, char, enemy): """Initialize a combat encounter instance, using either \ a supplied enemy or generating a new one.""" if not enemy: self.enemy = PQ_Enemy() self.enemy.gen(lvl) else: self.enemy = enemy self.turn = -1 self.char = char initiative_differential = atk_roll([0, self.char.stats[2]], \ [0, self.enemy.stats[2]], self.char.combat['initiative'], 0) self.turnorder = ['monster', 'player'] if initiative_differential > 0: self.turnorder = ['player', 'monster'] elif initiative_differential == 0: if char.stats[2] > self.enemy.stats[2]: self.turnorder = ['player', 'monster'] elif char.stats[2] == self.enemy.stats[2]: if 'ImprovedInititiative' in char.feats: self.turnorder = ['player', 'monster'] elif random.randint(0, 1): self.turnorder = ['player', 'monster'] self.done = False