Update Healer Man server
This commit is contained in:
1 parent
1fedb9368d
commit
cc3b2fa4d5
27 files changed
+1988
-83
No files matched your search
+34
-7
@@ -166,9 +166,7 @@ def random_party(builds: Sequence[dict[str, Any]], seed: int) -> list[dict[str,
|
||||
generator = random.Random(seed)
|
||||
# Named alternatives remain directly selectable and are covered by "all",
|
||||
# but ordinary random/filler seats should use the declared default profile.
|
||||
defaults = [build for build in builds if build.get("defaultTalentBuild")]
|
||||
if defaults:
|
||||
builds = defaults
|
||||
builds = random_party_builds(builds)
|
||||
by_role: dict[str, list[dict[str, Any]]] = defaultdict(list)
|
||||
for build in builds:
|
||||
by_role[build["role"]].append(build)
|
||||
@@ -178,6 +176,21 @@ def random_party(builds: Sequence[dict[str, Any]], seed: int) -> list[dict[str,
|
||||
return [generator.choice(by_role["tank"]), generator.choice(by_role["healer"]), *damage]
|
||||
|
||||
|
||||
def random_party_builds(builds: Sequence[dict[str, Any]]) -> list[dict[str, Any]]:
|
||||
defaults = [build for build in builds if build.get("defaultTalentBuild")]
|
||||
return defaults or list(builds)
|
||||
|
||||
|
||||
def random_party_capacity(builds: Sequence[dict[str, Any]]) -> int:
|
||||
"""Return the number of unique 1/1/3 compositions in the random pool."""
|
||||
by_role: dict[str, int] = defaultdict(int)
|
||||
for build in random_party_builds(builds):
|
||||
by_role[build["role"]] += 1
|
||||
if not by_role["tank"] or not by_role["healer"] or by_role["damage"] < 3:
|
||||
return 0
|
||||
return by_role["tank"] * by_role["healer"] * math.comb(by_role["damage"], 3)
|
||||
|
||||
|
||||
def readiness_eligible_builds(
|
||||
builds: Sequence[dict[str, Any]],
|
||||
policy: dict[str, Any] | None,
|
||||
@@ -209,14 +222,28 @@ def automatic_parties(
|
||||
configurations: list[dict[str, Any]] = []
|
||||
for source in sources:
|
||||
source_builds = [build for build in builds if build["source"] == source]
|
||||
capacity = random_party_capacity(source_builds)
|
||||
if capacity < 1:
|
||||
raise SystemExit(
|
||||
f"The {source} eligible pool does not expose enough tank, healer, and damage builds "
|
||||
"for a 1/1/3 party."
|
||||
)
|
||||
target_configurations = min(configurations_per_source, capacity)
|
||||
if target_configurations < configurations_per_source:
|
||||
print(
|
||||
f"[balance-lab] {source} eligible pool has {capacity} unique party "
|
||||
f"configuration{'s' if capacity != 1 else ''}; running each once instead of "
|
||||
f"duplicating {configurations_per_source - capacity} identical parties.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
seen: set[tuple[str, str, tuple[str, ...]]] = set()
|
||||
attempts = 0
|
||||
while len(seen) < configurations_per_source:
|
||||
while len(seen) < target_configurations:
|
||||
attempts += 1
|
||||
if attempts > max(1_000, configurations_per_source * 100):
|
||||
if attempts > max(1_000, target_configurations * 100):
|
||||
raise SystemExit(
|
||||
f"Could not generate {configurations_per_source} unique {source} parties. "
|
||||
"Request fewer party configurations."
|
||||
f"Could not generate {target_configurations} unique {source} parties from a "
|
||||
f"calculated capacity of {capacity}."
|
||||
)
|
||||
party = random_party(source_builds, seed + offsets[source] + attempts - 1)
|
||||
signature = (party[0]["id"], party[1]["id"], tuple(sorted(member["id"] for member in party[2:])))
|
||||
|
||||
Reference in new issue
Block a user