How salinecitrine/noita-wand-simulator works
• UI Layer – Represented by the React components located in src/app/components (with specialized subdirectories for preset menus, wand actions, shared generic components, etc.). The entry point is src/app/App.tsx and public/index.html.
• Calculation / Simulation Engine – The “calc” directory (and its subdirectories such as eval and extra) contains the logic for computing wand behavior, shooting effects, and spell simulation. Treat this as the business logic or simulation module.
• State Management – The Redux components in src/app/redux (slices for wand, presets, configuration, etc.) handle application state, acting as the glue between UI events and the simulation engine.
• Code Generation Scripts – The Python scripts in the scripts/ folder (“generate_gun_actions.py”, “generate_entity_map.py”, “generate_translations.py”) generate parts of the Typescript code (e.g., spell functions, entity mappings, translations) that feed into the simulation engine. Even though these are development utilities, they form an important pre-runtime step.
• Static Public Assets – In the public/ directory, along with manifest and index.html. These are used for the browser deployment and possibly to host static data files (such as UI graphics or data used in the simulation).
• Testing & Utility Functions – The __tests__ directories scattered within the calc and util functions signifying unit tests ensuring calculation accuracy and proper utility function behavior.
• Local Storage – There is a localStorage.ts file, indicating that some state or configuration may be preserved locally between sessions.
Relationships and flows
• The Browser loads the static assets from public/ (index.html, manifest, etc.) to start the React app.
• The App (src/app/App.tsx) bootstraps the UI components, which in turn interact with the Redux store.
• The Redux store (in src/app/redux) receives UI events and triggers changes that can invoke calls to the Calculation Engine.
• The Calculation Engine, composed of various modules in src/app/calc (including eval and extra), processes simulation logic and returns results to the UI for display (such as wand shot results, spell visualizations, etc.).
• The Python scripts serve as pre-build code generators that ensure that parts of the simulation engine (such as gun actions and entity mappings) are kept in sync with the original Lua definitions and external translation CSV files.
• The testing components validate correctness at both the UI and simulation engine levels.
Architectural patterns and design principles
• A clear separation-of-concerns is seen: UI (React Components), Business Logic (Simulation and Calculation), and State Management (Redux).
• Code generation as a pre-processing step is a noteworthy pattern, ensuring that generated code remains synchronized with the original data sources.
• The project uses modular components and organizes them in directories reflecting their purpose (configuration, shot results, wand actions), facilitating clear component reuse.