2011-11-20
2011-11-20
Zero Percent Game Dev - Yayyy! I'm not broken.
So the goal is to insert the earned items into the item table, but that could happen two different ways. The item table has a unique row for every item for every player, but they aren't initialized to zero on character creation because some day there might be thousands of items (or at least I want to do this right and learn how to write code that scales well). Many players might never get certain items, so why bother storing lists in the database for items they have zero of?
So if the player already has a number of that item, the code needs only to increase the quantity field by the amount earned. But if not, the entire row has to be written from scratch.
So I need to write a query to find out which items exist, and then write two potential queries to make the necessary changes to the database (which possibly both have to run), and I need to do this for a bunch of players at once.
The delay here, and the reason I've written and re-written it, is because I am unsatisfied with my results and I feel that there is a better way to go about doing this.