def test_criteria_not_run_returns_not_run():
    number_of_chances = 1
    required_value = 1
    is_odd = True

    test_criteria = OddEvenValueCriterion(number_of_chances, required_value,
                                          is_odd)

    assert (test_criteria.criteria_state() == "not run")
def test_player_thrown_odd_is_pass_over_multiple_throws():
    number_of_chances = 5
    required_value = 3
    is_odd = True

    test_criteria = OddEvenValueCriterion(number_of_chances, required_value,
                                          is_odd)

    rolls = [1, 4, 6, 5, 3]

    test_game_state = GameState()
    test_game_state.set_rolls(rolls)
    console_input = ConsoleInput()

    test_criteria.execute(test_game_state, console_input)
    assert (test_criteria.criteria_state() == "True")
def test_player_thrown_even_is_pass():
    number_of_chances = 1
    required_value = 1
    is_odd = False

    test_criteria = OddEvenValueCriterion(number_of_chances, required_value,
                                          is_odd)

    rolls = [2]

    test_game_state = GameState()
    test_game_state.set_rolls(rolls)
    console_input = ConsoleInput()

    test_criteria.execute(test_game_state, console_input)
    assert (test_criteria.criteria_state() == "True")
Exemple #4
0
 def add_odd_even_criteria(self, criterion):
     """Add the odd even criteria for evaluation.
     Args:
         criterion (dict): The criterion
     """
     self._evaluator.add_criteria(
         criterion["name"],
         OddEvenValueCriterion(
             criterion["number_of_chances"],
             criterion["required_value"],
             criterion["is_odd"],
         ),
     )
     if self._required_rolls < int(criterion["number_of_chances"]):
         self._required_rolls = criterion["number_of_chances"]