示例#1
0
def main():
    """The main function that runs the game"""
    print ""
    print "Labyrinth: The War on Terror AI Player"
    print ""
    print "Release", RELEASE
    print ""
    saver = Saver()
    saver.new_session()

    # Ask user if they want to continue previous game
    if saver.suspended_game_exists() and Utils.getUserYesNoResponse(
            "Resume suspended game?"):
        app = saver.load_suspend_file()
    else:
        app = _create_game()
        saver.save_turn_file(app, 0)

    command = Command(app, saver)

    while True:
        command.cmdloop()
        # The user has quit, or wants to undo or rollback; prevents
        # issues dealing with save/reloading within class instance.
        if app.undo:
            print "Undo to last turn"
            app = saver.load_undo_file()
        elif app.roll_turn >= 0:
            print "Rolling back to turn " + str(app.roll_turn)
            app = saver.load_turn_file(app.roll_turn)
            if not app:
                break
        else:
            break
示例#2
0
def _create_game():
    """Factory function for a new game"""
    print ""
    scenario_number = Utils.choose_option("Choose Scenario", scenario_names())
    print ""
    ideology_number = choose_ideology()
    print ""
    ai_rolls = Utils.getUserYesNoResponse(
        "Do you want the program to roll dice for you?")
    return Labyrinth(scenario_number, ideology_number, ai_rolls=ai_rolls)
示例#3
0
 def do_quit(self, _):
     """Quits the game and prompts you to save."""
     if Utils.getUserYesNoResponse("Save the game?"):
         print "Saving suspend file."
         self.saver.save_suspend_file(self.app)
     print "Exiting."