Переглянути джерело

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 { Resistances } from './entity'
import { World } from './world'
import { TestCategory } from './combat/tests'

export enum DamageType {
Pierce = "Pierce",
@@ -555,6 +556,20 @@ export class Effective {
scale (scale: number): number {
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


+ 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 {
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)
}


+ 5
- 1
src/game/creature.ts Переглянути файл

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

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

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

groupActions: Array<GroupAction> = [];
items: Array<Item> = [];
/* 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 { AttackAction, TransferAction } from '../combat/actions'
import { VoreAI } from '../ai'
import { RavenousPerk } from '../combat/perks'

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

this.perks.push(new RavenousPerk())

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


Завантаження…
Відмінити
Зберегти