From d6b1564690a960160040b6eada6cc97d28393985 Mon Sep 17 00:00:00 2001 From: Van Nguyen <36019388+nguyentvan7@users.noreply.github.com> Date: Wed, 28 Aug 2024 15:35:12 -0700 Subject: [PATCH 1/2] Fix crash when optimizing with Scroll set --- .../ScrollOfTheHeroOfCinderCity/index.tsx | 56 +++++++++---------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/libs/gi/sheets/src/Artifacts/ScrollOfTheHeroOfCinderCity/index.tsx b/libs/gi/sheets/src/Artifacts/ScrollOfTheHeroOfCinderCity/index.tsx index 491edecf2f..0be0b34d6b 100644 --- a/libs/gi/sheets/src/Artifacts/ScrollOfTheHeroOfCinderCity/index.tsx +++ b/libs/gi/sheets/src/Artifacts/ScrollOfTheHeroOfCinderCity/index.tsx @@ -27,24 +27,23 @@ const condReacts = objKeyMap(allElementKeys, (ele) => condReadNode(condReactPaths[ele]) ) -const condReactNodes = objKeyMap(allElementKeys, (triggerEle) => - greaterEq( - input.artSet.ScrollOfTheHeroOfCinderCity, - 4, - equal(condReacts[triggerEle], triggerEle, 1) - ) +const reactNodeOnCount = sum( + ...allElementKeys.map((ele) => equal(condReacts[ele], ele, 1)) ) -const reactNodeOnCount = sum(...Object.values(condReactNodes)) const condReactBuffs = objKeyValMap(allElementKeys, (ele) => [ `${ele}_dmg_`, - threshold( - equal(input.charEle, ele, 1), - 1, - // buffing self elemental damage, check if any of the reactions are enabled - greaterEq(reactNodeOnCount, 1, 0.12), - // buffing other elemental damage, check if that particular conditional is enabled - equal(condReactNodes[ele], 1, 0.12) + greaterEq( + input.artSet.ScrollOfTheHeroOfCinderCity, + 4, + threshold( + equal(input.charEle, ele, 1), + 1, + // buffing self elemental damage, check if any of the reactions are enabled + greaterEq(reactNodeOnCount, 1, 0.12), + // buffing other elemental damage, check if that particular conditional is enabled + equal(condReacts[ele], ele, 0.12) + ) ), ]) @@ -56,17 +55,10 @@ const condNightsouls = objKeyMap(allElementKeys, (ele) => condReadNode(condNightsoulPaths[ele]) ) -const condNightsoulNodes = objKeyMap(allElementKeys, (triggerEle) => - greaterEq( - input.artSet.ScrollOfTheHeroOfCinderCity, - 4, - equal(condNightsouls[triggerEle], triggerEle, 1) - ) -) const reactAndNightsoulOnCount = sum( ...allElementKeys.map((ele) => greaterEq( - equal(condReactNodes[ele], 1, equal(condNightsoulNodes[ele], 1, 1)), + equal(condReacts[ele], ele, equal(condNightsouls[ele], ele, 1)), 1, 1 ) @@ -75,13 +67,17 @@ const reactAndNightsoulOnCount = sum( const condNightsoulBuffs = objKeyValMap(allElementKeys, (ele) => [ `${ele}_dmg_`, - threshold( - equal(input.charEle, ele, 1), - 1, - // buffing self elemental damage, check if any of the reactions are enabled - greaterEq(reactAndNightsoulOnCount, 1, 0.28), - // buffing other elemental damage, check if that particular conditional is enabled - equal(condNightsoulNodes[ele], 1, equal(condReactNodes[ele], 1, 0.28)) + greaterEq( + input.artSet.ScrollOfTheHeroOfCinderCity, + 4, + threshold( + equal(input.charEle, ele, 1), + 1, + // buffing self elemental damage, check if any of the reactions are enabled + greaterEq(reactAndNightsoulOnCount, 1, 0.28), + // buffing other elemental damage, check if that particular conditional is enabled + equal(condNightsouls[ele], ele, equal(condReacts[ele], ele, 0.28)) + ) ), ]) @@ -143,7 +139,7 @@ const sheet: SetEffectSheet = { states: (data: UIData) => objKeyMap( // Only show reactions that are already enabled - allElementKeys.filter((ele) => data.get(condReactNodes[ele]).value), + allElementKeys.filter((ele) => data.get(condReacts[ele]).value), (ele) => ({ value: condNightsouls[ele], path: condNightsoulPaths[ele], From 6da9f451da68759d67462492d3618cfe4fff24f5 Mon Sep 17 00:00:00 2001 From: Van Nguyen <36019388+nguyentvan7@users.noreply.github.com> Date: Wed, 28 Aug 2024 15:47:57 -0700 Subject: [PATCH 2/2] Even simpler --- .../ScrollOfTheHeroOfCinderCity/index.tsx | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/libs/gi/sheets/src/Artifacts/ScrollOfTheHeroOfCinderCity/index.tsx b/libs/gi/sheets/src/Artifacts/ScrollOfTheHeroOfCinderCity/index.tsx index 0be0b34d6b..3bc516d6cb 100644 --- a/libs/gi/sheets/src/Artifacts/ScrollOfTheHeroOfCinderCity/index.tsx +++ b/libs/gi/sheets/src/Artifacts/ScrollOfTheHeroOfCinderCity/index.tsx @@ -6,12 +6,12 @@ import { import type { UIData } from '@genshin-optimizer/gi/uidata' import type { Data } from '@genshin-optimizer/gi/wr' import { + compareEq, equal, greaterEq, infoMut, input, sum, - threshold, } from '@genshin-optimizer/gi/wr' import { condReadNode, st, stg } from '../../SheetUtil' import { ArtifactSheet, setHeaderTemplate } from '../ArtifactSheet' @@ -36,9 +36,9 @@ const condReactBuffs = objKeyValMap(allElementKeys, (ele) => [ greaterEq( input.artSet.ScrollOfTheHeroOfCinderCity, 4, - threshold( - equal(input.charEle, ele, 1), - 1, + compareEq( + input.charEle, + ele, // buffing self elemental damage, check if any of the reactions are enabled greaterEq(reactNodeOnCount, 1, 0.12), // buffing other elemental damage, check if that particular conditional is enabled @@ -57,11 +57,7 @@ const condNightsouls = objKeyMap(allElementKeys, (ele) => const reactAndNightsoulOnCount = sum( ...allElementKeys.map((ele) => - greaterEq( - equal(condReacts[ele], ele, equal(condNightsouls[ele], ele, 1)), - 1, - 1 - ) + equal(condReacts[ele], ele, equal(condNightsouls[ele], ele, 1)) ) ) @@ -70,9 +66,9 @@ const condNightsoulBuffs = objKeyValMap(allElementKeys, (ele) => [ greaterEq( input.artSet.ScrollOfTheHeroOfCinderCity, 4, - threshold( - equal(input.charEle, ele, 1), - 1, + compareEq( + input.charEle, + ele, // buffing self elemental damage, check if any of the reactions are enabled greaterEq(reactAndNightsoulOnCount, 1, 0.28), // buffing other elemental damage, check if that particular conditional is enabled