Implement endgame command, unify encoding in JSONPacket class.