Hi,
I’m trying to create a custom version of the Deck piece collection which automatically shuffles itself once at startup. I’ve got the build.module.DrawPile subclass working fine, and I’ve got a ‘ShuffleableDeck’ subclass which should send a shuffle command after instantiating itself, but I’m having trouble tying this together.
Following the tutorial here, I’ve created a BasicCommandEncoder subclass, and edited the buildFile to use it. The code is simple:
[code]public class ShuffleableFactory extends BasicCommandEncoder {
protected GamePiece createBasic(String type) {
String prefix = type.substring(0,type.indexOf(’;’)+1);
if (prefix.length() == 0) {
prefix = type;
}
if (prefix.equals(Deck.ID)) {
return new ShuffleableDeck(type);
} else {
return super.createBasic(type);
}
}
[/code]
I know my class is being loaded by VASSAL and this code is running, because if I add diagnostic output to the createBasic method it comes out. The problem I have is this: my prefix.equals(Deck.ID) condition is never matched. Am I testing for the prefix wrong? This seems to be the way BasicCommandEncoder does it (passing the prefix to the hash basicFactories.get()). The module’s main map does contain deck pieces! They get loaded correctly - just as Decks rather than ShuffleableDecks.
Does anyone have any ideas about what I might be doing wrong?