@@ -428,6 +428,7 @@ def entrance_dependencies(self) -> dict[str, set[int]]:
428428
429429class AtLeast (NestedRule [TWorld ], game = "Archipelago" ):
430430 """A rule that returns true when at least N child rules evaluate as true"""
431+
431432 count : int | FieldResolver
432433
433434 def __init__ (
@@ -452,12 +453,10 @@ def _instantiate(self, world: TWorld) -> Rule.Resolved:
452453 while children_to_process :
453454 child = children_to_process .pop (0 )
454455 if child .always_true :
455- # true always wins
456456 if count == 1 :
457457 return child
458- else :
459- count -= 1
460- continue
458+ count -= 1
459+ continue
461460 if child .always_false :
462461 # falses can be ignored
463462 continue
@@ -471,7 +470,9 @@ def _instantiate(self, world: TWorld) -> Rule.Resolved:
471470 return Or (* self .children , options = self .options , filtered_resolution = self .filtered_resolution ).resolve (world )
472471 if count == len (clauses ):
473472 # Switch to And which has more optimized handling
474- return And (* self .children , options = self .options , filtered_resolution = self .filtered_resolution ).resolve (world )
473+ return And (* self .children , options = self .options , filtered_resolution = self .filtered_resolution ).resolve (
474+ world
475+ )
475476 return AtLeast .Resolved (
476477 tuple (clauses ),
477478 count = count ,
@@ -489,15 +490,15 @@ def _evaluate(self, state: CollectionState) -> bool:
489490 if rule (state ):
490491 if count == 1 :
491492 return True
492- else :
493- count += 1
493+ count -= 1
494494 return False
495495
496496 @override
497497 def explain_json (self , state : CollectionState | None = None ) -> list [JSONMessagePart ]:
498498 messages : list [JSONMessagePart ] = [
499- {"type" : "color" , "color" : "cyan" , "text" : str (self .count )},
500- {"type" : "text" , "text" : f" of (" }
499+ {"type" : "text" , "text" : "At least " },
500+ {"type" : "color" , "color" : "cyan" , "text" : str (self .count )},
501+ {"type" : "text" , "text" : " of (" },
501502 ]
502503 for i , child in enumerate (self .children ):
503504 if i > 0 :
@@ -509,12 +510,12 @@ def explain_json(self, state: CollectionState | None = None) -> list[JSONMessage
509510 @override
510511 def explain_str (self , state : CollectionState | None = None ) -> str :
511512 clauses = ", " .join ([c .explain_str (state ) for c in self .children ])
512- return f"{ self .count } of ({ clauses } )"
513+ return f"At least { self .count } of ({ clauses } )"
513514
514515 @override
515516 def __str__ (self ) -> str :
516517 clauses = ", " .join ([str (c ) for c in self .children ])
517- return f"{ self .count } of ({ clauses } )"
518+ return f"At least { self .count } of ({ clauses } )"
518519
519520
520521@dataclasses .dataclass (init = False )
0 commit comments