This repository has been archived on 2026-05-04. You can view files and clone it, but cannot push or open issues or pull requests.
Galaxy-Strike-Online/Galaxy-Strike-Online-main/GameServer/systems/CraftingSystem.js

31 lines
1.1 KiB
JavaScript

/**
* CraftingSystem — thin wrapper around ContentLoader for recipe definitions.
*/
class CraftingSystem {
constructor(contentLoader) {
this.loader = contentLoader;
this.playerCrafting = new Map();
}
getAllRecipes() { return this.loader.getAllRecipes(); }
getRecipe(id) { return this.loader.getRecipe(id); }
getRecipesByType(type) { return this.loader.getRecipesByType(type); }
getCraftingTabs() { return this.loader.getCraftingTabs(); }
initializePlayerData(userId) {
if (this.playerCrafting.has(userId)) return this.playerCrafting.get(userId);
const data = { skill: 1, experience: 0, knownRecipes: new Set(), totalCrafted: 0 };
this.playerCrafting.set(userId, data);
return data;
}
getPlayerCrafting(userId) { return this.initializePlayerData(userId); }
recordCraft(userId, recipeId) {
const pd = this.initializePlayerData(userId);
pd.totalCrafted++;
pd.knownRecipes.add(recipeId);
}
}
module.exports = CraftingSystem;