Skip to content

Commit

Permalink
Merge pull request #1211 from Coflnet/show-crafts-item-count
Browse files Browse the repository at this point in the history
show count per slot in recipe
  • Loading branch information
matthias-luger authored Feb 14, 2024
2 parents e1f3948 + b65dff0 commit 2cd00e7
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 26 deletions.
29 changes: 21 additions & 8 deletions components/CraftsList/CraftingRecipe/CraftingRecipe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,41 @@ export function CraftingRecipe(props: Props) {
cursor: props.onIngredientClick ? 'pointer' : 'default'
} as React.CSSProperties

function getGridElement(tag?: string) {
function getGridElement(craftingRecipeSlot: CraftingRecipeSlot | undefined) {
if (!craftingRecipeSlot) {
return <div style={{ height: '36px', width: '36px' }} />
}
return (
<div
onClick={() => {
onIngredientClick(tag)
onIngredientClick(craftingRecipeSlot.tag)
}}
style={style}
className={styles.gridCell}
>
{tag ? (
<div style={{ position: 'relative' }}>
<Image
title={convertTagToName(tag)}
title={convertTagToName(craftingRecipeSlot.tag)}
className={styles.ingredienceImage}
src={api.getItemImageUrl({ tag: tag })}
src={api.getItemImageUrl({ tag: craftingRecipeSlot.tag })}
alt=""
crossOrigin="anonymous"
height={36}
width={36}
/>
) : (
<div style={{ height: '36px', width: '36px' }} />
)}
<div
style={{
position: 'absolute',
bottom: 0,
right: 0,
color: 'white',
fontSize: '16px',
fontWeight: 'bold'
}}
>
{craftingRecipeSlot.count}
</div>
</div>
</div>
)
}
Expand Down
23 changes: 14 additions & 9 deletions global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,15 +389,20 @@ interface SkyblockProfile {
id: string
}
interface CraftingRecipe {
A1: string
A2: string
A3: string
B1: string
B2: string
B3: string
C1: string
C2: string
C3: string
A1: CraftingRecipeSlot
A2: CraftingRecipeSlot
A3: CraftingRecipeSlot
B1: CraftingRecipeSlot
B2: CraftingRecipeSlot
B3: CraftingRecipeSlot
C1: CraftingRecipeSlot
C2: CraftingRecipeSlot
C3: CraftingRecipeSlot
}

interface CraftingRecipeSlot {
tag: string,
count: number
}

interface LowestBin {
Expand Down
45 changes: 36 additions & 9 deletions utils/Parser/APIResponseParser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -415,15 +415,42 @@ export function parseSkyblockProfile(profile): SkyblockProfile {

export function parseCraftingRecipe(recipe): CraftingRecipe {
return {
A1: recipe.A1.split(':')[0],
A2: recipe.A2.split(':')[0],
A3: recipe.A3.split(':')[0],
B1: recipe.B1.split(':')[0],
B2: recipe.B2.split(':')[0],
B3: recipe.B3.split(':')[0],
C1: recipe.C1.split(':')[0],
C2: recipe.C2.split(':')[0],
C3: recipe.C3.split(':')[0]
A1: {
tag: recipe.A1.split(':')[0],
count: recipe.A1.split(':')[1]
},
A2: {
tag: recipe.A2.split(':')[0],
count: recipe.A2.split(':')[1]
},
A3: {
tag: recipe.A3.split(':')[0],
count: recipe.A3.split(':')[1]
},
B1: {
tag: recipe.B1.split(':')[0],
count: recipe.B1.split(':')[1]
},
B2: {
tag: recipe.B2.split(':')[0],
count: recipe.B2.split(':')[1]
},
B3: {
tag: recipe.B3.split(':')[0],
count: recipe.B3.split(':')[1]
},
C1: {
tag: recipe.C1.split(':')[0],
count: recipe.C1.split(':')[1]
},
C2: {
tag: recipe.C2.split(':')[0],
count: recipe.C2.split(':')[1]
},
C3: {
tag: recipe.C3.split(':')[0],
count: recipe.C3.split(':')[1]
}
}
}

Expand Down

0 comments on commit 2cd00e7

Please sign in to comment.