Inventories are easier than I thought

So today’s efforts focused on integrating code written, believe it or not, last October, with the character object.  This code was for the ordered inventory of items.  Remember:  items are anything added to a character, from spells to complex forms to guns to racials.  And, it was this last set of items that provided the first test of the Inventory object written last October.

It didn’t go well.  After about 45 minutes of debugging that code, I scrapped it, rewrote the whole damn thing so that (a) it uses the Iterator interface in PHP to make searching and printing easier and (b) it was based on an encapsulated, inner array rather than a linked list of items.  This makes implementation easier, but requires that the list be sorted after every addition.

Time will tell if that creates too much overhead during use.  If so, the answer might simply be to generate the alphabetical inventory when it’s requested that we do so (i.e. when printing the character) but I suspect that for gear listings within the app, having a list that’s already in order will facilitate fast call and response from the server.

I also re-wrote the routines that set priorities and priority options (e.g. what metatype the character is) so that they could be called to both set and reset these choices.  Previously, this was done outside the character object and that was a fairly foolish thing for me to have done.

To do:

Comments are closed.