We set defaults in new_game() don't pass parameters that aren't needed
[naja.git] / naja / options.py
index efde88c5aec21d1044bdc03a53c2f5acc2a364ab..498a979d8ecae6299cbf4d5d280b89bd6bfb2a46 100644 (file)
@@ -13,9 +13,9 @@ def load_game(parser, slot_num):
     '''
     Load a save game and store it in parser.values.game_state.
     '''
+    from naja.scenes.load_save import SaveGameSlot
     if not (0 <= slot_num <= 7):
         parser.error("--load accepts a slot number from 0 to 7.")
-    from naja.scenes.load_save import SaveGameSlot
     state = SaveGameSlot(slot_num).load()
     if state is None:
         raise parser.error(
@@ -28,8 +28,14 @@ def load_deck(parser, deck):
     Create a new game for a specific deck  and store it in
     parser.values.game_state.
     '''
-    raise optparse.OptionalValueError(
-        "Deck loading not implemented.")
+    from naja.gamestate import GameState
+    try:
+        state = GameState.new(deck=deck)
+    except:
+        if options.debug:
+            raise
+        parser.error("Could not load deck %r" % (deck,))
+    options.game_state = state
 
 
 def parse_args(args):
@@ -55,16 +61,20 @@ def parse_args(args):
     parser.add_option("--save-location", default=_get_default_save_location(),
                       dest="save_location", help="Saved game location")
 
+    parser.add_option('--deck', default=None,
+                      help='Start with a new game for a specific deck'
+                      ' (bypassing the menu).')
+
+    parser.add_option('--load', default=None, type=int,
+                      help='Start with a specific save game loaded'
+                      ' (bypassing the menu). Slot values are 0-7.')
+
     if options.debug:
         parser.add_option('--initial-bits', type=int,
                           help='Initial player bits')
         parser.add_option('--cheat-enabled', default=False,
                           action='store_true',
                           help='For those too lazy to type the KONAMI code')
-        parser.add_option('--deck', default=None,
-                          help='Start with a new game for a specific deck')
-        parser.add_option('--load', default=None, type=int,
-                          help='Start with a specific save game loaded (0-7)')
 
     opts, _ = parser.parse_args(args)