@dev-dungeon/mud-engine
Version:
TypeScript game engine library for MUDs that handles core logic, including entity creation, room management, and game interactions in a modular and extensible way.
120 lines (110 loc) • 3.09 kB
TypeScript
declare enum PlaceType {
ROOM = "ROOM",
CITY = "CITY",
FOREST = "FOREST"
}
declare enum Orientation {
N = "N",
S = "S",
E = "E",
W = "W",
NE = "NE",
SE = "SE",
SW = "SW",
NW = "NW",
UP = "UP",
DOWN = "DOWN"
}
interface IPlace {
attrs?: Array<IPlaceAttr>;
code: string;
exits: Array<IPlaceExit>;
id?: string;
isExitToOtherArea?: boolean;
lightPost?: number;
npcs?: Array<IPlaceNpc>;
placeType: PlaceType;
players: Array<IPlacePlayer>;
security: number;
windows?: number;
}
interface IPlaceAttr {
code: string;
disabled?: boolean;
value: string | number | boolean;
}
interface IPlaceExit {
disabled?: boolean;
id: string;
lockable?: boolean;
locked?: boolean;
name: string;
opened: boolean;
orientation: Orientation;
placeId: string;
unlocker?: Array<string>;
visible?: boolean;
}
interface IPlaceNpc {
id: string;
name: string;
quests: Array<IPlaceNpcQuest>;
}
interface IPlaceNpcQuest {
questId: string;
requirements: Array<string>;
}
interface IPlacePlayer {
id: string;
name: string;
}
declare class Place implements IPlace {
attrs: Array<IPlaceAttr>;
code: string;
exits: Array<IPlaceExit>;
id: string;
isExitToOtherArea: boolean;
npcs: Array<IPlaceNpc>;
placeType: PlaceType;
players: Array<IPlacePlayer>;
security: number;
constructor(attrs: Array<IPlaceAttr> | undefined, code: string, exits: Array<IPlaceExit> | undefined, id: string | undefined, isExitToOtherArea: boolean | undefined, npcs: Array<IPlaceNpc> | undefined, placeType: PlaceType, players: Array<IPlacePlayer> | undefined, security: number);
addPlayer(player: IPlacePlayer): void;
removePlayer(playerId: string): void;
addNpc(npc: IPlaceNpc): void;
removeNpc(npcName: string): void;
addExit(exit: IPlaceExit): void;
removeExit(exitId: IPlaceExit['id']): void;
getVisibleExits(): Array<IPlaceExit>;
toJSON(): IPlace;
}
interface IArea {
id: string;
name: string;
minimumLevel: number;
maximumLevel: number;
places: Array<IPlace>;
}
declare class Area implements IArea {
id: string;
name: string;
maximumLevel: number;
minimumLevel: number;
places: Array<IPlace>;
constructor(id?: string, name?: string, maximumLevel?: number, minimumLevel?: number, places?: Array<IPlace>);
addPlace(place: IPlace): void;
removePlace(placeId: string): void;
}
declare abstract class Creator$1 {
abstract createArea(name: string): IArea;
}
declare class AreaFactory extends Creator$1 {
createArea(name: string): IArea;
}
declare abstract class Creator {
abstract createPlace(code: string, security: number): IPlace;
}
declare class RoomPlaceFactory extends Creator {
createPlace(code: string, security: number): IPlace;
}
export { Area, AreaFactory, type IArea, type IPlace, type IPlaceAttr, type IPlaceExit, type IPlaceNpc, type IPlaceNpcQuest, type IPlacePlayer, Orientation, Place, PlaceType, RoomPlaceFactory };