From fafc984b70be0c8d30355b0fc47ee0e4c02bec46 Mon Sep 17 00:00:00 2001 From: Brian Nelson Date: Sat, 27 May 2023 23:53:41 -0700 Subject: [PATCH] clean up --- src/Character.ts | 4 +--- src/EffectableEntity.ts | 3 +-- src/Npc.ts | 6 ++---- src/Room.ts | 7 ++----- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/Character.ts b/src/Character.ts index 0046ffe..38adc66 100644 --- a/src/Character.ts +++ b/src/Character.ts @@ -10,9 +10,7 @@ import { Equipment } from './Equipment'; import { GameEntity } from './GameEntity'; import { EntityDefinitionBase } from './EntityFactory'; -export interface ICharacterConfig - extends ISerializedEffectableEntity, - EntityDefinitionBase { +export interface ICharacterConfig extends ISerializedEffectableEntity { /** @property {string} name Name shown on look/who/login */ name: string; /** @property {Inventory} inventory */ diff --git a/src/EffectableEntity.ts b/src/EffectableEntity.ts index c6142f8..44f150d 100644 --- a/src/EffectableEntity.ts +++ b/src/EffectableEntity.ts @@ -146,8 +146,7 @@ export class EffectableEntity extends EventEmitter { * @return {number} */ getBaseAttribute(attrName: string): number { - const attr = this.attributes.get(attrName); - return (attr && attr.base) || 0; + return this.attributes.get(attrName)?.base || 0; } /** diff --git a/src/Npc.ts b/src/Npc.ts index 07283b7..aee9bdf 100644 --- a/src/Npc.ts +++ b/src/Npc.ts @@ -1,6 +1,7 @@ import { Area } from './Area'; import { Character, ICharacterConfig } from './Character'; import { CommandQueue } from './CommandQueue'; +import { EntityDefinitionBase } from './EntityFactory'; import { EntityReference } from './EntityReference'; import { IGameState } from './GameState'; import { IItemDef } from './Item'; @@ -9,9 +10,7 @@ import { Room } from './Room'; const uuid = require('uuid'); -export interface INpcDef extends ICharacterConfig { - area?: string; - script?: string; +export interface INpcDef extends ICharacterConfig, EntityDefinitionBase { behaviors?: Record; equipment?: | Record @@ -19,7 +18,6 @@ export interface INpcDef extends ICharacterConfig { items?: EntityReference[]; description: string; entityReference: EntityReference; - id: string; keywords: string[]; quests?: EntityReference[]; uuid?: string; diff --git a/src/Room.ts b/src/Room.ts index a7e7c32..144a3a2 100644 --- a/src/Room.ts +++ b/src/Room.ts @@ -2,6 +2,7 @@ import { Area } from './Area'; import { Config } from './Config'; import { ISerializedEffect } from './Effect'; import { SerializedAttributes } from './EffectableEntity'; +import { EntityDefinitionBase } from './EntityFactory'; import { EntityReference } from './EntityReference'; import { GameEntity } from './GameEntity'; import { IGameState } from './GameState'; @@ -23,15 +24,11 @@ export interface IExit { leaveMessage?: string; } -export interface IRoomDef { +export interface IRoomDef extends EntityDefinitionBase { title: string; description: string; - entityReference: string; - id: string; - area?: string; items?: IRoomItemDef[]; npcs?: IRoomNpcDef[] | string[]; - script?: string; behaviors?: Record; attributes?: SerializedAttributes; effects?: ISerializedEffect[];