From 1a9841d2b9f98f5a0acbda3f41a540be9bedf16c Mon Sep 17 00:00:00 2001 From: Joshua Sigona Date: Sat, 11 Sep 2021 17:21:20 +0900 Subject: [PATCH] We have food. And the food now makes sense. Thanks dudley --- src/TestPanel.js | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/src/TestPanel.js b/src/TestPanel.js index 498f1bb..1951e94 100644 --- a/src/TestPanel.js +++ b/src/TestPanel.js @@ -464,12 +464,35 @@ const [prevSkillPointData,setPrevSkillPointData] = useState([]) const [foodPointData,setFoodPointData] = useState({}) const [prevFoodPointData,setPrevFoodPointData] = useState({}) +const [BUFFS,setBUFFS] = useState({}) + function CalculateBuffs(foodPointData) { + + var boost_prefixes = { + pp_consumption:"Rich", + pp_recovery:"Light", + weak_point_dmg:"Crisp", + hp_recovery:"Robust", + } + var boost_suffixes = { + potency:"Meat", + pp:"Fruit", + dmg_res:"Vegetable", + hp:"Seafood", + } + var categories= {} - Object.keys(GetData("food_mult","0")).filter((key)=>key!=="id"&&key!=="amount").forEach((key)=>{categories[key]={from:"",count:0}}) - //Object.keys(foodPointData). - console.log(foodPointData) - return categories + Object.keys(GetData("food_mult","0")).filter((key)=>key!=="id"&&key!=="amount").forEach((key)=>{categories[key]={count:0}}) + Object.keys(foodPointData).map((key)=>{return {...GetData("food",key),amount:foodPointData[key]}}).forEach((item)=>{ + for (var key of Object.keys(item)) { + if (key in categories && item[key]) { + categories[key].count+=item.amount + } + } + }) + var finalObj = {} + Object.keys(categories).filter((key)=>categories[key].count>0).forEach((key)=>finalObj[key]={...categories[key],from:boost_prefixes[key]??boost_suffixes[key]}) + return finalObj } function SaveData() { @@ -577,6 +600,14 @@ useEffect(()=>{ } },[BUILDID,GetData,BACKENDURL,p]) +useEffect(()=>{ + setBUFFS(CalculateBuffs(foodPointData)??[]) +},[foodPointData]) + +useEffect(()=>{ + console.log(BUFFS) +},[BUFFS]) + //console.log(p.GetData("class",p.className,"icon")) return (<> @@ -788,8 +819,8 @@ useEffect(()=>{ {effectPage===1?<>

Effect Name