The MMO Project Part 16: Bags of loot

The MMO Project Part 16: Bags of loot

Since the whiteboard is still on it's way I am sitting here with 4 sheets of paper working out the Inventory. Currently I am writing the C++ wrapper for the inventory which should be fairly straightforward insofar as it's just taking the code from the character wrapper and rewriting the SQL statements. The only difference is the output is actually going to be a JSON string instead of a CSV string.

I sat down at 8:30 today and started turning my notes from the last few days into a useful plan/scaffold. Pleasantly surprised by my little gecko buds coming out to greet me. Which means (potentially) my boys are more active when it's warmer vs the girls who seem to be more active when it is colder (I'll have to check Mantilogs and cross reference their activities with the temperatures Jake has stored). I had run a secondary heat wire for them to double their heating last night and now I see my boys coming out again. So it is likely I was right in thinking their heat wasn't enough. Now I need to add some insulation to their setup to make it less expensive to run.

Anyway, back to writing this wrapper and doing some testing with it, then I gotta integrate it into the server. Hopefully the whiteboard appears today and I can get a better overview scribbled out on there to work from rather than papers all over my desk.

Oh crap, lunch.

Testing Create
First part of the inventory wrapper is in.

Updates also work, though I need to remember to use Escapes for the "s in the command.

Updated and set the number of Apples to 8. Yes, that ID is for Apples. The test item.

Now I just need to test the Read part of the wrapper.

No newline, don't need one. Anyway it works.

Had to stop and work on a heat cable issue there for a minute. Ordered a backup cable too, in case. RIP wallet.

Switching the Lofi back on and getting back to work now.

This loser decided to come pass out in my lap while I work.

Alright, there's Inventory Update wired up. I think? There will need to be more testing of course but I can now update it whenever the player uses, drops or picks up an item. There is no representation in the client for any of this yet but the server and DB can track it fine and persist it.

It's garbage and slow but it'll do the job until I get the GDNative stuff worked out.

	var inventory_string = "{"
	var inventory_size = inventory.size()
	for k in inventory.keys():
		inventory_string += "\\\"" + str(k) + "\\\":" + str(inventory[k])
		if inventory_size > 1:
			inventory_string += ","
		inventory_size -=1	
	inventory_string += "}"

The "\\\"" is a mass of escape characters. This is a CLI so "s are read as "All this stuff in here is one item, Spaces and New lines are part of this." So you need to escape them in the command as well as in the string. Ugly, does the job. There's a lot I could probably do to make this better and faster but it will be refactored into a GDNative addon later so it's not terribly important to me to do all that.

Next up I need to create Items as objects in the server. I will not make them drop on the ground for now and will instead use Kromdibular to distribute them. Dropping them on the ground will require the server side maps to be in, as a map is responsible for knowing what items are on it.

I also need to create an inventory interface in the client. This will take some thinking. Most of that paperwork was just for getting the wrapper and DB models worked out. TO THE PAPER!

Basic UI for Inventory.

I have yet to send the inventory to the client. Should maybe do that, eh? Possibly as part of CharacterData. But I am also designing how the UI will work. Bah, too many things at once.

Well, it's getting too dark in the office to see now at nearly 5pm. I will have to finish this (hopefully) tomorrow. I wrote down a bunch of thoughts on how the server should handle inventory and items. Wrote out how the client and server will communicate about items and inventory and am going to make my commits for the day.