Esempio n. 1
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)
Esempio n. 2
0
    def test_choose_option_with_numeric_input(self):
        # Set up
        dogs = ['Boxer', 'Chow', 'Pug']
        original_raw_input = __builtin__.raw_input
        __builtin__.raw_input = lambda _: "1"

        # Invoke
        dog_number = Utils.choose_option("Fave dog?", dogs)

        # Check
        self.assertEqual(1, dog_number)
        __builtin__.raw_input = original_raw_input
Esempio n. 3
0
def choose_ideology():
    """Prompts the user to choose an ideology (returns a 1-indexed number)"""
    descriptions = ["%s: %s" % (i.name(), i.difference()) for i in IDEOLOGIES]
    return Utils.choose_option("Choose Jihadist Ideology", descriptions)