Пример #1
0
def test_player_not_thrown_enough_is_fail():
    number_of_chances = 1
    required_value = 10

    test_criteria = GreaterThanCriterion(number_of_chances, required_value)

    rolls = [1]

    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() == "False")
Пример #2
0
def test_player_thrown_enough__over_multiple_rolls_is_pass():
    number_of_chances = 3
    required_value = 4

    test_criteria = GreaterThanCriterion(number_of_chances, required_value)

    rolls = [1, 2, 5]

    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")
Пример #3
0
def test_player_thrown_exact_is_pass():
    number_of_chances = 1
    required_value = 3

    test_criteria = ExactMatchCriterion(number_of_chances, required_value)

    rolls = [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_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")
Пример #6
0
def test_player_thrown_in_bounds_over_multiple_rolls_is_pass():
    number_of_chances = 3
    required_value = 4
    boundary_offset = 1

    test_criteria = BoundedMatchCriterion(number_of_chances, required_value,
                                          boundary_offset)

    rolls = [1, 2, 5]

    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")
Пример #7
0
def test_player_not_thrown_in_bounds_is_fail():
    number_of_chances = 1
    required_value = 4
    boundary_offset = 1

    test_criteria = BoundedMatchCriterion(number_of_chances, required_value,
                                          boundary_offset)

    rolls = [1]

    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() == "False")
Пример #8
0
def generate_game_state(number_of_rolls):
    player_items = get_player_items()

    player_rolls = get_player_rolls(number_of_rolls)

    game_state = GameState()
    game_state.set_items(player_items)
    game_state.set_rolls(player_rolls)
    return game_state