소스 검색

Add a damage calculator that does a percentage of the target's stats/vigors

vintage
Fen Dweller 5 년 전
부모
커밋
0ab5b201c1
2개의 변경된 파일78개의 추가작업 그리고 7개의 파일을 삭제
  1. +52
    -1
      src/game/combat.ts
  2. +26
    -6
      src/game/creatures/shingo.ts

+ 52
- 1
src/game/combat.ts 파일 보기

@@ -9,7 +9,8 @@ export enum DamageType {
Acid = "Acid",
Seduction = "Seduction",
Dominance = "Dominance",
Heal = "Heal"
Heal = "Heal",
Pure = "Pure"
}

export interface DamageInstance {
@@ -258,6 +259,56 @@ export class StatDamageFormula implements DamageFormula {
}
}

/**
* Deals a percentage of the target's current vigors/stats
*/
export class FractionDamageFormula implements DamageFormula {
constructor (private factors: Array<{ fraction: number; target: Vigor|Stat; type: DamageType }>) {

}

calc (user: Creature, target: Creature): Damage {
const instances: Array<DamageInstance> = this.factors.map(factor => {
if (factor.target in Stat) {
return {
amount: Math.max(0, factor.fraction * target.stats[factor.target as Stat]),
target: factor.target,
type: factor.type
}
} else if (factor.target in Vigor) {
return {
amount: Math.max(factor.fraction * user.vigors[factor.target as Vigor]),
target: factor.target,
type: factor.type
}
} else {
// should be impossible; .target is Stat|Vigor
return {
amount: 0,
target: Vigor.Health,
type: DamageType.Heal
}
}
})

return new Damage(...instances)
}

describe (user: Creature, target: Creature): LogEntry {
return this.explain(user)
}

explain (user: Creature): LogEntry {
return new LogLine(
`Deal damage equal to `,
...this.factors.map(factor => new LogLine(
`${factor.fraction * 100}% of your target's `,
new PropElem(factor.target)
)).joinGeneral(new LogLine(`, `), new LogLine(` and `))
)
}
}

export enum Side {
Heroes,
Monsters


+ 26
- 6
src/game/creatures/shingo.ts 파일 보기

@@ -1,21 +1,21 @@
import { Creature } from "../creature"
import { Damage, DamageType, ConstantDamageFormula, Vigor, Side, StatDamageFormula, Stat, Action, DamageFormula } from '../combat'
import { Damage, DamageType, ConstantDamageFormula, Vigor, Side, StatDamageFormula, Stat, Action, DamageFormula, Condition, FractionDamageFormula } from '../combat'
import { ImproperNoun, ProperNoun, FemalePronouns, MalePronouns, Verb, PairLineArgs, PairLine, TextLike } from '../language'
import { VoreType, Stomach, Bowels, NormalContainer, InnerContainer, VoreContainer, Container, Vore } from '../vore'
import { AttackAction, TransferAction, FeedAction, StruggleAction, DamageAction } from '../combat/actions'
import { LogLine, LogEntry, LogLines } from '../interface'
import { ContainsCondition, CapableCondition, EnemyCondition } from '../combat/conditions'
import { ContainsCondition, CapableCondition, EnemyCondition, TargetDrainedVigorCondition } from '../combat/conditions'
import { StatTest } from '../combat/tests'

export class TrappedAction extends DamageAction {
protected test: StatTest

constructor (name: TextLike, desc: TextLike, protected verb: Verb, protected damage: DamageFormula, container: Container) {
constructor (name: TextLike, desc: TextLike, protected verb: Verb, protected damage: DamageFormula, container: Container, conditions: Condition[] = []) {
super(
name,
desc,
damage,
[new CapableCondition(), new ContainsCondition(container), new EnemyCondition()]
[new CapableCondition(), new ContainsCondition(container), new EnemyCondition()].concat(conditions)
)
this.test = new StatTest(Stat.Power)
}
@@ -77,13 +77,33 @@ class Paw extends NormalContainer {
),
new ConstantDamageFormula(
new Damage(
{ amount: 10, target: Stat.Toughness, type: DamageType.Crush },
{ amount: 10, target: Stat.Power, type: DamageType.Crush },
{ amount: 100, target: Vigor.Stamina, type: DamageType.Crush },
{ amount: 3, target: Stat.Toughness, type: DamageType.Crush },
{ amount: 5, target: Stat.Power, type: DamageType.Crush },
{ amount: 10, target: Stat.Speed, type: DamageType.Crush }
)
),
this
))
this.actions.push(new TrappedAction(
"Crush",
"Finish them off",
new Verb(
'crush',
'crushes'
),
new FractionDamageFormula(
[
{ fraction: 1, target: Stat.Toughness, type: DamageType.Pure },
{ fraction: 1, target: Stat.Power, type: DamageType.Pure },
{ fraction: 1, target: Stat.Speed, type: DamageType.Pure },
{ fraction: 1, target: Stat.Willpower, type: DamageType.Pure },
{ fraction: 1, target: Stat.Charm, type: DamageType.Pure }
]
),
this,
[new TargetDrainedVigorCondition(Vigor.Stamina)]
))
}

consumeLine: PairLineArgs<Vore, { container: Container }> = (user, target, args) => {


불러오는 중...
취소
저장