feat: migrate JavaScript files to TypeScript, enhancing type safety and maintainability across the codebase

This commit is contained in:
Juan Sebastián Montoya 2026-01-06 21:51:00 -05:00
parent 3db2bb9160
commit c582f2004e
107 changed files with 5876 additions and 3588 deletions

View file

@ -1,28 +0,0 @@
/**
* World manager - handles areas and world state
*/
export class World {
constructor() {
this.areas = [];
this.currentArea = null;
this.areas.push({
id: 'cave',
name: 'Dark Cave',
type: 'cave',
spawnTypes: ['humanoid', 'beast', 'elemental'],
spawnRate: 0.5
});
this.currentArea = this.areas[0];
}
getCurrentArea() {
return this.currentArea;
}
getSpawnTypes() {
return this.currentArea ? this.currentArea.spawnTypes : ['beast'];
}
}

49
src/world/World.ts Normal file
View file

@ -0,0 +1,49 @@
/**
* Area configuration structure
*/
export interface Area {
id: string;
name: string;
type: string;
spawnTypes: string[];
spawnRate: number;
}
/**
* World manager responsible for handling different map areas and overall world state.
*/
export class World {
areas: Area[];
currentArea: Area | null;
constructor() {
this.areas = [];
this.currentArea = null;
this.areas.push({
id: 'cave',
name: 'Dark Cave',
type: 'cave',
spawnTypes: ['humanoid', 'beast', 'elemental'],
spawnRate: 0.5,
});
this.currentArea = this.areas[0];
}
/**
* Get the current active area.
* @returns The current area configuration
*/
getCurrentArea(): Area | null {
return this.currentArea;
}
/**
* Get the list of entity types permitted to spawn in the current area.
* @returns Array of entity type strings
*/
getSpawnTypes(): string[] {
return this.currentArea ? this.currentArea.spawnTypes : ['beast'];
}
}