|
- import { StatusEffect, Damage, DamageType, Action, Condition } from '../combat'
- import { DynText, LiveText, ToBe, Verb } from '../language'
- import { Creature } from "../creature"
- import { LogLine, LogEntry, LogLines, FAElem, nilLog } from '../interface'
-
- export class InstantKillEffect extends StatusEffect {
- constructor () {
- super('Instant Kill', 'Instant kill!', 'fas fa-skull')
- }
-
- onApply (creature: Creature) {
- creature.vigors.Health = 0
- creature.removeEffect(this)
- return new LogLines(
- new LogLine(
- `${creature.name.capital} ${creature.name.conjugate(new ToBe())} killed instantly! `,
- new FAElem('fas fa-skull')
- ),
- creature.takeDamage(new Damage())
- )
- }
- }
- export class StunEffect extends StatusEffect {
- constructor (private duration: number) {
- super('Stun', 'Cannot act!', 'fas fa-sun')
- this.desc = new DynText('Stunned for your next ', new LiveText(this, x => x.duration), ' actions!')
- }
-
- get topLeft () {
- return this.duration.toString()
- }
-
- onApply (creature: Creature) {
- return new LogLine(`${creature.name.capital} ${creature.name.conjugate(new ToBe())} is stunned!`)
- }
-
- onRemove (creature: Creature) {
- return new LogLine(`${creature.name.capital} ${creature.name.conjugate(new ToBe())} no longer stunned.`)
- }
-
- preTurn (creature: Creature): { prevented: boolean; log: LogEntry } {
- if (--this.duration <= 0) {
- return {
- prevented: true,
- log: new LogLines(
- `${creature.name.capital} ${creature.name.conjugate(new ToBe())} stunned! ${creature.pronouns.capital.subjective} can't move.`,
- creature.removeEffect(this)
- )
- }
- } else {
- return {
- prevented: true,
- log: new LogLines(
- `${creature.name.capital} ${creature.name.conjugate(new ToBe())} stunned! ${creature.pronouns.capital.subjective} can't move!`
- )
- }
- }
- }
- }
-
- export class ShieldEffect extends StatusEffect {
- constructor (private damageTypes: DamageType[], private amount: number) {
- super('Shield', 'Block a fraction of incoming damage', 'fas fa-shield-alt')
- }
-
- onApply (creature: Creature) {
- return new LogLine(`${creature.name.capital} ${creature.name.conjugate(new Verb('gain'))} a shield!`)
- }
-
- onRemove (creature: Creature) {
- return new LogLine(`${creature.name.capital} ${creature.name.conjugate(new Verb('lose'))} ${creature.pronouns.possessive} shield!`)
- }
-
- preDamage (creature: Creature, damage: Damage) {
- return damage.scale(this.amount)
- }
- }
-
- export class PredatorCounterEffect extends StatusEffect {
- constructor (private devour: Action, private chance: number) {
- super('Predatory Counter', 'Eat them back', 'fas fa-redo')
- this.desc = new DynText(new LiveText(this, x => (x.chance * 100).toFixed(0)), '% chance to devour your attackers')
- }
-
- preAttack (creature: Creature, attacker: Creature) {
- if (this.devour.allowed(creature, attacker) && Math.random() < this.chance) {
- return {
- prevented: true,
- log: new LogLines(
- `${creature.name.capital} ${creature.name.conjugate(new Verb('surprise'))} ${attacker.name.objective} and ${creature.name.conjugate(new Verb('try', 'tries'))} to devour ${attacker.pronouns.objective}!`,
- this.devour.execute(creature, attacker)
- )
- }
- } else {
- return { prevented: false, log: nilLog }
- }
- }
- }
-
- export class UntouchableEffect extends StatusEffect {
- constructor () {
- super('Untouchable', 'Cannot be attacked', 'fas fa-times')
- }
-
- preAttack (creature: Creature, attacker: Creature) {
- return {
- prevented: true,
- log: new LogLine(`${creature.name.capital} cannot be attacked.`)
- }
- }
- }
-
- export class DazzlingEffect extends StatusEffect {
- constructor (private conditions: Condition[]) {
- super('Dazzling', 'Stuns enemies who try to affect this creature', 'fas fa-spinner')
- }
-
- preReceiveAction (creature: Creature, attacker: Creature) {
- if (this.conditions.every(cond => cond.allowed(creature, attacker))) {
- attacker.applyEffect(new StunEffect(1))
- return {
- prevented: true,
- log: new LogLine(`${attacker.name.capital} can't act against ${creature.name.objective}!`)
- }
- } else {
- return {
- prevented: false,
- log: nilLog
- }
- }
- }
- }
|