|  |  | @@ -1,7 +1,7 @@ | 
		
	
		
			
			|  |  |  | import { Entity, Mortal, POV, Creature } from './entity' | 
		
	
		
			
			|  |  |  | import { Damage, DamageType, Stats, Actionable, Action, Vigor } from './combat' | 
		
	
		
			
			|  |  |  | import { LogLines, LogEntry, CompositeLog, LogLine } from './interface' | 
		
	
		
			
			|  |  |  | import { Noun, Pronoun, POVPair, POVPairArgs, ImproperNoun } from './language' | 
		
	
		
			
			|  |  |  | import { Noun, Pronoun, POVPair, POVPairArgs, ImproperNoun, POVSolo } from './language' | 
		
	
		
			
			|  |  |  | import { DigestAction, DevourAction, ReleaseAction, StruggleAction } from './combat/actions' | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | export enum VoreType { | 
		
	
	
		
			
				|  |  | @@ -19,7 +19,7 @@ export abstract class Vore implements Mortal { | 
		
	
		
			
			|  |  |  | abstract maxVigors: {[key in Vigor]: number}; | 
		
	
		
			
			|  |  |  | abstract disabled: boolean; | 
		
	
		
			
			|  |  |  | abstract resistances: Map<DamageType, number>; | 
		
	
		
			
			|  |  |  | abstract takeDamage (damage: Damage): void; | 
		
	
		
			
			|  |  |  | abstract takeDamage (damage: Damage): LogEntry; | 
		
	
		
			
			|  |  |  | abstract stats: Stats; | 
		
	
		
			
			|  |  |  | abstract status: string; | 
		
	
		
			
			|  |  |  | abstract preyPrefs: Set<VoreType>; | 
		
	
	
		
			
				|  |  | @@ -28,6 +28,10 @@ export abstract class Vore implements Mortal { | 
		
	
		
			
			|  |  |  | abstract predPrefs: Set<VoreType>; | 
		
	
		
			
			|  |  |  | abstract containers: Array<Container>; | 
		
	
		
			
			|  |  |  | destroy (): LogEntry { | 
		
	
		
			
			|  |  |  | const lines = new POVSolo<Vore>([ | 
		
	
		
			
			|  |  |  | [[POV.First], (target: Vore) => new LogLine('You die!')], | 
		
	
		
			
			|  |  |  | [[POV.Third], (target: Vore) => new LogLine(`${target.name.capital} dies!`)] | 
		
	
		
			
			|  |  |  | ]) | 
		
	
		
			
			|  |  |  | this.containers.map(container => { | 
		
	
		
			
			|  |  |  | container.contents.map(prey => { | 
		
	
		
			
			|  |  |  | prey.containedIn = this.containedIn | 
		
	
	
		
			
				|  |  | @@ -37,7 +41,7 @@ export abstract class Vore implements Mortal { | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | return new LogLine(`${this.name.capital} dies!`) | 
		
	
		
			
			|  |  |  | return lines.run(this) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
	
		
			
				|  |  | @@ -46,6 +50,7 @@ export interface Container extends Actionable { | 
		
	
		
			
			|  |  |  | owner: Vore; | 
		
	
		
			
			|  |  |  | voreTypes: Set<VoreType>; | 
		
	
		
			
			|  |  |  | contents: Array<Vore>; | 
		
	
		
			
			|  |  |  | digested: Array<Vore>; | 
		
	
		
			
			|  |  |  | capacity: number; | 
		
	
		
			
			|  |  |  | fullness: number; | 
		
	
		
			
			|  |  |  | canTake: (prey: Vore) => boolean; | 
		
	
	
		
			
				|  |  | @@ -62,6 +67,7 @@ export interface Container extends Actionable { | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | abstract class NormalContainer implements Container { | 
		
	
		
			
			|  |  |  | contents: Array<Vore> | 
		
	
		
			
			|  |  |  | digested: Array<Vore> | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | abstract consumeLines: POVPair<Vore, Vore> | 
		
	
		
			
			|  |  |  | abstract releaseLines: POVPair<Vore, Vore> | 
		
	
	
		
			
				|  |  | @@ -107,33 +113,26 @@ abstract class NormalContainer implements Container { | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | tick (dt: number): LogEntry { | 
		
	
		
			
			|  |  |  | const digested: Array<Vore> = [] | 
		
	
		
			
			|  |  |  | const absorbed: Array<Vore> = [] | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | const scaled = this.damage.scale(dt / 60) | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | const damageResults: Array<LogEntry> = [] | 
		
	
		
			
			|  |  |  | this.contents.forEach(prey => { | 
		
	
		
			
			|  |  |  | const start = prey.vigors[Vigor.Health] | 
		
	
		
			
			|  |  |  | prey.takeDamage(scaled) | 
		
	
		
			
			|  |  |  | const end = prey.vigors[Vigor.Health] | 
		
	
		
			
			|  |  |  | damageResults.push(prey.takeDamage(scaled)) | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | if (start > 0 && end <= 0) { | 
		
	
		
			
			|  |  |  | if (prey.vigors[Vigor.Health] <= 0) { | 
		
	
		
			
			|  |  |  | digested.push(prey) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | if (start > -100 && end <= -100) { | 
		
	
		
			
			|  |  |  | absorbed.push(prey) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | const tickedEntries = new CompositeLog(...this.contents.map(prey => this.tickLines.run(this.owner, prey, { damage: scaled }))) | 
		
	
		
			
			|  |  |  | const digestedEntries = new CompositeLog(...digested.map(prey => this.digest(prey))) | 
		
	
		
			
			|  |  |  | const absorbedEntries = new CompositeLog(...absorbed.map(prey => this.absorb(prey))) | 
		
	
		
			
			|  |  |  | const tickedEntries = new LogLines(...this.contents.map(prey => this.tickLines.run(this.owner, prey, { damage: scaled }))) | 
		
	
		
			
			|  |  |  | const digestedEntries = new LogLines(...digested.map(prey => this.digest(prey))) | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | this.contents = this.contents.filter(prey => { | 
		
	
		
			
			|  |  |  | return prey.vigors[Vigor.Health] > -100 | 
		
	
		
			
			|  |  |  | return prey.vigors[Vigor.Health] > 0 | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | return new CompositeLog(tickedEntries, digestedEntries, absorbedEntries) | 
		
	
		
			
			|  |  |  | return new LogLines(tickedEntries, new LogLines(...damageResults), digestedEntries) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | describe (): LogEntry { | 
		
	
	
		
			
				|  |  | @@ -162,6 +161,7 @@ abstract class NormalContainer implements Container { | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | constructor (public name: Noun, public owner: Vore, public voreTypes: Set<VoreType>, public capacity: number, private damage: Damage) { | 
		
	
		
			
			|  |  |  | this.contents = [] | 
		
	
		
			
			|  |  |  | this.digested = [] | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | this.actions = [] | 
		
	
		
			
			|  |  |  | 
 | 
		
	
	
		
			
				|  |  | 
 |