Roast my codebase!

Hiya folks, apologies if the category is wrong there were a couple I could have gone for,

So round the beginning of last year I got working on the prototype for my games then latest design iteration but real life got in the way and it fell to the wayside, however I am now ready to start coding again,

This will be a new repo as a lot has changed design wise but it seems both fun and hopefully profitable to offer the last one up for review so any kind defold experts can rip it to shreds (I know I got lazy in places :wink: ), any feedback for improvements on the general patterns and the like would be deeply appreciated,

https://github.com/mohaynes97/plundered-empire-2023

I know this is a sizeable ask so thank you kindly in advance for any who partake,

1 Like

Wow, I only briefly browsed the repo and it is not a small project. The fact that you’ve managed to put something together is not a small project of only a few files is an indication that you seem to have found a structure that works for you. Well done!

One thing which I noticed is that you have some global variable declarations which I believe should be local. Example, items.lua:

local function generate_rarity()
	random = math.random(1, 100)
local function generate_modifiers(ilvl, subtype, attunement)
	local rarity = generate_rarity()
	modifiers = {}

And so on. I’m thinking that random and modifiers and some others should be local.

There are also required which are set as globals, while in otherwise required to local variables.

Are you using a code linter of some kind? You can use the one in VS Code or the Defold LSP server to detect such issues.

2 Likes