+def check_min_max(option, value, min_value, max_value):
+ '''
+ Check value lies between min and max and raise OptionValueError if it does
+ not.
+ '''
+ if not (min_value <= value <= max_value):
+ raise optparse.OptionValueError(
+ "Value of %s should be between %s and %s but got: %r"
+ % (option.dest, min, max, value))
+
+
+def load_game(option, opt_str, value, parser):
+ '''
+ Load a save game and store it in parser.values.game_state.
+ '''
+ check_min_max(option, value, 0, 7)
+ # madness takes its toll ...
+ options.save_location = parser.values.save_location
+ from naja.scenes.load_save import SaveGameSlot
+ state = SaveGameSlot(value).load()
+ if state is None:
+ raise optparse.OptionValueError(
+ "Could not load game from slot %s" % (value,))
+ parser.values.game_state = state
+
+
+def load_deck(option, opt_str, value, parser):
+ '''
+ Create a new game for a specific deck and store it in
+ parser.values.game_state.
+ '''
+ raise optparse.OptionalValueError(
+ "Deck loading not implemented.")
+
+