General design advice

I have a town of almost a dozen buildings. Each building has several functions. Some functions are shared among buildings, e.g. buy/sell items. I am trying to decide on the best way to lay this out.

I was planning on making each building an extension, and using common functions as their own extension. For example, in the Emporium, the player can buy/equipment, and in the Inn, the player can buy/sell menu items. Therefore, I was thinking of making a Transactions extension for buying/selling. Each building can be its own extension because it provides specific data, and my main program hooks it all together.

Alternatively, I can make one massive program for all buildings in the city, which seems to be harder to change if the need arises. (I will still have buy/sell as a functional extension.)

Any advice about which is the better way to go?

Organizing your game logic into separate functional units is generally a good idea. Put all the buy-sell code in one section, each building in its own section, sure.

That doesn’t mean you have to make each section a separate file (extension). You can if you want. Or you can put everything in one source file. That’s purely a matter of whether you’re more comfortable navigating one big file or several smaller files.

1 Like

Thanks. I already have the code encapsulated into buildings and functions etc. I don’t mind the extensions because it keeps the functions and data better isolated.