Hi all,
Still working on this RPG game - all chuffing along nicely. I've got a database (Access) with tables of Events (such as what happens when you wear a magic item). The table contains names of properties for the TEntity object (which holds all personal information for a game hero).
The problem is that in my code that's reading these events I have such ugliness as:
where AField is the text retrieved from the database table indicating which property of the TEntity object to adjust.
I have quite a few different classes like this - the TEntity one has over 40 properties that need to be mapped, which is not very nice code. It works, but I would appreciate any advice on restructuring or shortcuts to doing it.
Many thanks!
Still working on this RPG game - all chuffing along nicely. I've got a database (Access) with tables of Events (such as what happens when you wear a magic item). The table contains names of properties for the TEntity object (which holds all personal information for a game hero).
The problem is that in my code that's reading these events I have such ugliness as:
Code:
if AField = 'Gold' then
AEntity.Gold := ....
else if AField = 'Gems' then
AEntity.Gems := ....
else if AField = 'HitPoints' then
AEntity.HitPoints := ...
etc.
etc.
where AField is the text retrieved from the database table indicating which property of the TEntity object to adjust.
I have quite a few different classes like this - the TEntity one has over 40 properties that need to be mapped, which is not very nice code. It works, but I would appreciate any advice on restructuring or shortcuts to doing it.
Many thanks!