11import itertools
2+ import json
23import logging
34import os
45import typing
@@ -66,8 +67,9 @@ def get_available_secondary_stats(self, data_dict: dict) -> int:
6667 generate_html = self .settings .html ,
6768 )
6869 simulation .simc_arguments .append ("# not-a-real-apl" )
70+ simulation .simc_arguments .append ("actions=snapshot_stats" )
6971 # actions=auto_attack
70- simulation .simc_arguments .append ("actions= auto_attack" )
72+ simulation .simc_arguments .append ("actions+=/ auto_attack" )
7173
7274 try :
7375 simulation .simulate ()
@@ -79,22 +81,37 @@ def get_available_secondary_stats(self, data_dict: dict) -> int:
7981 else :
8082 raise e
8183
82- stats = 0
83- for stat in rating_names :
84- if simulation .json_data :
85- try :
86- stats += simulation .json_data ["sim" ]["players" ][0 ][
87- "collected_data"
88- ]["buffed_stats" ]["stats" ][stat ]
89- except KeyError :
90- logger .warning (
91- f"Stat '{ stat } ' not found in single iteration simulation data while extracting secondary stats. Assuming 0."
84+ # Disable buffed stats for now. I believe these would basically get double-buffed when applied to a profile again.
85+ # stats = 0
86+ # for stat in rating_names:
87+ # if simulation.json_data:
88+ # try:
89+ # stats += simulation.json_data["sim"]["players"][0][
90+ # "collected_data"
91+ # ]["buffed_stats"]["stats"][stat]
92+ # except KeyError:
93+ # logger.warning(
94+ # f"Stat '{stat}' not found in single iteration simulation data while extracting secondary stats. Assuming 0."
95+ # )
96+
97+ if simulation .json_data :
98+ for itemslot in simulation .json_data ["sim" ]["players" ][0 ]["gear" ]: # type: ignore
99+ for stat in rating_names :
100+ secondary_amount += simulation .json_data ["sim" ]["players" ][0 ]["gear" ][ # type: ignore
101+ itemslot
102+ ].get (
103+ stat , 0
92104 )
93105
94- secondary_amount = int (stats )
95-
96106 logger .debug ("Extracted secondary_amount: {}" .format (secondary_amount ))
97107
108+ if secondary_amount == 0 :
109+ with open ("simc_error.json" , "w" ) as f :
110+ json .dump (simulation .json_data , f )
111+ raise ValueError (
112+ "No secondary stats found. Were no items in the profile? This makes no sense and makes this sim pointless."
113+ )
114+
98115 return secondary_amount
99116
100117 def pre_processing (self , data_dict : dict ) -> dict :
0 commit comments