Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonsbrian committed May 28, 2023
1 parent 1930112 commit fafc984
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
4 changes: 1 addition & 3 deletions src/Character.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
3 changes: 1 addition & 2 deletions src/EffectableEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
6 changes: 2 additions & 4 deletions src/Npc.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -9,17 +10,14 @@ 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<string, any>;
equipment?:
| Record<string, IItemDef>
| Record<string, { entityReference: string }>;
items?: EntityReference[];
description: string;
entityReference: EntityReference;
id: string;
keywords: string[];
quests?: EntityReference[];
uuid?: string;
Expand Down
7 changes: 2 additions & 5 deletions src/Room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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<string, any>;
attributes?: SerializedAttributes;
effects?: ISerializedEffect[];
Expand Down

0 comments on commit fafc984

Please sign in to comment.