Hi, I’ve been working on a game with a custom Tool class for the past couple of months. Every instance of this class stores information on its in-store price, its store icon, etc. but it also manages its behaviour when equipped.
I feel this isn’t right, especially as the “lobby” and “in-game” areas are in different places. This means when preparing the shop in the lobby the Tool is loading modules generally only needed when in a round.
Should I have two separate classes for every Tool - one for the physical tool in-game which manages behaviour and one for a Tool listing which stores data? Or maybe all this data (price, icon, etc.) can all be stored in one database module script with a ToolDataRetriever (for example) module to retrieve data for a Tool given its name.
How would you structure your code in this instance? Thanks!
Sorry if I misunderstood since I’m much better with visuals for this kind of thing but how I’d usually do something like that is I would use a module with information on a tool (like the Name, Description, Cost, SellPrice, etc) so the client and server can both access it if they ever need to and then the behavior of the tool should run in a separate script, usually 1 copy of the script for each tool ‘type’ on the server where it is moved into the tool as needed. If there’s any configuration settings (behavior-wise, let’s say if you want a weapon to do a poisoning effect) for this specific tool you can always add them into the configuration module that is unique to each tool, then the script can alter behavior depending on that information.