Also fixes a dumb bug where humans could make OTHER units surrendervintage
| @@ -466,6 +466,17 @@ export class Effective { | |||||
| modResistance (type: DamageType, factor: number): number { | modResistance (type: DamageType, factor: number): number { | ||||
| return factor | return factor | ||||
| } | } | ||||
| /** | |||||
| * Called when a test is about to resolve. Decides if the creature should automatically fail. | |||||
| */ | |||||
| failTest (creature: Creature, opponent: Creature): { failed: boolean; log: LogEntry } { | |||||
| return { | |||||
| failed: false, | |||||
| log: nilLog | |||||
| } | |||||
| } | |||||
| } | } | ||||
| /** | /** | ||||
| * A displayable status effect | * A displayable status effect | ||||
| @@ -1,4 +1,4 @@ | |||||
| import { StatusEffect, Damage, DamageType, Action, Condition } from '../combat' | |||||
| import { StatusEffect, Damage, DamageType, Action, Condition, Vigor } from '../combat' | |||||
| import { DynText, LiveText, ToBe, Verb } from '../language' | import { DynText, LiveText, ToBe, Verb } from '../language' | ||||
| import { Creature } from "../creature" | import { Creature } from "../creature" | ||||
| import { LogLine, LogEntry, LogLines, FAElem, nilLog } from '../interface' | import { LogLine, LogEntry, LogLines, FAElem, nilLog } from '../interface' | ||||
| @@ -138,18 +138,23 @@ export class DazzlingEffect extends StatusEffect { | |||||
| export class SurrenderEffect extends StatusEffect { | export class SurrenderEffect extends StatusEffect { | ||||
| constructor () { | constructor () { | ||||
| super('Surrendered', 'This creature has given up', 'fas fa-flag') | |||||
| super('Surrendered', 'This creature has given up, and will fail most tests', 'fas fa-flag') | |||||
| } | } | ||||
| onApply (creature: Creature): LogEntry { | onApply (creature: Creature): LogEntry { | ||||
| creature.takeDamage( | |||||
| new Damage( | |||||
| { amount: creature.vigors.Resolve, target: Vigor.Resolve, type: DamageType.Pure } | |||||
| ) | |||||
| ) | |||||
| return new LogLine( | return new LogLine( | ||||
| `${creature.name.capital} ${creature.name.conjugate(new Verb('surrender'))}!` | `${creature.name.capital} ${creature.name.conjugate(new Verb('surrender'))}!` | ||||
| ) | ) | ||||
| } | } | ||||
| preTurn (creature: Creature): { prevented: boolean; log: LogEntry } { | |||||
| failTest (creature: Creature, opponent: Creature): { failed: boolean; log: LogEntry } { | |||||
| return { | return { | ||||
| prevented: true, | |||||
| failed: true, | |||||
| log: nilLog | log: nilLog | ||||
| } | } | ||||
| } | } | ||||
| @@ -8,8 +8,19 @@ function logistic (x0: number, L: number, k: number): (x: number) => number { | |||||
| } | } | ||||
| } | } | ||||
| // TODO this will need to be able to return a LogEntry at some point | |||||
| abstract class RandomTest implements CombatTest { | abstract class RandomTest implements CombatTest { | ||||
| test (user: Creature, target: Creature): boolean { | test (user: Creature, target: Creature): boolean { | ||||
| const userFail = user.effects.map(effect => effect.failTest(user, target)) | |||||
| if (userFail.some(result => result.failed)) { | |||||
| return false | |||||
| } | |||||
| const targetFail = target.effects.map(effect => effect.failTest(target, user)) | |||||
| if (targetFail.some(result => result.failed)) { | |||||
| return true | |||||
| } | |||||
| return Math.random() < this.odds(user, target) | return Math.random() < this.odds(user, target) | ||||
| } | } | ||||
| @@ -4,6 +4,7 @@ import { Noun, Pronoun, ImproperNoun } from '../language' | |||||
| import { VoreType } from '../vore' | import { VoreType } from '../vore' | ||||
| import { StatusConsequence } from '../combat/consequences' | import { StatusConsequence } from '../combat/consequences' | ||||
| import { SurrenderEffect } from '../combat/effects' | import { SurrenderEffect } from '../combat/effects' | ||||
| import { SoloCondition } from '../combat/conditions' | |||||
| export class Human extends Creature { | export class Human extends Creature { | ||||
| constructor (name: Noun, pronouns: Pronoun, options: { | constructor (name: Noun, pronouns: Pronoun, options: { | ||||
| @@ -33,6 +34,9 @@ export class Human extends Creature { | |||||
| new StatusConsequence( | new StatusConsequence( | ||||
| () => new SurrenderEffect() | () => new SurrenderEffect() | ||||
| ) | ) | ||||
| ], | |||||
| conditions: [ | |||||
| new SoloCondition() | |||||
| ] | ] | ||||
| } | } | ||||
| )) | )) | ||||