浏览代码

Add a basic perk system

The perks aren't visible yet. There's only one perk: Ravenous,
which makes the dire wolf even better at eating you.
vintage
Fen Dweller 5 年前
父节点
当前提交
ac646801db
共有 5 个文件被更改,包括 52 次插入3 次删除
  1. +15
    -0
      src/game/combat.ts
  2. +27
    -0
      src/game/combat/perks.ts
  3. +2
    -2
      src/game/combat/tests.ts
  4. +5
    -1
      src/game/creature.ts
  5. +3
    -0
      src/game/creatures/wolves.ts

+ 15
- 0
src/game/combat.ts 查看文件

@@ -3,6 +3,7 @@ import { TextLike, DynText, ToBe, LiveText, PairLineArgs, PairLine } from './lan
import { LogEntry, LogLines, FAElem, LogLine, FormatEntry, FormatOpt, PropElem, nilLog, Newline } from './interface' import { LogEntry, LogLines, FAElem, LogLine, FormatEntry, FormatOpt, PropElem, nilLog, Newline } from './interface'
import { Resistances } from './entity' import { Resistances } from './entity'
import { World } from './world' import { World } from './world'
import { TestCategory } from './combat/tests'


export enum DamageType { export enum DamageType {
Pierce = "Pierce", Pierce = "Pierce",
@@ -555,6 +556,20 @@ export class Effective {
scale (scale: number): number { scale (scale: number): number {
return scale return scale
} }

/**
* Additively modifies a creature's score for an offensive test
*/
modTestOffense (attacker: Creature, defender: Creature, kind: TestCategory): number {
return 0
}

/**
* Additively modifies a creature's score for a defensive test
*/
modTestDefense (defender: Creature, attacker: Creature, kind: TestCategory): number {
return 0
}
} }
/** /**
* A displayable status effect * A displayable status effect


+ 27
- 0
src/game/combat/perks.ts 查看文件

@@ -0,0 +1,27 @@
import { Effective } from '../combat'
import { TextLike } from '../language'
import { Creature } from '../creature'
import { TestCategory } from './tests'

export abstract class Perk extends Effective {
constructor (name: TextLike, desc: TextLike) {
super()
}
}

export class RavenousPerk extends Perk {
constructor () {
super(
"Ravenous",
"+10 to your score when eating someone if you have no prey in you."
)
}

modTestOffense (user: Creature, target: Creature, kind: TestCategory): number {
if (user.voreStats["Prey Count"] === 0 && kind === TestCategory.Vore) {
return 10
} else {
return 0
}
}
}

+ 2
- 2
src/game/combat/tests.ts 查看文件

@@ -60,8 +60,8 @@ export class OpposedStatTest extends RandomTest {
} }


odds (user: Creature, target: Creature): number { odds (user: Creature, target: Creature): number {
const userScore = this.getScore(user, this.userStats)
const targetScore = this.getScore(target, this.targetStats)
const userScore = this.getScore(user, this.userStats) + user.effects.reduce((total, effect) => total + effect.modTestOffense(user, target, this.category), 0)
const targetScore = this.getScore(target, this.targetStats) + target.effects.reduce((total, effect) => total + effect.modTestDefense(target, user, this.category), 0)


return this.f(userScore - targetScore + this.bias) return this.f(userScore - targetScore + this.bias)
} }


+ 5
- 1
src/game/creature.ts 查看文件

@@ -6,6 +6,7 @@ import { Item, EquipmentSlot, Equipment, ItemKind, Currency } from './items'
import { PassAction } from './combat/actions' import { PassAction } from './combat/actions'
import { AI } from './ai' import { AI } from './ai'
import { Mortal } from './entity' import { Mortal } from './entity'
import { Perk } from './combat/perks'


export class Creature extends Mortal { export class Creature extends Mortal {
containers: Array<VoreContainer> = [] containers: Array<VoreContainer> = []
@@ -22,11 +23,14 @@ export class Creature extends Mortal {
return (this.statusEffects as Effective[]).concat( return (this.statusEffects as Effective[]).concat(
Object.values(this.equipment).filter(item => item !== undefined).flatMap( Object.values(this.equipment).filter(item => item !== undefined).flatMap(
item => (item as Equipment).effects item => (item as Equipment).effects
)
),
this.perks
) )
} }


statusEffects: Array<StatusEffect> = []; statusEffects: Array<StatusEffect> = [];
perks: Array<Perk> = [];

groupActions: Array<GroupAction> = []; groupActions: Array<GroupAction> = [];
items: Array<Item> = []; items: Array<Item> = [];
/* eslint-disable-next-line */ /* eslint-disable-next-line */


+ 3
- 0
src/game/creatures/wolves.ts 查看文件

@@ -4,6 +4,7 @@ import { MalePronouns, ImproperNoun, FemalePronouns, TheyPronouns, Verb } from '
import { Stomach, Bowels, anyVore } from '../vore' import { Stomach, Bowels, anyVore } from '../vore'
import { AttackAction, TransferAction } from '../combat/actions' import { AttackAction, TransferAction } from '../combat/actions'
import { VoreAI } from '../ai' import { VoreAI } from '../ai'
import { RavenousPerk } from '../combat/perks'


export class Wolf extends Creature { export class Wolf extends Creature {
constructor () { constructor () {
@@ -54,6 +55,8 @@ export class DireWolf extends Creature {
this.side = Side.Monsters this.side = Side.Monsters
this.ai = new VoreAI() this.ai = new VoreAI()


this.perks.push(new RavenousPerk())

this.actions.push( this.actions.push(
new AttackAction( new AttackAction(
new StatDamageFormula([ new StatDamageFormula([


正在加载...
取消
保存