Browse Source

allow fewer rounds in tiered generator

Kirk Trombley 3 năm trước cách đây
mục cha
commit
75308d4cee
1 tập tin đã thay đổi với 2 bổ sung4 xóa
  1. 2 4
      server/app/point_gen/__init__.py

+ 2 - 4
server/app/point_gen/__init__.py

@@ -142,9 +142,7 @@ class PointStore:
             if config.generation_method == GenMethodEnum.diff_tiered:
                 # in the case of using the "difficulty tiered" generator there is some special logic
                 # assume that, in general, we want 10 points (4 normal rounds going up in difficulty, 1 max difficulty round, 4 normal going down, 1 nightmare tier)
-                if config.rounds != len(DIFFICULTY_TIER_ORDER):
-                    # TODO would probably be nice to relax this restriction at some point
-                    raise ExhaustedSourceError
+                # if more are requested, it repeats. if less, it only goes that far.
 
                 def make_point_task(tier):
                     country_lock = random.choice(tier)
@@ -155,7 +153,7 @@ class PointStore:
                     else:
                         raise ExhaustedSourceError
 
-                point_tasks = [make_point_task(tier) for tier in DIFFICULTY_TIER_ORDER]
+                point_tasks = [make_point_task(DIFFICULTY_TIER_ORDER[i % len(DIFFICULTY_TIER_ORDER)]) for i in range(config.rounds)]
             else:
                 point_tasks = [self.get_point(config.generation_method, config.country_lock) for _ in range(config.rounds)]
             gathered = asyncio.gather(*point_tasks)