@@ -37,68 +37,39 @@ def testresolve():
3737def test_ranks_all_1v1_possibilities ():
3838 """
3939 Document expectations for all outcomes of 1v1 games.
40- Assumes that the order of teams doesn't matter.
41- With five possible outcomes there are 15 possibilities.
40+ With six possible outcomes there are 36 possibilities.
4241 """
43- team_outcomes = [{ArmyOutcome .VICTORY }, {ArmyOutcome .VICTORY }]
44- with pytest .raises (GameResolutionError ):
45- resolve_game (team_outcomes )
46-
47- team_outcomes = [{ArmyOutcome .VICTORY }, {ArmyOutcome .DEFEAT }]
48- ranks = resolve_game (team_outcomes )
49- assert ranks == [GameOutcome .VICTORY , GameOutcome .DEFEAT ]
50-
51- team_outcomes = [{ArmyOutcome .VICTORY }, {ArmyOutcome .DRAW }]
52- resolve_game (team_outcomes )
53- assert ranks == [GameOutcome .VICTORY , GameOutcome .DEFEAT ]
54-
55- team_outcomes = [{ArmyOutcome .VICTORY }, {ArmyOutcome .UNKNOWN }]
56- ranks = resolve_game (team_outcomes )
57- assert ranks == [GameOutcome .VICTORY , GameOutcome .DEFEAT ]
5842
59- team_outcomes = [{ArmyOutcome .VICTORY }, {ArmyOutcome .CONFLICTING }]
60- ranks = resolve_game (team_outcomes )
61- assert ranks == [GameOutcome .VICTORY , GameOutcome .DEFEAT ]
62-
63- team_outcomes = [{ArmyOutcome .DEFEAT }, {ArmyOutcome .DEFEAT }]
64- ranks = resolve_game (team_outcomes )
65- assert ranks == [GameOutcome .DRAW , GameOutcome .DRAW ]
66-
67- team_outcomes = [{ArmyOutcome .DEFEAT }, {ArmyOutcome .DRAW }]
68- with pytest .raises (GameResolutionError ):
69- resolve_game (team_outcomes )
70-
71- team_outcomes = [{ArmyOutcome .DEFEAT }, {ArmyOutcome .UNKNOWN }]
72- with pytest .raises (GameResolutionError ):
73- resolve_game (team_outcomes )
74-
75- team_outcomes = [{ArmyOutcome .DEFEAT }, {ArmyOutcome .CONFLICTING }]
76- with pytest .raises (GameResolutionError ):
77- resolve_game (team_outcomes )
78-
79- team_outcomes = [{ArmyOutcome .DRAW }, {ArmyOutcome .DRAW }]
80- ranks = resolve_game (team_outcomes )
81- assert ranks == [GameOutcome .DRAW , GameOutcome .DRAW ]
82-
83- team_outcomes = [{ArmyOutcome .DRAW }, {ArmyOutcome .UNKNOWN }]
84- with pytest .raises (GameResolutionError ):
85- resolve_game (team_outcomes )
86-
87- team_outcomes = [{ArmyOutcome .DRAW }, {ArmyOutcome .CONFLICTING }]
88- with pytest .raises (GameResolutionError ):
89- resolve_game (team_outcomes )
90-
91- team_outcomes = [{ArmyOutcome .UNKNOWN }, {ArmyOutcome .UNKNOWN }]
92- with pytest .raises (GameResolutionError ):
93- resolve_game (team_outcomes )
94-
95- team_outcomes = [{ArmyOutcome .UNKNOWN }, {ArmyOutcome .CONFLICTING }]
96- with pytest .raises (GameResolutionError ):
97- resolve_game (team_outcomes )
98-
99- team_outcomes = [{ArmyOutcome .CONFLICTING }, {ArmyOutcome .CONFLICTING }]
100- with pytest .raises (GameResolutionError ):
101- resolve_game (team_outcomes )
43+ ERROR = 0
44+ DRAW = 1
45+ WIN = 2
46+ LOSS = 3
47+ # Victory Defeat Recall Draw Unknown Conflicting
48+ grid = [[ERROR , WIN , WIN , WIN , WIN , WIN ] # Victory
49+ [LOSS , DRAW , DRAW , ERROR , ERROR , ERROR ] # Defeat
50+ [LOSS , DRAW , DRAW , ERROR , ERROR , ERROR ] # Recall
51+ [LOSS , ERROR , ERROR , DRAW , ERROR , ERROR ] # Draw
52+ [LOSS , ERROR , ERROR , ERROR , ERROR , ERROR ] # Unknown
53+ [LOSS , ERROR , ERROR , ERROR , ERROR , ERROR ]] # Conflicting
54+ outcome_list = [ArmyOutcome .VICTORY , ArmyOutcome .DEFEAT , ArmyOutcome .RECALL ,
55+ ArmyOutcome .DRAW , ArmyOutcome .UNKNOWN , ArmyOutcome .CONFLICTING ]
56+
57+ win_resolution = [GameOutcome .VICTORY , GameOutcome .DEFEAT ]
58+ draw_resolution = [GameOutcome .DRAW , GameOutcome .DRAW ]
59+ loss_resolution = [GameOutcome .DEFEAT , GameOutcome .VICTORY ]
60+
61+ for outcome1 , row in grid :
62+ for outcome2 , resolution in row :
63+ team_outcomes = [{outcome_list [outcome1 ]}, {outcome_list [outcome2 ]}]
64+ if resolution == ERROR :
65+ with pytest .raises (GameResolutionError ):
66+ resolve_game (team_outcomes )
67+ elif resolution == WIN :
68+ assert resolve_game (team_outcomes ) == win_resolution
69+ elif resolution == DRAW :
70+ assert resolve_game (team_outcomes ) == draw_resolution
71+ elif resolution == LOSS :
72+ assert resolve_game (team_outcomes ) == loss_resolution
10273
10374
10475def test_team_outcome_ignores_unknown ():
0 commit comments