Sunday, January 24, 2010

Remote Storage, Part II

The remote store is up and running at:

http://bit.ly/wiglaf

The practical effect of this is the ability to create your character on a computer, and load it on your portable device. Character data is automatically synced to the remote store, and can be retrieved using the char->load menu by entering the character name.

At this time (since I'm the only one using it), THERE IS NO OVERWRITE PROTECTION!!! If you create a character named "Bob" and some other dood creates a "Bob", the last guy's data will blow away the Bob data. I have a fix in mind where you enter an owner name to distinguish your Bob the other guy.

Friday, January 15, 2010

Storing data online with CouchDB

I'm looking at using a remote CouchDB as a store for character data. With some sync code, characters should be transparently available on any device you're using.

CouchDB looks cool, but the documentation is horrible (at least for starting out using Javascript).

Something I didn't fully appreciate is that you can't call out to different a server from Javascript directly (this is "cross-site scripting", and there are workarounds). Essentially, it's assumed any connections will be performed on the server side and the client (browser) connects to a single server. The quick-and-dirty solution is to host the Player's Companion from my local CouchDB instance:
  1. Log in to Futon: http://localhost:5984/_utils/index.html

  2. Create a database (charmgr) to host the files

  3. Create a document (id: "charmgr")

  4. Upload all the files as attachments to the document

  5. Go to: http://localhost:5984/charmgr/charmgr/charmgr.html, et voila!


In the code, writing out the data is direct:

var db = new CouchDB(cookie_name.toLowerCase(), {"X-Couch-Full-Commit":"false"});
db.createDb();
db.save(data);


Thanks to Justin Walgran: http://mail-archives.apache.org/mod_mbox/couchdb-user/200812.mbox/%3Cf893e2810812262119k3163421ds372d4b7a2eac22c1@mail.gmail.com%3E

Useful: http://sitr.us/2009/06/30/database-queries-the-couchdb-way.html

Sunday, January 10, 2010

Multi-character Support




Some refactoring and now I can switch between multiple character sheets. Basically names the cookie after the character name, and lists all "named cookies" in the file menu.

Addition of the file menu is something of a failure, since now it's no longer a toaster.