damage calculator
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: make nice interfaces for recipe addition

serenity fa7dd74a 90b12eb5

+137 -25
+5
app/src/components/Recipe.tsx
··· 1 + import type { RecipePattern } from "#/lib/recipe"; 2 + 3 + export const Recipe = ({ recipeInfo }: { recipeInfo: RecipePattern }) => { 4 + return <div>{recipeInfo.id}</div>; 5 + };
+26
app/src/lib/machine.ts
··· 1 + import type { Enumify } from "#/lib/utils/types"; 2 + 3 + export const AicMachineName = { 4 + REFINING_UNIT: "Refining Unit", 5 + SHREDDING_UNIT: "Shredding Unit", 6 + FITTING_UNIT: "Fitting Unit", 7 + MOULDING_UNIT: "Moulding Unit", 8 + PLANTING_UNIT: "Planting Unit", 9 + SEED_PICKING_UNIT: "Seed Picking Unit", 10 + GEARING_UNIT: "Gearing Unit", 11 + FILLING_UNIT: "Filling Unit", 12 + PACKAGING_UNIT: "Packaging Unit", 13 + GRINDING_UNIT: "Grinding Unit", 14 + SEPARATING_UNIT: "Separating Unit", 15 + FORGE_OF_THE_SKY: "Forge of the Sky", 16 + 17 + WATER_TREATMENT_UNIT: "Water Treatment Unit", 18 + REACTOR_CRUCIBLE: "Reactor Crucible", 19 + }; 20 + 21 + export type AicMachineName = Enumify<typeof AicMachineName>; 22 + 23 + export interface AicMachine { 24 + name: AicMachineName; 25 + iconUri?: string; 26 + }
+10
app/src/lib/product/index.ts
··· 1 + import type { Rarity } from "#/lib/rarity"; 2 + 3 + export interface AicProduct { 4 + id: string; 5 + iconUri?: string; 6 + name: string; 7 + rarity: Rarity; 8 + type: "Material" | "Miscellaneous" | string & {}; 9 + isFluid: boolean; 10 + }
+28
app/src/lib/product/products.ts
··· 1 + import { Rarity } from "#/lib/rarity"; 2 + import type { Enumify } from "#/lib/utils/types"; 3 + 4 + export const AicProducts = { 5 + BATT_WULING_MID: { 6 + id: "BATT_WULING_MID", 7 + name: "SC Wuling Battery", 8 + type: "Material", 9 + rarity: Rarity.EPIC, 10 + isFluid: false, 11 + }, 12 + POWDER_DENSE_ORIG: { 13 + id: "POWDER_DENSE_ORIG", 14 + name: "Dense Originium Powder", 15 + type: "Material", 16 + rarity: Rarity.RARE, 17 + isFluid: false, 18 + }, 19 + XIRCON_RESC: { 20 + id: "XIRCON_RESC", 21 + name: "Xircon", 22 + type: "Material", 23 + rarity: Rarity.RARE, 24 + isFluid: false, 25 + }, 26 + }; 27 + 28 + export type AicProducts = Enumify<typeof AicProducts>;
-22
app/src/lib/recipe.ts
··· 1 - import type { Rarity } from "#/lib/rarity"; 2 - 3 - export interface ProductItem { 4 - id: string; 5 - iconUri: string; 6 - name: string; 7 - rarity: Rarity; 8 - type: "Material" | "Miscalleneous"; 9 - } 10 - 11 - export interface RecipeItem { 12 - id: string; 13 - count: number; 14 - item: ProductItem; 15 - } 16 - 17 - export interface Recipe { 18 - id: string; 19 - secondsTaken: number; 20 - inputs: Array<RecipeItem>; 21 - outputs: Array<RecipeItem>; 22 - }
+16
app/src/lib/recipe/index.ts
··· 1 + import type { AicMachine } from "#/lib/machine"; 2 + import type { AicProduct } from "#/lib/product"; 3 + 4 + export interface RecipeItem { 5 + id: string; 6 + count: number; 7 + item: AicProduct; 8 + } 9 + 10 + export interface RecipePattern { 11 + id: string; 12 + secondsTaken: number; 13 + inputs: Array<RecipeItem>; 14 + outputs: Array<RecipeItem>; 15 + machine: AicMachine; 16 + }
+33
app/src/lib/recipe/recipes.ts
··· 1 + import { AicMachineName } from "#/lib/machine"; 2 + import { AicProducts } from "#/lib/product/products"; 3 + import type { RecipePattern } from "#/lib/recipe"; 4 + 5 + export const AIC_RECIPES = new Map<string, RecipePattern>([ 6 + [ 7 + "BATT_WULING_MID_MAIN", 8 + { 9 + id: "BATT_WULING_MID_MAIN", 10 + machine: { name: AicMachineName.PACKAGING_UNIT }, 11 + inputs: [ 12 + { 13 + id: AicProducts.XIRCON_RESC.id, 14 + count: 5, 15 + item: AicProducts.XIRCON_RESC, 16 + }, 17 + { 18 + id: AicProducts.POWDER_DENSE_ORIG.id, 19 + count: 20, 20 + item: AicProducts.POWDER_DENSE_ORIG, 21 + }, 22 + ], 23 + outputs: [ 24 + { 25 + id: AicProducts.BATT_WULING_MID.id, 26 + count: 1, 27 + item: AicProducts.BATT_WULING_MID, 28 + }, 29 + ], 30 + secondsTaken: 10, 31 + }, 32 + ], 33 + ]);
+19 -3
app/src/routes/index.tsx
··· 1 - import { createFileRoute } from '@tanstack/react-router' 1 + import { Recipe } from "#/components/Recipe"; 2 + import { AIC_RECIPES } from "#/lib/recipe/recipes"; 3 + import { createFileRoute } from "@tanstack/react-router"; 2 4 3 - export const Route = createFileRoute('/')({ component: App }) 5 + export const Route = createFileRoute("/")({ component: App }); 4 6 5 7 function App() { 6 - return <div>Welcome back, Endministrator</div> 8 + const testRecipe = AIC_RECIPES.get("BATT_WULING_MID_MAIN"); 9 + 10 + if (!testRecipe) 11 + return ( 12 + <div> 13 + <p>Could not get recipe info from recipe map.</p> 14 + </div> 15 + ); 16 + 17 + return ( 18 + <div> 19 + <p>Test Recipe:</p> 20 + <Recipe recipeInfo={testRecipe} /> 21 + </div> 22 + ); 7 23 }