Skip to content

Commit

Permalink
trait trees are in mod editorgit status
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Aug 23, 2024
1 parent 92f7452 commit 7b08b4c
Show file tree
Hide file tree
Showing 11 changed files with 2,321 additions and 1,474 deletions.
76 changes: 76 additions & 0 deletions _transformers/helpers/traittrees.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
const fs = require("fs");

module.exports.handleTraitTrees = function handleTraitTrees(traitTrees) {
const coreTree = traitTrees.find((t) => t.name === "Core");
const ancientTree = traitTrees.find((t) => t.name === "Ancient");

const newCore = () => structuredClone(coreTree.data);
const newAncient = () => structuredClone(ancientTree.data);

// set treeName and requiredLevel for each trait entry
traitTrees.forEach((tree) => {
tree.data.treeOrder.forEach((treeName) => {
tree.data.trees[treeName].tree
.map((t) => t.traits)
.flat()
.forEach((t) => {
t.name ??= "";

if (!t.name) {
delete t.maxLevel;
delete t.requires;
delete t.isAncient;
return;
}

t.treeName = treeName;
});

tree.data.trees[treeName].name = treeName;
tree.data.trees[treeName].tree.forEach((row, rowIndex) => {
row.requiredLevel = rowIndex * 10;
});
});
});

const allTraitTrees = {
Ancient: newAncient(),
Core: newCore(),
};

traitTrees.forEach((tree) => {
allTraitTrees[tree.name] = tree.data;
});

// merge everything
traitTrees.forEach((tree) => {
if (tree.name === "Core" || tree.name === "Ancient") return;

tree.data.treeOrder = ["Core", ...tree.data.treeOrder, "Ancient"];
tree.data.trees.Ancient = newAncient().trees.Ancient;
tree.data.trees.Core = newCore().trees.Core;

tree.data.allTreeTraits = {};
tree.data.treeOrder.forEach((treeName) => {
tree.data.trees[treeName].tree.forEach((row) => {
row.traits.forEach((t) => {
if (!t.name) return;

if (!t.isAncient) delete t.isAncient;
if (!t.requires) delete t.requires;
if (!t.maxLevel) t.maxLevel = 1;

tree.data.allTreeTraits[t.name] = {
...t,
requiredLevel: row.requiredLevel,
};
});
});
});
});

fs.writeFileSync(
"_output/trait-trees.json",
JSON.stringify(allTraitTrees, null, 4)
);
};
2 changes: 2 additions & 0 deletions _transformers/modimport.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const fs = require("fs-extra");
const { handleRNGDungeonConfig } = require("./helpers/rngdungeon");
const { handleDoors } = require("./helpers/doors");
const { handleSTEMs } = require("./helpers/stems");
const { handleTraitTrees } = require("./helpers/traittrees");

const OUTPUT_DIR = "_output";

Expand Down Expand Up @@ -69,6 +70,7 @@ fs.readdirSync("mods").forEach((mod) => {

handleCoreFiles(modFile.cores);
handleSTEMs(modFile.stems);
handleTraitTrees(modFile.traitTrees);

modFile.maps.forEach((mapData) => {
const { name, map } = mapData;
Expand Down
59 changes: 0 additions & 59 deletions _transformers/trait-tree.js

This file was deleted.

Loading

0 comments on commit 7b08b4c

Please sign in to comment.