index.ts
1 /** 2 * pi-dunnet: A faithful port of Emacs Dunnet text adventure 3 * 4 * Run with: npm run dev 5 */ 6 7 import { DunnetGame, GameData } from './engine/game.js'; 8 import { ROOMS, ROOM_IDS } from './data/rooms.js'; 9 import { OBJECTS, createObjectNames } from './data/objects.js'; 10 import { DUNGEON_MAP, LIGHT_ROOMS, createInitialRoomObjects, createDiggables, generateCombination } from './data/map.js'; 11 12 export function createGameData(): GameData { 13 return { 14 rooms: ROOMS, 15 objects: OBJECTS, 16 objectNames: createObjectNames(), 17 roomMap: DUNGEON_MAP, 18 lightRooms: LIGHT_ROOMS, 19 diggables: createDiggables(), 20 treasureRoom: ROOM_IDS.TREASURE_ROOM, 21 caveCombination: generateCombination(), 22 roomObjects: createInitialRoomObjects(), 23 roomSilents: new Map(), 24 }; 25 } 26 27 async function main() { 28 console.log('Starting Dunnet...\n'); 29 30 const data = createGameData(); 31 const game = new DunnetGame(data); 32 33 await game.start(); 34 } 35 36 // Only run standalone, not when imported 37 if (process.argv[1]?.endsWith('index.js') || process.argv[1]?.endsWith('index.ts')) { 38 main().catch(console.error); 39 }