diff --git a/src/game/ai.ts b/src/game/ai.ts index 88dde55..5d894d4 100644 --- a/src/game/ai.ts +++ b/src/game/ai.ts @@ -1,10 +1,8 @@ import { Creature } from './creature' -import { Encounter, Action, Damage, StatusEffect } from './combat' -import { LogEntry, nilLog } from './interface' -import { ReleaseAction, TransferAction, PassAction } from './combat/actions' -import { NoPassDecider, NoReleaseDecider, ChanceDecider, ConsequenceDecider, ConsequenceFunctionDecider, NoSurrenderDecider } from './ai/deciders' -import { SurrenderEffect } from './combat/effects' -import { StatusConsequence, DamageConsequence } from './combat/consequences' +import { Encounter, Action } from './combat' +import { LogEntry } from './interface' +import { PassAction } from './combat/actions' +import { NoPassDecider, NoReleaseDecider, ChanceDecider, NoSurrenderDecider } from './ai/deciders' /** * A Decider determines how favorable an action is to perform. @@ -14,7 +12,7 @@ export interface Decider { } export class AI { - constructor (public name: string, private deciders: Decider[]) { + constructor (private deciders: Decider[]) { } @@ -25,8 +23,6 @@ export class AI { weight: 1 }))) - console.log(options) - this.deciders.forEach( decider => options.forEach( option => { option.weight *= decider.decide(encounter, actor, option.target, option.action) } @@ -39,7 +35,6 @@ export class AI { ) total *= Math.random() - console.log(total) const chosen = options.find( option => { @@ -56,9 +51,9 @@ export class AI { return chosen.action.try(actor, chosen.target) } - // should never reach this point! + // if we filtered out EVERY action, we should just give up and pass - throw new Error("Couldn't pick an action") + return new PassAction().try(actor, actor) } } @@ -68,11 +63,11 @@ export class AI { export class VoreAI extends AI { constructor () { super( - "Vore AI", [ new NoReleaseDecider(), - new ChanceDecider(), - new NoSurrenderDecider() + new NoSurrenderDecider(), + new NoPassDecider(), + new ChanceDecider() ] ) } diff --git a/src/game/combat/tests.ts b/src/game/combat/tests.ts index 630eb86..d555b6c 100644 --- a/src/game/combat/tests.ts +++ b/src/game/combat/tests.ts @@ -62,7 +62,6 @@ export class OpposedStatTest extends RandomTest { odds (user: Creature, target: Creature): number { const userScore = this.getScore(user, this.userStats) const targetScore = this.getScore(target, this.targetStats) - console.log(userScore, targetScore) return this.f(userScore - targetScore + this.bias) } @@ -107,7 +106,6 @@ export class OpposedStatTest extends RandomTest { const vigor = StatToVigor[stat as Stat] value = value * (1 - this.maxStatVigorPenalty) + value * this.maxStatVigorPenalty * actor.vigors[vigor] / actor.maxVigors[vigor] - console.log(value) return total + value }, 0) diff --git a/src/game/creatures/werewolf.ts b/src/game/creatures/werewolf.ts index 465cb2f..9a37561 100644 --- a/src/game/creatures/werewolf.ts +++ b/src/game/creatures/werewolf.ts @@ -30,18 +30,33 @@ export class Werewolf extends Creature { this.side = Side.Monsters - const stomach = new Stomach(this, 2, new ConstantDamageFormula(new Damage( - { amount: 60, type: DamageType.Acid, target: Vigor.Health }, - { amount: 30, type: DamageType.Crush, target: Vigor.Stamina }, - { amount: 30, type: DamageType.Dominance, target: Vigor.Resolve } - ))) + const stomach = new Stomach( + this, + 1, + new StatDamageFormula([ + { fraction: 1, stat: Stat.Toughness, target: Vigor.Health, type: DamageType.Acid }, + { fraction: 1, stat: Stat.Power, target: Vigor.Health, type: DamageType.Crush }, + { fraction: 0.5, stat: Stat.Toughness, target: Vigor.Stamina, type: DamageType.Acid }, + { fraction: 0.5, stat: Stat.Power, target: Vigor.Stamina, type: DamageType.Crush }, + { fraction: 0.5, stat: Stat.Toughness, target: Vigor.Resolve, type: DamageType.Acid }, + { fraction: 0.5, stat: Stat.Power, target: Vigor.Resolve, type: DamageType.Crush } + ]) + ) + this.containers.push(stomach) - const bowels = new Bowels(this, 2, new ConstantDamageFormula(new Damage( - { amount: 30, type: DamageType.Crush, target: Vigor.Health }, - { amount: 60, type: DamageType.Crush, target: Vigor.Stamina }, - { amount: 60, type: DamageType.Dominance, target: Vigor.Resolve } - ))) + const bowels = new Bowels( + this, + 1.5, + new StatDamageFormula([ + { fraction: 0.5, stat: Stat.Toughness, target: Vigor.Health, type: DamageType.Acid }, + { fraction: 0.5, stat: Stat.Power, target: Vigor.Health, type: DamageType.Crush }, + { fraction: 1, stat: Stat.Toughness, target: Vigor.Stamina, type: DamageType.Acid }, + { fraction: 1, stat: Stat.Power, target: Vigor.Stamina, type: DamageType.Crush }, + { fraction: 1, stat: Stat.Toughness, target: Vigor.Resolve, type: DamageType.Acid }, + { fraction: 1, stat: Stat.Power, target: Vigor.Resolve, type: DamageType.Crush } + ]) + ) this.containers.push(bowels) @@ -49,17 +64,32 @@ export class Werewolf extends Creature { this.otherActions.push(new FeedAction(stomach)) - const cock = new Cock(this, 2, new ConstantDamageFormula(new Damage( - { amount: 30, type: DamageType.Crush, target: Vigor.Health }, - { amount: 60, type: DamageType.Crush, target: Vigor.Stamina }, - { amount: 60, type: DamageType.Dominance, target: Vigor.Resolve } - ))) + const cock = new Cock( + this, + 1.5, + new StatDamageFormula([ + { fraction: 1, stat: Stat.Charm, target: Vigor.Health, type: DamageType.Acid }, + { fraction: 1, stat: Stat.Power, target: Vigor.Health, type: DamageType.Crush }, + { fraction: 0.5, stat: Stat.Charm, target: Vigor.Stamina, type: DamageType.Acid }, + { fraction: 0.5, stat: Stat.Power, target: Vigor.Stamina, type: DamageType.Crush }, + { fraction: 1, stat: Stat.Charm, target: Vigor.Resolve, type: DamageType.Acid }, + { fraction: 1, stat: Stat.Power, target: Vigor.Resolve, type: DamageType.Crush } + ]) + ) - const balls = new Balls(this, 2, new ConstantDamageFormula(new Damage( - { amount: 30, type: DamageType.Crush, target: Vigor.Health }, - { amount: 60, type: DamageType.Crush, target: Vigor.Stamina }, - { amount: 60, type: DamageType.Dominance, target: Vigor.Resolve } - )), cock) + const balls = new Balls( + this, + 1.5, + new StatDamageFormula([ + { fraction: 1, stat: Stat.Toughness, target: Vigor.Health, type: DamageType.Acid }, + { fraction: 1, stat: Stat.Power, target: Vigor.Health, type: DamageType.Crush }, + { fraction: 1, stat: Stat.Toughness, target: Vigor.Stamina, type: DamageType.Acid }, + { fraction: 1, stat: Stat.Power, target: Vigor.Stamina, type: DamageType.Crush }, + { fraction: 1.5, stat: Stat.Toughness, target: Vigor.Resolve, type: DamageType.Acid }, + { fraction: 1.5, stat: Stat.Power, target: Vigor.Resolve, type: DamageType.Crush } + ]), + cock + ) this.containers.push(balls) this.containers.push(cock)