I’m starting to design a basic php game, with some properties which can be upgrated over the time.
I’m wondering what is the best way to implement it (and the database as well)
I was think of something like this:
PlayerID | Property1 | Property1_isUpdating(bool) | Property1_Timeout(date)
but I have to create 2 extra fields per player’s attribute.
Or I could just use a date as a timeout, and when the player connects, I check and update what I need.. but it doesn’t seem to be good either.
I’m almost sure there is “one good way” to do it.. (and almost sure it isn’t those mentioned before)
Thank you for your help
I would do this:
This gives you the option to have multiple upgrade paths as well. Each game tick, go through your buildings where
UpgradingTo <> NULL AND UpgradeComplateAt < currentTime()and setPropertyId = UpgradingToandUpgradingTo = null. You can optionally reset UpgradeCompleteAt, but it might be a useful mechanic to keep it. For example “You can only upgrade property X to property Y if it has been X for at least 3 days” would add an interesting element.*Note if you don’t have a game tick, I’d make one. It’s essentially something that loops every X amount of time, could be every 0.1 seconds, could be every minute.