Using Firebird 2.1 and need to update the table using a Random function. It is for a sports sim and there are several factors that need to take place.
Each player has a "potential" value between 1-20 (basically how much they can increase), this will be added to either their Def or Off skill (random which one is increased). It is also based on the player's age.
I will use some examples:
If a player is 18 yrs old and has 14 in Potential and the DEF skill is chosed using random, also if the DEF skill is between 5-10 then something like the code pasted below would be used.
But by implementing this, it would take ages to go through each records in a table filled with 5000+ records. Especially since there are so many different factors. Any better way to achieve this?
Or should I use some kind of "update Spelare set" ? Not sure how to use it with the Random() function though?
if (strtoint(Spelare['Def']) >= 5) and (strtoint((Spelare['Def']) <= 10) then
if (strtoint(Spelare['Potential']) >= 13) and (strtoint((Spelare['Potential']) <= 16) then
if (strtoint(Spelare['Age']) >= 16) and (strtoint((Spelare['Age']) <= 20) then
i := Random(3)
Spelare['Def'] := inttostr(strtoint(Spelare['Def']) + strtoint(inttostr(i));