From 618be2bd9535a0ca2cbcfbdc92c1b81a45a11434 Mon Sep 17 00:00:00 2001 From: Edward Chernenko Date: Tue, 21 Jan 2025 01:51:19 +0300 Subject: [PATCH] (tools) count_price_of_all_research_nodes: count other currencies too --- tools/count_price_of_all_research_nodes.js | 24 +++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/tools/count_price_of_all_research_nodes.js b/tools/count_price_of_all_research_nodes.js index 2e1b80f..a112963 100644 --- a/tools/count_price_of_all_research_nodes.js +++ b/tools/count_price_of_all_research_nodes.js @@ -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.' +);