feat: add fabricator disciplines for recipe unlocks
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m21s

- Add unlocksRecipes field to DisciplinePerk type
- Add study-fabricator-recipes discipline (earth/metal/sand/crystal recipes)
- Add study-wizard-branch discipline (wizard equipment recipes)
- Add study-physical-branch discipline (physical combat equipment recipes)
- Collect unlocksRecipes during discipline tick processing
- Pass recipe unlocks to crafting store via gameStore
- Add unlockRecipes action to craftingStore with persistence
- Filter fabricator recipes by unlock status in FabricatorSubTab UI
This commit is contained in:
2026-05-29 15:42:09 +02:00
parent 9e49aa1ca6
commit 644b76f16d
10 changed files with 216 additions and 8 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
# Circular Dependencies
Generated: 2026-05-29T13:10:03.724Z
Generated: 2026-05-29T13:23:45.664Z
No circular dependencies found. ✅
+1 -1
View File
@@ -1,6 +1,6 @@
{
"_meta": {
"generated": "2026-05-29T13:10:02.096Z",
"generated": "2026-05-29T13:23:43.981Z",
"description": "Import dependency graph for src/lib/game. Keys are files, values are arrays of files they import.",
"usage": "To find what a file affects, search for its path in the VALUES. To find what a file depends on, look at its KEY entry."
},
@@ -136,6 +136,7 @@ export function FabricatorSubTab() {
const [branchFilter, setBranchFilter] = useState<BranchFilter>('all');
const lootInventory = useCraftingStore((s) => s.lootInventory);
const unlockedRecipes = useCraftingStore((s) => s.unlockedRecipes);
const equipmentCraftingProgress = useCraftingStore((s) => s.equipmentCraftingProgress);
const rawMana = useManaStore((s) => s.rawMana);
const elements = useManaStore((s) => s.elements);
@@ -156,8 +157,8 @@ export function FabricatorSubTab() {
} else if (branchFilter === 'physical') {
recipes = recipes.filter(r => isPhysicalBranch(r));
}
return recipes.filter(r => r.manaType === selectedManaType);
}, [selectedManaType, branchFilter]);
return recipes.filter(r => r.manaType === selectedManaType && unlockedRecipes.includes(r.id));
}, [selectedManaType, branchFilter, unlockedRecipes]);
const isCrafting = equipmentCraftingProgress !== null;
+172
View File
@@ -57,4 +57,176 @@ export const fabricatorDisciplines: DisciplineDefinition[] = [
},
],
},
{
id: 'study-fabricator-recipes',
name: 'Study Fabricator Recipes',
attunement: DisciplinesAttunementType.FABRICATOR,
manaType: 'earth',
baseCost: 10,
description: 'Learn to craft elemental equipment at the fabricator.',
statBonus: { stat: 'enchantPower', baseValue: 3, label: 'Enchantment Power' },
difficultyFactor: 100,
scalingFactor: 80,
drainBase: 2,
perks: [
{
id: 'fabricator-earth-recipes',
type: 'once',
threshold: 50,
value: 0,
description: 'Unlock Earth fabricator recipes',
unlocksRecipes: ['earthHelm', 'earthChest', 'earthBoots'],
},
{
id: 'fabricator-metal-recipes',
type: 'once',
threshold: 100,
value: 0,
description: 'Unlock Metal fabricator recipes',
unlocksRecipes: ['metalBlade', 'metalShield', 'metalGloves'],
},
{
id: 'fabricator-sand-recipes',
type: 'once',
threshold: 150,
value: 0,
description: 'Unlock Sand fabricator recipes',
unlocksRecipes: ['sandBoots', 'sandGloves', 'sandVest'],
},
{
id: 'fabricator-crystal-recipes',
type: 'once',
threshold: 200,
value: 0,
description: 'Unlock Crystal fabricator recipes',
unlocksRecipes: ['crystalWand', 'crystalRing', 'crystalAmulet'],
},
],
},
{
id: 'study-wizard-branch',
name: 'Study Wizard Equipment',
attunement: DisciplinesAttunementType.FABRICATOR,
manaType: 'earth',
baseCost: 15,
description: 'Learn to craft advanced wizard equipment.',
statBonus: { stat: 'enchantPower', baseValue: 5, label: 'Enchantment Power' },
difficultyFactor: 150,
scalingFactor: 100,
drainBase: 3,
requires: ['study-fabricator-recipes'],
perks: [
{
id: 'wizard-oak-staff',
type: 'once',
threshold: 50,
value: 0,
description: 'Unlock Oak Staff recipe',
unlocksRecipes: ['oakStaff'],
},
{
id: 'wizard-arcanist-staff',
type: 'once',
threshold: 100,
value: 0,
description: 'Unlock Arcanist Staff recipe',
unlocksRecipes: ['arcanistStaff'],
},
{
id: 'wizard-battlestaff',
type: 'once',
threshold: 150,
value: 0,
description: 'Unlock Battlestaff recipe',
unlocksRecipes: ['battlestaff'],
},
{
id: 'wizard-arcanist-set',
type: 'once',
threshold: 200,
value: 0,
description: 'Unlock Arcanist Circlet and Robe recipes',
unlocksRecipes: ['arcanistCirclet', 'arcanistRobe'],
},
{
id: 'wizard-void-catalyst',
type: 'once',
threshold: 250,
value: 0,
description: 'Unlock Void Catalyst recipe',
unlocksRecipes: ['voidCatalyst'],
},
{
id: 'wizard-arcanist-pendant',
type: 'once',
threshold: 300,
value: 0,
description: 'Unlock Arcanist Pendant recipe',
unlocksRecipes: ['arcanistPendant'],
},
],
},
{
id: 'study-physical-branch',
name: 'Study Physical Equipment',
attunement: DisciplinesAttunementType.FABRICATOR,
manaType: 'earth',
baseCost: 15,
description: 'Learn to craft advanced physical combat equipment.',
statBonus: { stat: 'enchantPower', baseValue: 5, label: 'Enchantment Power' },
difficultyFactor: 150,
scalingFactor: 100,
drainBase: 3,
requires: ['study-fabricator-recipes'],
perks: [
{
id: 'physical-crystal-blade',
type: 'once',
threshold: 50,
value: 0,
description: 'Unlock Crystal Blade recipe',
unlocksRecipes: ['crystalBlade'],
},
{
id: 'physical-arcanist-blade',
type: 'once',
threshold: 100,
value: 0,
description: 'Unlock Arcanist Blade recipe',
unlocksRecipes: ['arcanistBlade'],
},
{
id: 'physical-void-blade',
type: 'once',
threshold: 150,
value: 0,
description: 'Unlock Void Blade recipe',
unlocksRecipes: ['voidBlade'],
},
{
id: 'physical-battle-set',
type: 'once',
threshold: 200,
value: 0,
description: 'Unlock Battle Helm and Robe recipes',
unlocksRecipes: ['battleHelm', 'battleRobe'],
},
{
id: 'physical-battle-boots',
type: 'once',
threshold: 250,
value: 0,
description: 'Unlock Battle Boots recipe',
unlocksRecipes: ['battleBoots'],
},
{
id: 'physical-combat-gauntlets',
type: 'once',
threshold: 300,
value: 0,
description: 'Unlock Combat Gauntlets recipe',
unlocksRecipes: ['combatGauntlets'],
},
],
},
];
@@ -19,6 +19,7 @@ export function createDefaultCraftingState(): CraftingState {
equipmentCraftingProgress: null,
enchantmentDesigns: [],
unlockedEffects: [],
unlockedRecipes: [],
equippedInstances: initial.equippedInstances,
equipmentInstances: initial.instances,
lootInventory: {
+16
View File
@@ -344,6 +344,21 @@ export const useCraftingStore = create<CraftingStore>()(
});
},
unlockRecipes: (recipeIds: string[]) => {
set((state) => {
const existing = new Set(state.unlockedRecipes);
let changed = false;
for (const id of recipeIds) {
if (!existing.has(id)) {
existing.add(id);
changed = true;
}
}
if (!changed) return state;
return { unlockedRecipes: Array.from(existing) };
});
},
processEquipmentCraftingTick: (): { completed: boolean; logMessage?: string } => {
const state = get();
return processEquipmentCraftingTick(state, set as unknown as (partial: Partial<CraftingState>) => void);
@@ -366,6 +381,7 @@ export const useCraftingStore = create<CraftingStore>()(
equipmentCraftingProgress: state.equipmentCraftingProgress,
enchantmentDesigns: state.enchantmentDesigns,
unlockedEffects: state.unlockedEffects,
unlockedRecipes: state.unlockedRecipes,
equipmentInstances: state.equipmentInstances,
equippedInstances: state.equippedInstances,
lootInventory: state.lootInventory,
@@ -24,6 +24,7 @@ export interface CraftingState {
equipmentCraftingProgress: EquipmentCraftingProgress | null;
enchantmentDesigns: EnchantmentDesign[];
unlockedEffects: string[];
unlockedRecipes: string[];
equipmentInstances: Record<string, EquipmentInstance>;
equippedInstances: Record<string, string | null>;
lootInventory: {
@@ -72,6 +73,7 @@ export interface CraftingActions {
resetEnchantmentSelection: () => void;
clearLastError: () => void;
unlockEffects: (effectIds: string[]) => void;
unlockRecipes: (recipeIds: string[]) => void;
processEquipmentCraftingTick: () => { completed: boolean; logMessage?: string };
resetCrafting: () => void;
}
+9 -2
View File
@@ -54,6 +54,7 @@ export interface DisciplineStoreActions {
rawMana: number;
elements: Record<string, ElementState>;
unlockedEffects: string[];
unlockedRecipes: string[];
};
setPracticingCallbacks(callbacks: { onStartPracticing: () => void; onStopPracticing: () => void }): void;
resetDisciplines: () => void;
@@ -158,6 +159,7 @@ export const useDisciplineStore = create<DisciplineStore>()(
let newXP = s.totalXP;
const newDisciplines = { ...s.disciplines };
const newUnlockedEffects: string[] = [];
const newUnlockedRecipes: string[] = [];
const newProcessedPerks = [...s.processedPerks];
const drainedIds: string[] = [];
@@ -221,10 +223,15 @@ export const useDisciplineStore = create<DisciplineStore>()(
const newPerks = getUnlockedPerks(def, disc.xp + 1);
const oldPerkIds = new Set(oldPerks.map(p => p.id));
for (const perk of newPerks) {
if (!oldPerkIds.has(perk.id) && perk.unlocksEffects) {
if (!oldPerkIds.has(perk.id)) {
const perkKey = `${id}:${perk.id}`;
if (!newProcessedPerks.includes(perkKey)) {
if (perk.unlocksEffects) {
newUnlockedEffects.push(...perk.unlocksEffects);
}
if (perk.unlocksRecipes) {
newUnlockedRecipes.push(...perk.unlocksRecipes);
}
newProcessedPerks.push(perkKey);
}
}
@@ -251,7 +258,7 @@ export const useDisciplineStore = create<DisciplineStore>()(
processedPerks: newProcessedPerks,
});
return { rawMana, elements, unlockedEffects: newUnlockedEffects };
return { rawMana, elements, unlockedEffects: newUnlockedEffects, unlockedRecipes: newUnlockedRecipes };
},
}),
{ storage: createSafeStorage(), name: 'mana-loop-discipline-store', version: 1, partialize: (state) => ({ disciplines: state.disciplines, activeIds: state.activeIds, concurrentLimit: state.concurrentLimit, totalXP: state.totalXP, processedPerks: state.processedPerks }) }
+8
View File
@@ -277,6 +277,14 @@ export const useGameStore = create<GameCoordinatorStore>()(
}
}
// Unlock fabricator recipes from newly unlocked discipline perks
if (disciplineResult.unlockedRecipes.length > 0) {
useCraftingStore.getState().unlockRecipes(disciplineResult.unlockedRecipes);
for (const recipeId of disciplineResult.unlockedRecipes) {
addLog(`🔨 Fabricator recipe unlocked: ${recipeId}`);
}
}
// Apply per-element capacity bonuses from disciplines and equipment
const perElementCapBonuses = mergePerElementCapBonuses(
disciplineEffects.bonuses,
+1
View File
@@ -25,6 +25,7 @@ export interface DisciplinePerk {
value: number;
description: string;
unlocksEffects?: string[];
unlocksRecipes?: string[];
bonus?: PerkBonus;
/**
* For capped perks: maximum number of tiers. If unset, capped perks