Made macros work
This commit is contained in:
parent
ed904f5eca
commit
e17e101c39
|
|
@ -142,7 +142,7 @@ class Recipe:
|
||||||
stats = [app_data[0], app_data[1], app_data[2]]
|
stats = [app_data[0], app_data[1], app_data[2]]
|
||||||
advanced_stats = [app_data[3], app_data[4], app_data[5], app_data[6]]
|
advanced_stats = [app_data[3], app_data[4], app_data[5], app_data[6]]
|
||||||
else:
|
else:
|
||||||
print('Log: Something went very wrong in recipe stat assignment.')
|
loggers.add_log('Something went very wrong in recipe stat assignment.')
|
||||||
|
|
||||||
self.progress = stats[0]
|
self.progress = stats[0]
|
||||||
self.quality = stats[1]
|
self.quality = stats[1]
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class Loader:
|
||||||
with open(self.relative_import(self.config.yaml_user), 'r') as file:
|
with open(self.relative_import(self.config.yaml_user), 'r') as file:
|
||||||
self.user_list.update(yaml.safe_load(file))
|
self.user_list.update(yaml.safe_load(file))
|
||||||
except FileNotFoundError as e:
|
except FileNotFoundError as e:
|
||||||
print(e)
|
loggers.add_log(e)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(self.relative_import(self.config.yaml_consumable), 'r') as file:
|
with open(self.relative_import(self.config.yaml_consumable), 'r') as file:
|
||||||
|
|
@ -35,13 +35,13 @@ class Loader:
|
||||||
self.foods_list.update(loaded_file['Foods'])
|
self.foods_list.update(loaded_file['Foods'])
|
||||||
self.pots_list.update(loaded_file['Pots'])
|
self.pots_list.update(loaded_file['Pots'])
|
||||||
except FileNotFoundError as e:
|
except FileNotFoundError as e:
|
||||||
print(e)
|
loggers.add_log(e)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(self.relative_import(self.config.yaml_recipes), 'r') as file:
|
with open(self.relative_import(self.config.yaml_recipes), 'r') as file:
|
||||||
self.recipes_list.update(yaml.safe_load(file))
|
self.recipes_list.update(yaml.safe_load(file))
|
||||||
except (FileNotFoundError, IsADirectoryError) as e:
|
except (FileNotFoundError, IsADirectoryError) as e:
|
||||||
print(e)
|
loggers.add_log(e)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def relative_import(path):
|
def relative_import(path):
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ Remaining CP: {self.remaining_cp}"""
|
||||||
|
|
||||||
return justified_text[:-1]
|
return justified_text[:-1]
|
||||||
|
|
||||||
def make_macro(self) -> str:
|
def make_macro(self) -> True:
|
||||||
saved_lines = ['']
|
saved_lines = ['']
|
||||||
translated_actions = translator.translate_list(self.actions, "en")
|
translated_actions = translator.translate_list(self.actions, "en")
|
||||||
count = 0
|
count = 0
|
||||||
|
|
@ -65,37 +65,34 @@ Remaining CP: {self.remaining_cp}"""
|
||||||
line = f'/ac "{action}" <wait.{"2" if self.actions[count] in self.all_buffs_list else "3"}>'
|
line = f'/ac "{action}" <wait.{"2" if self.actions[count] in self.all_buffs_list else "3"}>'
|
||||||
saved_lines.append(line)
|
saved_lines.append(line)
|
||||||
count += 1
|
count += 1
|
||||||
|
saved_lines = saved_lines[1:]
|
||||||
|
|
||||||
if self.steps != 29 or self.steps != 44:
|
if self.steps != 15 and self.steps != 29 and self.steps != 44:
|
||||||
saved_lines.append('/echo Craft complete ! <se.3>')
|
saved_lines.append('/echo Craft complete ! <se.3>')
|
||||||
else:
|
else:
|
||||||
loggers.log(f'No completion message in macro because rotation is exactly {self.steps} steps.')
|
loggers.log(f'No completion message in macro because rotation is exactly {self.steps} steps.')
|
||||||
|
|
||||||
|
if self.steps > 15:
|
||||||
|
saved_lines.insert(14, '/echo Macro 1 complete <se.2>')
|
||||||
|
|
||||||
|
if self.steps > 30:
|
||||||
|
saved_lines.insert(30, '/echo Macro 2 complete <se.2>')
|
||||||
|
# TODO : test index
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
for line in saved_lines:
|
for line in saved_lines:
|
||||||
count += 1
|
count += 1
|
||||||
if count < 15:
|
if count < 16:
|
||||||
self.macro1 += line + '\n'
|
self.macro1 += line + '\n'
|
||||||
elif 14 < count < 30:
|
elif 15 < count < 31:
|
||||||
self.macro2 += line + '\n'
|
self.macro2 += line + '\n'
|
||||||
elif 29 < count < 45:
|
elif 30 < count < 46:
|
||||||
self.macro3 += line + '\n'
|
self.macro3 += line + '\n'
|
||||||
else:
|
|
||||||
print("Log: Macro too long!")
|
|
||||||
|
|
||||||
nb_macros = 0
|
self.macro1 = self.macro1[:-1]
|
||||||
if self.macro1:
|
self.macro2 = self.macro2[:-1]
|
||||||
nb_macros = 1
|
self.macro3 = self.macro3[:-1]
|
||||||
if self.macro2:
|
return True
|
||||||
nb_macros += 1
|
|
||||||
if self.macro3:
|
|
||||||
nb_macros += 1
|
|
||||||
# TODO: add next macro line
|
|
||||||
|
|
||||||
self.macro1 = self.macro1[1:]
|
|
||||||
self.macro2 = self.macro2[1:]
|
|
||||||
self.macro3 = self.macro3[1:]
|
|
||||||
return self.macro1
|
|
||||||
|
|
||||||
|
|
||||||
class Solver:
|
class Solver:
|
||||||
|
|
@ -146,7 +143,19 @@ class Solver:
|
||||||
return self.best_quality
|
return self.best_quality
|
||||||
|
|
||||||
def compute_50percent_quality(self) -> Result:
|
def compute_50percent_quality(self) -> Result:
|
||||||
self.safe_50 = Result(self.solutions[round(len(self.solutions)/2)+1], 'Safe 50')
|
done = False
|
||||||
|
threshold = self.quality * 1.5
|
||||||
|
for s in reversed(self.solutions):
|
||||||
|
if s.quality > threshold:
|
||||||
|
self.safe_50 = Result(s, 'Safe 50')
|
||||||
|
done = True
|
||||||
|
|
||||||
|
if not done:
|
||||||
|
loggers.add_log('Could not find a rotation for 150% quality.\n'
|
||||||
|
' Defaulting to Best Quality.')
|
||||||
|
self.safe_50 = self.best_quality
|
||||||
|
|
||||||
|
# self.safe_50 = Result(self.solutions[round(len(self.solutions)/2)+1], 'Safe 50') # old version
|
||||||
return self.safe_50
|
return self.safe_50
|
||||||
|
|
||||||
def compute_least_steps(self) -> Result:
|
def compute_least_steps(self) -> Result:
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ supported_languages = {
|
||||||
|
|
||||||
def translate_list(actions: list, lang: str):
|
def translate_list(actions: list, lang: str):
|
||||||
output = []
|
output = []
|
||||||
print(actions)
|
|
||||||
if lang in supported_languages:
|
if lang in supported_languages:
|
||||||
dictionary = supported_languages[lang]
|
dictionary = supported_languages[lang]
|
||||||
for action in actions:
|
for action in actions:
|
||||||
|
|
@ -51,9 +50,8 @@ def translate_list(actions: list, lang: str):
|
||||||
loggers.log('Translation not found. Defaulting to English.\n'
|
loggers.log('Translation not found. Defaulting to English.\n'
|
||||||
' Macros will probably be broken because of this.')
|
' Macros will probably be broken because of this.')
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print(f'Log: Language code "{lang}" not recognised.')
|
loggers.add_log(f'Language code "{lang}" not recognised.')
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
|
||||||
Reference in New Issue