Quellcode durchsuchen

Move most of the actions over to the new line style

master
Fen Dweller vor 5 Jahren
Ursprung
Commit
7ec0dc8ec1
6 geänderte Dateien mit 61 neuen und 73 gelöschten Zeilen
  1. +3
    -5
      src/game/combat.ts
  2. +40
    -54
      src/game/combat/actions.ts
  3. +3
    -6
      src/game/creatures/cafat.ts
  4. +8
    -3
      src/game/creatures/withers.ts
  5. +2
    -0
      src/game/entity.ts
  6. +5
    -5
      src/game/vore.ts

+ 3
- 5
src/game/combat.ts Datei anzeigen

@@ -1,8 +1,6 @@
import { Creature, POV, Entity } from './entity'
import { POVPair, POVPairArgs, TextLike, DynText, LiveText } from './language'
import { VoreContainer } from './vore'
import { LogEntry, LogLines, CompositeLog, FAElem, LogLine, FormatEntry, FormatOpt, PropElem } from './interface'
import { StatTest, StatVigorTest } from './combat/tests'
import { Creature } from './entity'
import { TextLike } from './language'
import { LogEntry, LogLines, FAElem, LogLine, FormatEntry, FormatOpt, PropElem } from './interface'

export enum DamageType {
Pierce = "Pierce",


+ 40
- 54
src/game/combat/actions.ts Datei anzeigen

@@ -1,5 +1,5 @@
import { StatTest, StatVigorTest } from './tests'
import { POVPairArgs, POVPair, DynText, LiveText, TextLike, Verb } from '../language'
import { POVPairArgs, POVPair, DynText, LiveText, TextLike, Verb, PairLine, PairLineArgs } from '../language'
import { Entity, POV, Creature } from '../entity'
import { Damage, DamageFormula, Stat, Vigor, Action } from '../combat'
import { LogLine, LogLines, LogEntry, CompositeLog } from '../interface'
@@ -9,26 +9,14 @@ import { CapableCondition, UserDrainedVigorCondition, TogetherCondition, EnemyCo
export class AttackAction extends Action {
protected test: StatTest

protected successLines: POVPairArgs<Entity, Entity, { damage: Damage }> = new POVPairArgs([
[[POV.Second, POV.Third], (user, target, args) => new LogLine(
`You ${this.verb} ${target.name} for `,
args.damage.renderShort()
)],
[[POV.Third, POV.Second], (user, target, args) => new LogLine(
`${user.name.capital} ${this.verb.singular} you for `,
args.damage.renderShort()
)],
[[POV.Third, POV.Third], (user, target, args) => new LogLine(
`${user.name.capital} ${this.verb.singular} ${target.name} for `,
args.damage.renderShort()
)]
])

protected failLines: POVPair<Entity, Entity> = new POVPair([
[[POV.Second, POV.Third], (user, target) => new LogLine(`You try to ${this.verb.present} ${target.name}, but you miss`)],
[[POV.Third, POV.Second], (user, target) => new LogLine(`${user.name.capital} misses you`)],
[[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} misses ${target.name}`)]
])
protected successLine: PairLineArgs<Creature, { damage: Damage }> = (user, target, args) => new LogLine(
`${user.name.capital} ${user.name.conjugate(this.verb)} ${target.name.objective} for `,
args.damage.renderShort()
)

protected failLine: PairLine<Creature> = (user, target) => new LogLine(
`${user.name.capital} ${user.name.conjugate(new Verb('miss', 'misses'))} ${target.name.objective}`
)

constructor (protected damage: DamageFormula, protected verb: Verb = new Verb('smack')) {
super(
@@ -43,10 +31,10 @@ export class AttackAction extends Action {
if (this.test.test(user, target)) {
const damage = this.damage.calc(user, target)
const targetResult = target.takeDamage(damage)
const ownResult = this.successLines.run(user, target, { damage: damage })
const ownResult = this.successLine(user, target, { damage: damage })
return new CompositeLog(ownResult, targetResult)
} else {
return this.failLines.run(user, target)
return this.failLine(user, target)
}
}

@@ -58,11 +46,9 @@ export class AttackAction extends Action {
export class DevourAction extends Action {
private test: StatVigorTest

protected failLines: POVPairArgs<Entity, Entity, { container: Container }> = new POVPairArgs([
[[POV.Second, POV.Third], (user, target, args) => new LogLine(`You fail to ${args.container.consumeVerb} ${target.name}`)],
[[POV.Third, POV.Second], (user, target, args) => new LogLine(`${user.name.capital} tries to ${args.container.consumeVerb} you, but fails`)],
[[POV.Third, POV.Third], (user, target, args) => new LogLine(`${user.name.capital} unsuccessfully tries to ${args.container.consumeVerb} ${target.name}`)]
])
protected failLine: PairLineArgs<Entity, { container: Container }> = (user, target, args) => new LogLine(
`${user.name.capital} ${user.name.conjugate(new Verb('fail'))} to ${args.container.consumeVerb} ${target.name.objective}.`
)

allowed (user: Creature, target: Creature): boolean {
const owner = this.container.owner === user
@@ -89,7 +75,7 @@ export class DevourAction extends Action {
if (this.test.test(user, target)) {
return this.container.consume(target)
} else {
return this.failLines.run(user, target, { container: this.container })
return this.failLine(user, target, { container: this.container })
}
}

@@ -101,16 +87,18 @@ export class DevourAction extends Action {
export class FeedAction extends Action {
private test: StatTest

protected failLines: POVPair<Entity, Entity> = new POVPair([
[[POV.Second, POV.Third], (user, target) => new LogLine(`You fail to feed yourself to ${target.name}`)],
[[POV.Third, POV.Second], (user, target) => new LogLine(`${user.name.capital} tries to feed ${user.pronouns.possessive} to you, but fails`)],
[[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} unsuccessfully tries to feed ${user.pronouns.possessive} to ${target.name}`)]
])
protected successLine: PairLine<Entity> = (user, target) => new LogLine(
`${user.name.capital} ${user.name.conjugate(new Verb('feed'))} ${user.pronouns.reflexive} to ${target.name}. `
)

protected failLine: PairLine<Entity> = (user, target) => new LogLine(
`${user.name.capital} ${user.name.conjugate(new Verb('fail'))} to feed ${user.pronouns.reflexive} to ${target.name}. `
)

allowed (user: Creature, target: Creature): boolean {
const owner = this.container.owner === target
const predOk = Array.from(this.container.voreTypes).every(pref => user.predPrefs.has(pref))
const preyOk = Array.from(this.container.voreTypes).every(pref => target.preyPrefs.has(pref))
const predOk = Array.from(this.container.voreTypes).every(pref => user.preyPrefs.has(pref))
const preyOk = Array.from(this.container.voreTypes).every(pref => target.predPrefs.has(pref))

if (owner && predOk && preyOk) {
return super.allowed(user, target)
@@ -130,7 +118,7 @@ export class FeedAction extends Action {
}

execute (user: Creature, target: Creature): LogEntry {
return this.container.consume(user)
return new LogLines(this.successLine(user, target), this.container.consume(user))
}

describe (user: Creature, target: Creature): LogEntry {
@@ -141,11 +129,13 @@ export class FeedAction extends Action {
export class StruggleAction extends Action {
private test: StatVigorTest

protected failLines: POVPair<Entity, Entity> = new POVPair([
[[POV.Second, POV.Third], (user, target) => new LogLine(`You fail to escape from ${target.name}`)],
[[POV.Third, POV.Second], (user, target) => new LogLine(`${user.name.capital} tries to escape from you, but fails`)],
[[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} unsuccessfully struggles against ${target.name}`)]
])
protected successLine: PairLineArgs<Entity, { container: Container }> = (prey, pred, args) => new LogLine(
`${prey.name.capital} ${prey.name.conjugate(new Verb('escape'))} from ${pred.name.possessive} ${args.container.name}.`
)

protected failLine: PairLineArgs<Entity, { container: Container }> = (prey, pred, args) => new LogLine(
`${prey.name.capital} ${prey.name.conjugate(new Verb('fail'))} to escape from ${pred.name.possessive} ${args.container.name}.`
)

constructor (public container: Container) {
super(
@@ -159,9 +149,9 @@ export class StruggleAction extends Action {
execute (user: Creature, target: Creature): LogEntry {
if (user.containedIn !== null) {
if (this.test.test(user, target)) {
return user.containedIn.release(user)
return new LogLines(this.successLine(user, target, { container: this.container }), user.containedIn.release(user))
} else {
return this.failLines.run(user, target)
return this.failLine(user, target, { container: this.container })
}
} else {
return new LogLine("Vore's bugged!")
@@ -174,8 +164,6 @@ export class StruggleAction extends Action {
}

export abstract class EatenAction extends Action {
protected lines: POVPair<Entity, Entity> = new POVPair([])

allowed (user: Creature, target: Creature) {
if (target.containedIn === this.container) {
return super.allowed(user, target)
@@ -194,8 +182,6 @@ export abstract class EatenAction extends Action {
}

export class DigestAction extends Action {
protected lines: POVPair<Entity, Entity> = new POVPair([])

allowed (user: Creature, target: Creature) {
if (this.container.owner === user && this.container.contents.length > 0) {
return super.allowed(user, target)
@@ -249,11 +235,11 @@ export class ReleaseAction extends Action {
}

export class TransferAction extends Action {
lines: POVPairArgs<Entity, Entity, { from: Container; to: Container }> = new POVPairArgs([
[[POV.Second, POV.Third], (user, target, args) => new LogLine(`You squeeze ${target.name} from your ${args.from.name} to your ${args.to.name}`)],
[[POV.Third, POV.Second], (user, target, args) => new LogLine(`You're squeezed from ${user.name}'s ${args.from.name} to ${user.pronouns.possessive} ${args.to.name}`)],
[[POV.Third, POV.Third], (user, target, args) => new LogLine(`${user.name} sends ${target.name} from ${user.pronouns.possessive} ${args.from.name.all} to ${user.pronouns.possessive} ${args.to.name.all}`)]
])
verb: Verb = new Verb('send')
line: PairLineArgs<Creature, { from: Container; to: Container }> = (user, target, args) => new LogLine(
`${user.name.capital} ${user.name.conjugate(this.verb)} ${target.name.objective} from ${user.pronouns.possessive} ${args.from.name} to ${user.pronouns.possessive} ${args.to.name}`
)

allowed (user: Creature, target: Creature) {
if (target.containedIn === this.from && this.from.contents.includes(target)) {
@@ -274,7 +260,7 @@ export class TransferAction extends Action {
execute (user: Creature, target: Creature): LogEntry {
this.from.release(target)
this.to.consume(target)
return this.lines.run(user, target, { from: this.from, to: this.to })
return this.line(user, target, { from: this.from, to: this.to })
}

describe (user: Creature, target: Creature): LogEntry {


+ 3
- 6
src/game/creatures/cafat.ts Datei anzeigen

@@ -1,6 +1,6 @@
import { Creature, POV, Entity } from '../entity'
import { Stat, Damage, DamageType, Vigor, ConstantDamageFormula } from '../combat'
import { ProperNoun, TheyPronouns, ImproperNoun, POVPair, FemalePronouns, POVPairArgs } from '../language'
import { ProperNoun, TheyPronouns, ImproperNoun, POVPair, FemalePronouns, POVPairArgs, Verb } from '../language'
import { VoreType, Stomach, InnerStomach, VoreContainer, NormalContainer, Vore } from '../vore'
import { LogLine, LogLines, LogEntry, FAElem, CompositeLog, ImgElem } from '../interface'
import { AttackAction, EatenAction, TransferAction, FeedAction } from '../combat/actions'
@@ -116,11 +116,8 @@ export class Cafat extends Creature {

const transfer = new TransferAction(stomach, lowerStomach)

transfer.lines = new POVPairArgs([
[[POV.Second, POV.Third], (user, target, args) => new LogLine(`You squeeze ${target.name} from your ${args.from.name} to your ${args.to.name}`)],
[[POV.Third, POV.Second], (user, target, args) => new CompositeLog(new LogLine(`You're squeezed from ${user.name}'s ${args.from.name} to ${user.pronouns.possessive} ${args.to.name}`), new ImgElem('./media/cafat/images/lower-stomach.webp'))],
[[POV.Third, POV.Third], (user, target, args) => new LogLine(`${user.name} squeezes ${target.name} from ${user.pronouns.possessive} ${args.from.name} to ${user.pronouns.possessive} ${args.to.name}`)]
])
transfer.verb = new Verb('gulp')

this.actions.push(transfer)
this.actions.push(new TransferAction(lowerStomach, stomach))



+ 8
- 3
src/game/creatures/withers.ts Datei anzeigen

@@ -104,7 +104,9 @@ class MawContainer extends NormalContainer {
constructor (owner: Vore, stomach: VoreContainer) {
super(new ImproperNoun('maw'), owner, new Set([VoreType.Oral]), 50)

this.actions.push(new TransferAction(this, stomach))
const transfer = new TransferAction(this, stomach)
transfer.verb = new Verb('gulp')
this.actions.push(transfer)
}
}

@@ -163,7 +165,7 @@ class BootContainer extends NormalContainer {
{ target: Stat.Toughness, type: DamageType.Crush, amount: 10 },
{ target: Stat.Power, type: DamageType.Crush, amount: 10 },
{ target: Stat.Speed, type: DamageType.Crush, amount: 10 },
{ target: Stat.Willpower, type: DamageType.Crush, amount: 10 },
{ target: Stat.Willpower, type: DamageType.Crush, amount: 30 },
{ target: Stat.Charm, type: DamageType.Crush, amount: 10 }
), 0.5),
this
@@ -369,12 +371,15 @@ export class Withers extends Creature {

this.otherContainers.push(maw)

const transfer = new TransferAction(maw, stomach)
transfer.verb = new Verb('gulp')

this.actions.push(new ChewAction(
new UniformRandomDamageFormula(new Damage(
{ target: Vigor.Health, type: DamageType.Crush, amount: 10000 }
), 0.5),
maw,
new TransferAction(maw, stomach)
transfer
))

const boot = new BootContainer(this)


+ 2
- 0
src/game/entity.ts Datei anzeigen

@@ -181,7 +181,9 @@ export class Creature extends Vore implements Combatant {
if (this.containedIn !== null) {
choices = choices.concat(this.containedIn.actions)
}
console.log(this, target)
return choices.filter(action => {
console.log(action, action.allowed(this, target))
return action.allowed(this, target)
})
}


+ 5
- 5
src/game/vore.ts Datei anzeigen

@@ -1,7 +1,7 @@
import { Entity, Mortal, POV, Creature } from './entity'
import { Mortal, POV } from './entity'
import { Damage, DamageType, Stats, Actionable, Action, Vigor, VoreStats } from './combat'
import { LogLines, LogEntry, CompositeLog, LogLine } from './interface'
import { Noun, Pronoun, POVPair, POVPairArgs, ImproperNoun, POVSolo, TextLike, Verb, SecondPersonPronouns, PronounAsNoun, FirstPersonPronouns, PairLine, PairLineArgs } from './language'
import { LogLines, LogEntry, LogLine } from './interface'
import { Noun, Pronoun, ImproperNoun, POVSolo, TextLike, Verb, SecondPersonPronouns, PronounAsNoun, FirstPersonPronouns, PairLineArgs } from './language'
import { DigestAction, DevourAction, ReleaseAction, StruggleAction } from './combat/actions'
import * as Words from './words'

@@ -57,7 +57,7 @@ export abstract class Vore implements Mortal {
abstract otherContainers: Array<Container>;
destroy (): LogEntry {
const lines = new POVSolo<Vore>([
[[POV.Second], (target: Vore) => new LogLine('You die!')],
[[POV.Second], () => new LogLine('You die!')],
[[POV.Third], (target: Vore) => new LogLine(`${target.name.capital} dies!`)]
])

@@ -125,7 +125,7 @@ export abstract class NormalContainer implements Container {
return new LogLine(`${user.name.capital} ${user.name.conjugate(new Verb('hork'))} ${target.name.objective} up from ${user.pronouns.possessive} ${args.container.name}.`)
}

struggleLine: PairLineArgs<Vore, { container: Container }> = (user, target, args) => {
struggleLine: PairLineArgs<Vore, { container: Container }> = () => {
return new LogLine(`struggle`)
}



Laden…
Abbrechen
Speichern