[LIST=1][*]Calucale the reward grade in only one line of code (and two nested SQL queries):
Code:
fetchRewardGradeFromDataServer(ListOfDonationItems){
Connection = ConnectToDataServer;
QUeryResult = Connection.ExecuteSQLQueryforRewardGrade(ListOfDonationItems, RNG.getRngFactor);
Numeric grade = QueryResult.getRewardGrade;
Numeric delay = QueryResult.getDelayTime;
}
While the SQL code would look something like:
Code:
SELECT reward_grade, delay_time
FROM reward_grade_table,
(SELECT SUM(item_value) donation_value
FROM LOOP list_of_donation_items
(SELECT item_value
FROM donation_items_table
WHERE item_name = donation_item_name)
)
WHERE grade_min_value <= (donation_value + rng_factor)
AND grade_max_value >= (donation_value + rng_factor)
After that, once the time is over and we click on the recieve button,
we'd send the reward grade to the server, and it would:
- Get a random number from RNG
- Ask the Data Server for the rewards for a certain grade and a certain random index
- Return the rewards to us
Once again, such a thing could be done with a simple piece of code and an even simpler SQL query to a table of tuples
(reward_grade, random_offset, list_of_reward_items).