ソースを参照

Allow stats to be damaged

master
Fen Dweller 5年前
コミット
ab797188cc
3個のファイルの変更36行の追加11行の削除
  1. +19
    -6
      src/game/combat.ts
  2. +6
    -2
      src/game/creatures/cafat.ts
  3. +11
    -3
      src/game/entity.ts

+ 19
- 6
src/game/combat.ts ファイルの表示

@@ -16,7 +16,7 @@ export enum DamageType {
export interface DamageInstance {
type: DamageType;
amount: number;
target: Vigor;
target: Vigor | Stat;
}

export enum Vigor {
@@ -127,18 +127,31 @@ export class Damage {

render (): LogEntry {
return new LogLine(...this.damages.flatMap(instance => {
return [instance.amount.toString(), new FAElem(VigorIcons[instance.target]), " " + instance.type]
if (instance.target in Vigor) {
return [instance.amount.toString(), new FAElem(VigorIcons[instance.target as Vigor]), " " + instance.type]
} else if (instance.target in Stat) {
return [instance.amount.toString(), new FAElem(StatIcons[instance.target as Stat]), " " + instance.type]
} else {
// this should never happen!
return []
}
}))
}

renderShort (): LogEntry {
const totals: Vigors = Object.keys(Vigor).reduce((total: any, key) => { total[key] = 0; return total }, {})

const vigorTotals: Vigors = Object.keys(Vigor).reduce((total: any, key) => { total[key] = 0; return total }, {})
const statTotals: Stats = Object.keys(Stat).reduce((total: any, key) => { total[key] = 0; return total }, {})
this.damages.forEach(instance => {
totals[instance.target] += instance.amount
if (instance.target in Vigor) {
vigorTotals[instance.target as Vigor] += instance.amount
} else if (instance.target in Stat) {
statTotals[instance.target as Stat] += instance.amount
}
})

return new FormatEntry(new LogLine(...Object.keys(Vigor).flatMap(key => totals[key as Vigor] === 0 ? [] : [new PropElem(key as Vigor, totals[key as Vigor]), ' '])), FormatOpt.DamageInst)
const vigorEntries = Object.keys(Vigor).flatMap(key => vigorTotals[key as Vigor] === 0 ? [] : [new PropElem(key as Vigor, vigorTotals[key as Vigor]), ' '])
const statEntries = Object.keys(Stat).flatMap(key => statTotals[key as Stat] === 0 ? [] : [new PropElem(key as Stat, statTotals[key as Stat]), ' '])
return new FormatEntry(new LogLine(...vigorEntries.concat(statEntries)), FormatOpt.DamageInst)
}
}



+ 6
- 2
src/game/creatures/cafat.ts ファイルの表示

@@ -55,7 +55,7 @@ class BelchAction extends AttackAction {
constructor (damage: Damage) {
super(new ConstantDamageFormula(damage))
this.name = 'Belch'
this.desc = 'Drain your foe\'s willpower with a solid BELCH'
this.desc = 'Drain your foe\'s stats with a solid BELCH'
}
}

@@ -138,7 +138,11 @@ export class Cafat extends Creature {
this.actions.push(new AttackAction(new ConstantDamageFormula(new Damage({ amount: 40, type: DamageType.Crush, target: Vigor.Health }))))
this.actions.push(new BellyCrushAction(new Damage({ amount: 10, type: DamageType.Crush, target: Vigor.Health }, { amount: 10, type: DamageType.Dominance, target: Vigor.Resolve })))
this.actions.push(new BelchAction(new Damage(
{ amount: 100, target: Vigor.Resolve, type: DamageType.Acid }
{ amount: 10, target: Stat.Toughness, type: DamageType.Acid },
{ amount: 10, target: Stat.Power, type: DamageType.Acid },
{ amount: 10, target: Stat.Speed, type: DamageType.Acid },
{ amount: 10, target: Stat.Willpower, type: DamageType.Acid },
{ amount: 10, target: Stat.Charm, type: DamageType.Acid }
)))
this.otherActions.push(new FeedAction(stomach))
}


+ 11
- 3
src/game/entity.ts ファイルの表示

@@ -1,4 +1,4 @@
import { DamageType, Damage, Combatant, Stats, Action, Vigor, VoreStats, VoreStat } from './combat'
import { DamageType, Damage, Combatant, Stats, Action, Vigor, VoreStats, VoreStat, Stat } from './combat'
import { Noun, Pronoun } from './language'
import { LogEntry, LogLine } from './interface'
import { Vore, Container, VoreType } from './vore'
@@ -105,9 +105,17 @@ export class Creature extends Vore implements Combatant {
damage.damages.forEach(instance => {
const resistance: number|undefined = this.resistances.get(instance.type)
if (resistance !== undefined) {
this.vigors[instance.target] -= instance.amount * resistance
if (instance.target in Vigor) {
this.vigors[instance.target as Vigor] -= instance.amount * resistance
} else if (instance.target in Stat) {
this.stats[instance.target as Stat] -= instance.amount * resistance
}
} else {
this.vigors[instance.target] -= instance.amount
if (instance.target in Vigor) {
this.vigors[instance.target as Vigor] -= instance.amount
} else if (instance.target in Stat) {
this.stats[instance.target as Stat] -= instance.amount
}
}
})



読み込み中…
キャンセル
保存