Browse Source

Add a drain consequence and a prey targeter

master
Fen Dweller 5 years ago
parent
commit
37642859de
4 changed files with 62 additions and 5 deletions
  1. +2
    -1
      src/game/combat.ts
  2. +27
    -1
      src/game/combat/consequences.ts
  3. +11
    -0
      src/game/combat/targeters.ts
  4. +22
    -3
      src/game/creatures/characters/inazuma.ts

+ 2
- 1
src/game/combat.ts View File

@@ -4,6 +4,7 @@ import { LogEntry, LogLines, FAElem, LogLine, FormatEntry, FormatOpt, PropElem,
import { World } from '@/game/world'
import { TestCategory } from '@/game/combat/tests'
import { VoreContainer } from '@/game/vore'
import { SoloTargeter } from '@/game/combat/targeters'

export enum DamageType {
Pierce = "Pierce",
@@ -464,7 +465,7 @@ export class CompositionAction extends Action {
super(name, desc, properties.conditions ?? [], properties.tests ?? [])
this.consequences = properties.consequences ?? []
this.groupConsequences = properties.groupConsequences ?? []
this.targeters = properties.targeters ?? []
this.targeters = properties.targeters ?? [new SoloTargeter()]
}

execute (user: Creature, target: Creature): LogEntry {


+ 27
- 1
src/game/combat/consequences.ts View File

@@ -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 { LogEntry, LogLines, LogLine, nilLog } from '@/game/interface'
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
*/


+ 11
- 0
src/game/combat/targeters.ts View File

@@ -1,5 +1,6 @@
import { Encounter, Targeter } from '../combat'
import { Creature } from '../creature'
import { Container } from '../vore'

export class SoloTargeter implements Targeter {
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)
}
}

export class PreyTargeter implements Targeter {
constructor (private container: Container) {

}

targets (primary: Creature, encounter: Encounter): Array<Creature> {
return this.container.contents
}
}

+ 22
- 3
src/game/creatures/characters/inazuma.ts View File

@@ -1,9 +1,9 @@
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 { ConsumeConsequence } from '@/game/combat/consequences'
import { ConsumeConsequence, DamageConsequence, DrainConsequence, StatusConsequence } from '@/game/combat/consequences'
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 { LogLine } from '@/game/interface'
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.ai = null


Loading…
Cancel
Save