Allow attackers of any types, but with a charged move of the specified type

This commit is contained in:
Zoé Cassiopée Gauthier 2024-03-30 23:17:34 -04:00
parent fecb0db7dc
commit 0e3011c406

View File

@ -55,11 +55,12 @@ class Calculator:
f"""SELECT DISTINCT(attacker) FROM estimators WHERE charged_move IN ("{'","'.join(charged_moves)}")""" f"""SELECT DISTINCT(attacker) FROM estimators WHERE charged_move IN ("{'","'.join(charged_moves)}")"""
) )
attackers = {row[0]: {"RAID_LEVEL_3": [], "RAID_LEVEL_5": [], "RAID_LEVEL_MEGA": []} for row in res.fetchall()} attackers = {row[0]: {"RAID_LEVEL_3": [], "RAID_LEVEL_5": [], "RAID_LEVEL_MEGA": []} for row in res.fetchall()}
movesets = {}
defenders = functools.reduce(operator.iconcat, raid_bosses.values(), []) defenders = functools.reduce(operator.iconcat, raid_bosses.values(), [])
res = self.db.execute( res = self.db.execute(
f""" f"""
SELECT e.raid_tier, e.defender, e.attacker, MIN(e.estimator) / m.min_estimator SELECT e.raid_tier, e.defender, e.attacker, e.estimator / m.min_estimator, e.quick_move, e.charged_move
FROM estimators e FROM estimators e
INNER JOIN ( INNER JOIN (
SELECT defender, MIN(estimator) AS min_estimator SELECT defender, MIN(estimator) AS min_estimator
@ -69,12 +70,17 @@ class Calculator:
AND defender IN ("{'","'.join(defenders)}") AND defender IN ("{'","'.join(defenders)}")
GROUP BY defender GROUP BY defender
) AS m ON e.defender = m.defender ) AS m ON e.defender = m.defender
WHERE party = ? AND level = ? AND attacker IN ("{'","'.join(attackers.keys())}") INNER JOIN (
GROUP BY e.defender, e.attacker SELECT defender, attacker, MIN(estimator) as min_estimator
FROM estimators
WHERE party = ? AND level = ? AND charged_move IN ("{'","'.join(charged_moves)}")
GROUP BY defender, attacker
) AS ms ON e.defender = ms.defender AND e.attacker = ms.attacker AND e.estimator = ms.min_estimator
WHERE e.attacker IN ("{'","'.join(attackers.keys())}")
""", """,
(party, party, level), (party, party, level),
) )
for raid_tier, _defender, attacker, estimator in res.fetchall(): for raid_tier, _defender, attacker, estimator, fast_move, charged_move in res.fetchall():
if raid_tier == "RAID_LEVEL_MEGA_5": if raid_tier == "RAID_LEVEL_MEGA_5":
simplified_raid_tier = "RAID_LEVEL_MEGA" simplified_raid_tier = "RAID_LEVEL_MEGA"
elif raid_tier == "RAID_LEVEL_ULTRA_BEAST": elif raid_tier == "RAID_LEVEL_ULTRA_BEAST":
@ -82,6 +88,7 @@ class Calculator:
else: else:
simplified_raid_tier = raid_tier simplified_raid_tier = raid_tier
attackers[attacker][simplified_raid_tier].append(estimator) attackers[attacker][simplified_raid_tier].append(estimator)
movesets[attacker] = (fast_move, charged_move)
ase = {} ase = {}
for attacker, estimators in attackers.items(): for attacker, estimators in attackers.items():
@ -92,7 +99,8 @@ class Calculator:
+ 0.50 * sum(estimators["RAID_LEVEL_5"]) / len(estimators["RAID_LEVEL_5"]) + 0.50 * sum(estimators["RAID_LEVEL_5"]) / len(estimators["RAID_LEVEL_5"])
+ 0.35 * sum(estimators["RAID_LEVEL_MEGA"]) / len(estimators["RAID_LEVEL_MEGA"]) + 0.35 * sum(estimators["RAID_LEVEL_MEGA"]) / len(estimators["RAID_LEVEL_MEGA"])
) )
print(f"{attacker},{ase}") fast_move, charged_move = movesets[attacker]
print(f"{attacker},{ase},{fast_move},{charged_move}")
def _raid_bosses(self): def _raid_bosses(self):
raid_tiers = [] raid_tiers = []
@ -166,7 +174,6 @@ class Calculator:
"includeLegendary": "true", "includeLegendary": "true",
"includeShadow": "true", "includeShadow": "true",
"includeMegas": "true", "includeMegas": "true",
"attackerTypes": self.attacker_types,
"primalAssistants": "", "primalAssistants": "",
"numParty": str(party), "numParty": str(party),
} }