@@ -98,47 +98,50 @@ def test_aux_data_validation(filename: str):
98
98
99
99
100
100
@pytest .mark .parametrize (
101
- 'expression,inventory,expected_result' ,
101
+ 'expression,inventory,flags, expected_result' ,
102
102
[
103
103
# fmt: off
104
104
# Test basic expressions
105
- ('item Boomerang' , ['boomerang' , 'sword' ], True ),
106
- ('item Boomerang' , ['sword' ], False ),
105
+ ('item Boomerang' , ['boomerang' , 'sword' ], {}, True ),
106
+ ('item Boomerang' , ['sword' ], {}, False ),
107
107
# Test expressions with basic logic operators
108
- ('item Boomerang & item Bombs' , ['boomerang' , 'bombs' ], True ),
109
- ('item Boomerang & item Bombs' , ['boomerang' , 'sword' ], False ),
110
- ('item Boomerang & item Bombs' , ['bombs' ], False ),
111
- ('item Boomerang & item Bombs' , [], False ),
112
- ('item Boomerang | item Bombs' , ['boomerang' , 'bombs' ], True ),
113
- ('item Boomerang | item Bombs' , ['boomerang' , 'sword' ], True ),
114
- ('item Boomerang | item Bombs' , ['bombs' ], True ),
115
- ('item Boomerang | item Bombs' , ['sword' ], False ),
108
+ ('item Boomerang & item Bombs' , ['boomerang' , 'bombs' ], {}, True ),
109
+ ('item Boomerang & item Bombs' , ['boomerang' , 'sword' ], {}, False ),
110
+ ('item Boomerang & item Bombs' , ['bombs' ], {}, False ),
111
+ ('item Boomerang & item Bombs' , [], {}, False ),
112
+ ('item Boomerang | item Bombs' , ['boomerang' , 'bombs' ], {}, True ),
113
+ ('item Boomerang | item Bombs' , ['boomerang' , 'sword' ], {}, True ),
114
+ ('item Boomerang | item Bombs' , ['bombs' ], {}, True ),
115
+ ('item Boomerang | item Bombs' , ['sword' ], {}, False ),
116
+ ('item Boomerang | flag BridgeRepaired' , ['bombs' ], {'bridge_repaired' }, True ),
117
+ ('item Boomerang | flag BridgeRepaired' , [], {'bridge_repaired' }, True ),
118
+ ('item Boomerang | flag BridgeRepaired' , ['bombs' ], {}, False ),
116
119
# Test nested expressions
117
- ('item Boomerang & (item Bombs | item Bombchus)' , ['boomerang' , 'bombs' , 'bombchus' ], True ),
118
- ('item Boomerang & (item Bombs | item Bombchus | item Hammer)' , ['boomerang' , 'bombchus' ], True ), # noqa: E501
119
- ('item Boomerang & (item Bombs | item Bombchus)' , ['boomerang' , 'bombs' ], True ),
120
- ('item Boomerang & (item Bombs | item Bombchus)' , ['bombs' , 'bombchus' ], False ),
121
- ('item Boomerang & (item Bombs | item Bombchus)' , ['boomerang' , 'sword' ], False ),
122
- ('item Bombchus | item Bombs' , ['bombs' , 'bombchus' , 'cannon' ], True ),
123
- ('item Bombchus | item Bombs' , ['bombs' , 'boomerang' , 'cannon' ], True ),
124
- ('item Bombchus | item Bombs' , ['bombchus' , 'boomerang' , 'cannon' ], True ),
125
- ('item Bombchus | item Bombs' , ['boomerang' , 'cannon' , 'sword' ], False ),
126
- ('item Bombchus | item Bombs | item Sword' , ['boomerang' , 'cannon' , 'sword' ], True ),
120
+ ('item Boomerang & (item Bombs | item Bombchus)' , ['boomerang' , 'bombs' , 'bombchus' ], {}, True ),
121
+ ('item Boomerang & (item Bombs | item Bombchus | item Hammer)' , ['boomerang' , 'bombchus' ], {}, True ), # noqa: E501
122
+ ('item Boomerang & (item Bombs | item Bombchus)' , ['boomerang' , 'bombs' ], {}, True ),
123
+ ('item Boomerang & (item Bombs | item Bombchus)' , ['bombs' , 'bombchus' ], {}, False ),
124
+ ('item Boomerang & (item Bombs | item Bombchus)' , ['boomerang' , 'sword' ], {}, False ),
125
+ ('item Bombchus | item Bombs' , ['bombs' , 'bombchus' , 'cannon' ], {}, True ),
126
+ ('item Bombchus | item Bombs' , ['bombs' , 'boomerang' , 'cannon' ], {}, True ),
127
+ ('item Bombchus | item Bombs' , ['bombchus' , 'boomerang' , 'cannon' ], {}, True ),
128
+ ('item Bombchus | item Bombs' , ['boomerang' , 'cannon' , 'sword' ], {}, False ),
129
+ ('item Bombchus | item Bombs | item Sword' , ['boomerang' , 'cannon' , 'sword' ], {}, True ),
127
130
# Test more complex nested expressions
128
- ('item Boomerang & ((item Bombs | item Bombchus) | (item GrapplingHook & item Bow))' , ['bombs' ], False ), # noqa: E501
129
- ('item Boomerang & ((item Bombs | item Bombchus) | (item GrapplingHook & item Bow))' , ['boomerang' , 'bombs' ], True ), # noqa: E501
130
- ('item Boomerang & ((item Bombs | item Bombchus) | (item GrapplingHook & item Bow))' , ['boomerang' , 'bombchus' ], True ), # noqa: E501
131
- ('item Boomerang & ((item Bombs | item Bombchus) | (item GrapplingHook & item Bow))' , ['boomerang' , 'grappling_hook' ], False ), # noqa: E501
132
- ('item Boomerang & ((item Bombs | item Bombchus) | (item GrapplingHook & item Bow))' , ['boomerang' , 'bow' ], False ), # noqa: E501
133
- ('item Boomerang & ((item Bombs | item Bombchus) | (item GrapplingHook & item Bow))' , ['boomerang' , 'grappling_hook' , 'bow' ], True ), # noqa: E501
131
+ ('item Boomerang & ((item Bombs | item Bombchus) | (item GrapplingHook & item Bow))' , ['bombs' ], {}, False ), # noqa: E501
132
+ ('item Boomerang & ((item Bombs | item Bombchus) | (item GrapplingHook & item Bow))' , ['boomerang' , 'bombs' ], {}, True ), # noqa: E501
133
+ ('item Boomerang & ((item Bombs | item Bombchus) | (item GrapplingHook & item Bow))' , ['boomerang' , 'bombchus' ], {}, True ), # noqa: E501
134
+ ('item Boomerang & ((item Bombs | item Bombchus) | (item GrapplingHook & item Bow))' , ['boomerang' , 'grappling_hook' ], {}, False ), # noqa: E501
135
+ ('item Boomerang & ((item Bombs | item Bombchus) | (item GrapplingHook & item Bow))' , ['boomerang' , 'bow' ], {}, False ), # noqa: E501
136
+ ('item Boomerang & ((item Bombs | item Bombchus) | (item GrapplingHook & item Bow))' , ['boomerang' , 'grappling_hook' , 'bow' ], {}, True ), # noqa: E501
134
137
# Test expression with a lot of redundant parentheses, which shouldn't affect results
135
138
# other than additional performance overhead.
136
- ('(((((item Sword | ((item Shield)))))))' , ['sword' ], True ),
139
+ ('(((((item Sword | ((item Shield)))))))' , ['sword' ], {}, True ),
137
140
# fmt: on
138
141
],
139
142
)
140
- def test_edge_parser (expression : str , inventory : list [str ], expected_result : bool ):
143
+ def test_edge_parser (expression : str , inventory : list [str ], flags : set [ str ], expected_result : bool ):
141
144
assert (
142
- Edge (Node ('test1' , []), Node ('test2' , []), expression ).is_traversable (inventory )
145
+ Edge (Node ('test1' , []), Node ('test2' , []), expression ).is_traversable (inventory , flags )
143
146
== expected_result
144
147
)
0 commit comments