| @@ -4,6 +4,7 @@ import { LogEntry, LogLines, FAElem, LogLine, FormatEntry, FormatOpt, PropElem, | |||||
| import { World } from '@/game/world' | import { World } from '@/game/world' | ||||
| import { TestCategory } from '@/game/combat/tests' | import { TestCategory } from '@/game/combat/tests' | ||||
| import { VoreContainer } from '@/game/vore' | import { VoreContainer } from '@/game/vore' | ||||
| import { SoloTargeter } from '@/game/combat/targeters' | |||||
| export enum DamageType { | export enum DamageType { | ||||
| Pierce = "Pierce", | Pierce = "Pierce", | ||||
| @@ -464,7 +465,7 @@ export class CompositionAction extends Action { | |||||
| super(name, desc, properties.conditions ?? [], properties.tests ?? []) | super(name, desc, properties.conditions ?? [], properties.tests ?? []) | ||||
| this.consequences = properties.consequences ?? [] | this.consequences = properties.consequences ?? [] | ||||
| this.groupConsequences = properties.groupConsequences ?? [] | this.groupConsequences = properties.groupConsequences ?? [] | ||||
| this.targeters = properties.targeters ?? [] | |||||
| this.targeters = properties.targeters ?? [new SoloTargeter()] | |||||
| } | } | ||||
| execute (user: Creature, target: Creature): LogEntry { | execute (user: Creature, target: Creature): LogEntry { | ||||
| @@ -1,4 +1,4 @@ | |||||
| import { Consequence, DamageFormula, Condition, StatusEffect } from '@/game/combat' | |||||
| import { Consequence, DamageFormula, Condition, StatusEffect, Damage, DamageType } from '@/game/combat' | |||||
| import { Creature } from '@/game/creature' | import { Creature } from '@/game/creature' | ||||
| import { LogEntry, LogLines, LogLine, nilLog } from '@/game/interface' | import { LogEntry, LogLines, LogLine, nilLog } from '@/game/interface' | ||||
| import { Verb, PairLine } from '@/game/language' | import { Verb, PairLine } from '@/game/language' | ||||
| @@ -82,6 +82,32 @@ export class HealingConsequence extends Consequence { | |||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * Deals damage to the target and heals the user | |||||
| */ | |||||
| export class DrainConsequence extends Consequence { | |||||
| constructor (private damageFormula: DamageFormula, conditions: Condition[] = []) { | |||||
| super(conditions) | |||||
| } | |||||
| apply (user: Creature, target: Creature): LogEntry { | |||||
| const damage = this.damageFormula.calc(user, target) | |||||
| const heal = new Damage(...damage.damages.map(instance => ({ amount: instance.amount, type: DamageType.Heal, target: instance.target }))) | |||||
| console.log(heal) | |||||
| return new LogLines( | |||||
| new LogLine(`${user.name.capital} ${user.name.conjugate(new Verb("drain"))} `, damage.renderShort(), ` from ${target.name.objective}.`), | |||||
| target.takeDamage(damage), | |||||
| user.takeDamage(heal) | |||||
| ) | |||||
| } | |||||
| describe (user: Creature, target: Creature): LogEntry { | |||||
| return new LogLine( | |||||
| this.damageFormula.describe(user, target) | |||||
| ) | |||||
| } | |||||
| } | |||||
| /** | /** | ||||
| * Applies a status effect | * Applies a status effect | ||||
| */ | */ | ||||
| @@ -1,5 +1,6 @@ | |||||
| import { Encounter, Targeter } from '../combat' | import { Encounter, Targeter } from '../combat' | ||||
| import { Creature } from '../creature' | import { Creature } from '../creature' | ||||
| import { Container } from '../vore' | |||||
| export class SoloTargeter implements Targeter { | export class SoloTargeter implements Targeter { | ||||
| targets (primary: Creature, encounter: Encounter): Array<Creature> { | targets (primary: Creature, encounter: Encounter): Array<Creature> { | ||||
| @@ -12,3 +13,13 @@ export class SideTargeter implements Targeter { | |||||
| return encounter.combatants.filter(combatant => primary.side === combatant.side) | return encounter.combatants.filter(combatant => primary.side === combatant.side) | ||||
| } | } | ||||
| } | } | ||||
| export class PreyTargeter implements Targeter { | |||||
| constructor (private container: Container) { | |||||
| } | |||||
| targets (primary: Creature, encounter: Encounter): Array<Creature> { | |||||
| return this.container.contents | |||||
| } | |||||
| } | |||||
| @@ -1,9 +1,9 @@ | |||||
| import { FavorEscapedPrey, VoreAI } from '@/game/ai' | import { FavorEscapedPrey, VoreAI } from '@/game/ai' | ||||
| import { CompositionAction, DamageType, Side, Stat, StatDamageFormula, Vigor } from '@/game/combat' | |||||
| import { CompositionAction, ConstantDamageFormula, Damage, DamageType, FractionDamageFormula, Side, Stat, StatDamageFormula, Vigor } from '@/game/combat' | |||||
| import { PairCondition, TogetherCondition } from '@/game/combat/conditions' | import { PairCondition, TogetherCondition } from '@/game/combat/conditions' | ||||
| import { ConsumeConsequence } from '@/game/combat/consequences' | |||||
| import { ConsumeConsequence, DamageConsequence, DrainConsequence, StatusConsequence } from '@/game/combat/consequences' | |||||
| import { LogGroupConsequence } from '@/game/combat/groupConsequences' | import { LogGroupConsequence } from '@/game/combat/groupConsequences' | ||||
| import { SideTargeter } from '@/game/combat/targeters' | |||||
| import { PreyTargeter, SideTargeter, SoloTargeter } from '@/game/combat/targeters' | |||||
| import { Creature } from '@/game/creature' | import { Creature } from '@/game/creature' | ||||
| import { LogLine } from '@/game/interface' | import { LogLine } from '@/game/interface' | ||||
| import { ImproperNoun, MalePronouns, ProperNoun } from '@/game/language' | import { ImproperNoun, MalePronouns, ProperNoun } from '@/game/language' | ||||
| @@ -54,6 +54,25 @@ export default class Inazuma extends Creature { | |||||
| } | } | ||||
| )) | )) | ||||
| this.actions.push(new CompositionAction( | |||||
| "Level Drain", | |||||
| "Steal stats from prey", | |||||
| { | |||||
| conditions: [new PairCondition()], | |||||
| targeters: [new PreyTargeter(stomach)], | |||||
| consequences: [new DrainConsequence( | |||||
| new FractionDamageFormula([ | |||||
| { fraction: 0.25, target: Stat.Power, type: DamageType.Pure }, | |||||
| { fraction: 0.25, target: Stat.Toughness, type: DamageType.Pure }, | |||||
| { fraction: 0.25, target: Stat.Agility, type: DamageType.Pure }, | |||||
| { fraction: 0.25, target: Stat.Reflexes, type: DamageType.Pure }, | |||||
| { fraction: 0.25, target: Stat.Charm, type: DamageType.Pure }, | |||||
| { fraction: 0.25, target: Stat.Willpower, type: DamageType.Pure } | |||||
| ]) | |||||
| )] | |||||
| } | |||||
| )) | |||||
| this.addVoreContainer(stomach) | this.addVoreContainer(stomach) | ||||
| this.ai = null | this.ai = null | ||||