Custom counter programming - can't override Deck

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?

Ok,
The thing is that a module can have multiple CommandEncoders, and they are searched in order to find one that can Decode a given command. Since you are essentially trying to over-ride the in-built Vassal Command Encoder to handle Deck.ID, you will need to make sure that your Command Encoder is before the BasicCommandEncoder in the buildfile, otherwise the BasicCommandEncoder will always handle Deck.ID and yours will never be seen.
Regards,
Brent.