@@ -29,7 +29,8 @@ import type {
2929 itemFoundType ,
3030 experienceType ,
3131 formatedFriendshipDataType ,
32- formatedMonsterDataType
32+ formatedMonsterDataType ,
33+ cookingDataType
3334} from 'types/displayDataTypes' ;
3435import type { fullPlayerDataType , museumCollectionType } from 'types/displayDataTypes' ;
3536
@@ -67,7 +68,12 @@ type getParsedUserDataType = Omit<getDetailedInfoType, 'playerData'> & {
6768}
6869
6970//Calls the parser and creates an array of players depending on wether it is a single player or multiple
70- const GetDetailedInfo = ( { playerData , collectionStatus, specialRequests, availableSpecialRequests} : getDetailedInfoType ) => {
71+ const GetDetailedInfo = ( {
72+ playerData ,
73+ collectionStatus,
74+ specialRequests,
75+ availableSpecialRequests
76+ } : getDetailedInfoType ) => {
7177 let fullPlayerData : fullPlayerDataType [ ] = [ ]
7278 if ( Array . isArray ( playerData ) ) {
7379 playerData . forEach ( p => {
@@ -86,7 +92,12 @@ const GetDetailedInfo = ({playerData , collectionStatus, specialRequests, availa
8692}
8793
8894//Creates an object per player with the cleanup playerData.from the file
89- const parseData = ( { playerData, collectionStatus, specialRequests, availableSpecialRequests} : getParsedUserDataType ) : fullPlayerDataType => {
95+ const parseData = ( {
96+ playerData,
97+ collectionStatus,
98+ specialRequests,
99+ availableSpecialRequests
100+ } : getParsedUserDataType ) : fullPlayerDataType => {
90101 //Not finished
91102 console . log ( "Parsing data for:" , playerData )
92103 let fullPlayerData : fullPlayerDataType = {
@@ -98,16 +109,24 @@ const parseData = ({playerData, collectionStatus, specialRequests, availableSpec
98109 shippedItems : GetShippedItems ( playerData . basicShipped ) || [ ] , //DONE
99110 cropsShipped : GetCropsAchievements ( playerData . basicShipped ?. item ) , //Refactored DONE
100111 //mineralsFound: GetArrayData(playerData.mineralsFound?.item) || [], //DONE
101- cookedItems : GetCookingData ( playerData . recipesCooked , playerData . cookingRecipes . item ) || [ ] , //DONE
112+ cookingData : GetCookingData ( playerData . recipesCooked , playerData . cookingRecipes . item ) || [ ] , //DONE
102113 fishCaught : GetFishes ( playerData . fishCaught . item ) || [ ] ,
103114 tailoredItems : GetArrayDataTimeless ( playerData . tailoredItems ) || [ ] ,
104115 itemsCrafted : GetCraftingRecipes ( playerData . craftingRecipes . item ) || [ ] ,
105116 friendship : GetFriendshipData ( playerData . friendshipData . item ) || [ ] ,
106- monstersKilled : GetMonsterQuests ( playerData . stats . specificMonstersKilled . item , playerData . stats . slimesKilled ) || [ ] ,
107- museumCollection : GetMCollection ( playerData . archaeologyFound . item , playerData . mineralsFound . item , collectionStatus ) || { } ,
117+ monstersKilled :
118+ GetMonsterQuests ( playerData . stats . specificMonstersKilled . item , playerData . stats . slimesKilled ) || [ ] ,
119+ museumCollection :
120+ GetMCollection ( playerData . archaeologyFound . item , playerData . mineralsFound . item , collectionStatus ) || { } ,
108121 questsDone : playerData . stats . questsCompleted || 0 ,
109- specialRequests : specialRequests ?. SpecialOrder ? GetSpecialRequests ( specialRequests . SpecialOrder , townSR . Requests , true ) : [ ] ,
110- availableSpecialRequests : specialRequests ?. SpecialOrder ? GetSpecialRequests ( specialRequests . SpecialOrder , townSR . Requests , false ) : [ ]
122+ specialRequests :
123+ specialRequests ?. SpecialOrder ?
124+ GetSpecialRequests ( specialRequests . SpecialOrder , townSR . Requests , true )
125+ : [ ] ,
126+ availableSpecialRequests :
127+ specialRequests ?. SpecialOrder ?
128+ GetSpecialRequests ( specialRequests . SpecialOrder , townSR . Requests , false )
129+ : [ ]
111130 }
112131
113132 console . log ( `%c Grandpa's eval for ${ playerData . name } ` , 'color: #7289DA' )
@@ -207,31 +226,46 @@ const GetShippedItems = (allShipped: itemType) :generalFormatedItemType[] => {
207226}
208227/* End of Shipping Related Achievements */
209228
210- const GetCookingData = ( cooked : itemType , known : itemsType [ ] ) : generalFormatedItemType [ ] => {
229+ const GetCookingData = ( cooked : itemType , known : itemsType [ ] ) : cookingDataType => {
211230 let data : generalFormatedItemType [ ] = [ ] ;
231+ let knownRecipes = 0 ;
232+ let alreadyCooked = 0 ;
212233 Dishes . Dishes . forEach ( item => {
213234 let knownDish = ValidateKnown ( known , NameTranslate ( item . Name ) ) || false
235+ let cookedTimes = GetCooked ( cooked . item , item . id )
236+ if ( cookedTimes > 0 ) alreadyCooked ++ ;
237+ if ( knownDish ) knownRecipes ++ ;
238+ console . log ( 'Dish:' , item . Name , 'Known:' , knownRecipes , 'CookedTimes:' , alreadyCooked )
214239 let d = {
215240 name : NameTranslate ( item . Name ) ,
216241 id : item . id ,
217242 image : GetImages ( item . Name ) ,
218243 link : item . link ,
219244 knownDish : knownDish ,
220- times : knownDish ? GetCooked ( cooked . item , item . id ) : 0
245+ times : cookedTimes
221246 }
222247 data . push ( d ) ;
223248 } )
224- console . log ( 'Cooking Data:' , data ) ;
225- return data
249+ return { knownRecipes, alreadyCookedRecipes : alreadyCooked , cookedItems : data } ;
226250}
227251
228252const GetCooked = ( cookedItems :itemsType [ ] , id : number ) : number => {
229- let cooked = 0 ;
253+ let timesCooked = 0 ;
230254 if ( Array . isArray ( cookedItems ) ) {
231- let i = cookedItems . find ( item => item . key . int === id )
232- cooked = ( i !== undefined ) ? i . value . int : 0
255+ let i = cookedItems . find ( item => {
256+ if ( item . key ?. int === undefined ) {
257+ if ( item . key ?. string !== undefined ) {
258+ return + item . key . string === id ;
259+ } else {
260+ return false ;
261+ }
262+ } else {
263+ return item . key . int === id
264+ }
265+ } )
266+ timesCooked = ( i !== undefined ) ? i . value . int : 0
233267 }
234- return cooked ;
268+ return timesCooked ;
235269}
236270
237271const GetCraftingRecipes = ( recipes : itemsType [ ] ) : generalFormatedItemType [ ] => {
0 commit comments