From: Simon Cross Date: Sat, 17 May 2014 11:39:23 +0000 (+0200) Subject: Add deck loading. X-Git-Tag: 0.1~120 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=5cb3715ac847166eafc970819160792351dee952;p=naja.git Add deck loading. --- diff --git a/naja/options.py b/naja/options.py index efde88c..dd3e69d 100644 --- a/naja/options.py +++ b/naja/options.py @@ -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,12 @@ 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, max_health=4, wins_required=4) + except: + parser.error("Could not load deck %r" % (deck,)) + options.game_state = state def parse_args(args):