I have two programs. Mine and VASSAL. I want to get data (state info) out of VASSAL and into my program.
Are there any extensions that do things like export CSV or XML files?
I can code in Java. What should I look at to add this functionality as an extension?
It can definitely be done if you write a Custom Class (in other words, Java). But I don’t know of anyone who has done it before so you’ll be blazing some new territory.
The first step would be pulling down the Vassal source code and get it compiling on your computer – see the Wiki for some articles on getting “git” set up (so you can pull down the source code), and then I think there’s stuff about how to get your development environment set up (I think we’re currently recommending IntelliJ if you don’t already have a favorite).
Then you’d need to learn how to override VASSAL classes with your own custom classes. There’s a “Coding Tutorial” in there somewhere (and ZapWars in the module section is related to that) which attempts to walk you some of the basics. You’d be looking for some good place to override a Vassal class with your own, so that you’d have an insertion point for you code. The code would have full access to the game state data by calling into Vassal methods, and could then write out whatever you want to a file (and/or read it in from a file). I guess the Deck trait even already has a thing to read/write hands of cards to and from text files, so you could take a peek in there.
I’m not saying it’s easy, but it’s possible if you’ve got some Java chops
I don’t know that much about internals but I would look at how savegames are written, then hook into that process and write your own serializer.
Thus spake tinjaw via messages:
I have two programs. Mine and VASSAL. I want to get data (state info)
out of VASSAL and into my program.
You’ll find this far, far easier in VASSAL 4, when we’ll have human-
readable files defining modules, logs, and saves. It’s going to be hard
going dealing with the quasi-binary format VASSAL 3 uses.
- Are there any extensions that do things like export CSV or XML files?
Converting existing files to the new format will be close to the top of
my list when V4 development gets moving, so you might be able to take
advantage of that.
On another thought, this would actually be a very interesting addon.
I would very much like to write an AI for some of the games I play with Vassal, for various reasons. Would like a faster response time instead of waiting for days for the response email, have a strong opponent to learn from, have an opponent at all (still can’t find a reliable one for one of my games). Vassal already offers the GUI but I’d need the raw data to feed into the AI.
The current format may be ugly, but it should be possible and not too complicated to hook into the savegame writing functionality and write out a “second savegame” in another format, one that can be read by other tools like json. I think the data would need to be schema-free though so CSV is out of the question, except if someone was interested in coming up with a DB model in 2nd/3rd normal form that would work for every boardgame.