- def new_game(cls, deck,
- initial_bits=PLAYER_DEFAULTS.INITIAL_BITS,
- initial_pos=PLAYER_DEFAULTS.INITIAL_POS,
- max_health=PLAYER_DEFAULTS.MAX_HEALTH,
- wins_required=PLAYER_DEFAULTS.WINS_REQUIRED):
+ def new_game(cls, deck, initial_bits=None, initial_pos=None,
+ max_health=None, wins_required=None):
+
+ defaults = {
+ 'initial_bits': PLAYER_DEFAULTS.INITIAL_BITS,
+ 'initial_pos': PLAYER_DEFAULTS.INITIAL_POS,
+ 'max_health': PLAYER_DEFAULTS.MAX_HEALTH,
+ 'wins_required': PLAYER_DEFAULTS.WINS_REQUIRED,
+ }
+
+ deck_defaults = deck.get('defaults', {})
+ for k, v in deck_defaults.iteritems():
+ if isinstance(v, list):
+ deck_defaults[k] = tuple(v)
+ defaults.update(deck_defaults)
+
+ if initial_bits is None:
+ initial_bits = defaults['initial_bits']
+ if initial_pos is None:
+ initial_pos = defaults['initial_pos']
+ if max_health is None:
+ max_health = defaults['max_health']
+ if wins_required is None:
+ wins_required = defaults['wins_required']
+
+ assert wins_required + max_health == 8
+
+ # Overriden by command line