Skip to content

Commit

Permalink
(tools) count_price_of_all_research_nodes: count other currencies too
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardspec committed Jan 21, 2025
1 parent 58ac819 commit 618be2b
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions tools/count_price_of_all_research_nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,25 @@

const { ResearchTreeDatabase } = require( '../lib' );

let totalCost = 0;
let costByItem = {};

ResearchTreeDatabase.forEach( ( node ) => {
let researchCost = node.price.getAllComponents()
.filter( ( component ) => component.code === 'fuscienceresource' )[0];
node.price.getAllComponents().forEach( ( component ) => {
let count = component.quantity.count;
if ( !count ) {
return;
}

if ( researchCost ) {
totalCost += researchCost.quantity.count;
}
if ( !costByItem[component.code] ) {
costByItem[component.code] = 0;
}

costByItem[component.code] += count;
} );
} );

console.log( totalCost + ' of Research currency is needed to unlock ALL nodes.' );
console.log(
( costByItem.fuscienceresource || 0 ) + ' of Research currency, ' +
( costByItem.fumadnessresource || 0 ) + ' of Madness currency, ' +
( costByItem.fugeneticmaterial || 0 ) + ' of Genes currency are needed to unlock ALL nodes.'
);

0 comments on commit 618be2b

Please sign in to comment.