vky #11
|
|
@ -1,14 +1,12 @@
|
|||
import time
|
||||
|
||||
import dearpygui.dearpygui as dpg
|
||||
import xiv_craft_solver as xcs
|
||||
from ffcraft_solver.modules import loader
|
||||
from ffcraft_solver.modules import loader, log, solver
|
||||
import rich
|
||||
|
||||
dpg.create_context()
|
||||
dpg.configure_app(manual_callback_management=True)
|
||||
dpg.create_viewport(title='XIV Solver', width=500, height=700)
|
||||
|
||||
class User:
|
||||
name = 'NEW'
|
||||
name = ' '
|
||||
food = ''
|
||||
pot = ''
|
||||
specialist = False
|
||||
|
|
@ -25,13 +23,16 @@ class User:
|
|||
dpg.set_value(food_combo, self.food)
|
||||
dpg.set_value(pot_combo, self.pot)
|
||||
dpg.set_value(user_effective_stats, [self.craftsmanship, self.control, self.cp])
|
||||
if self.name != ' ':
|
||||
dpg.set_value(save_user_as, self.name)
|
||||
else:
|
||||
dpg.set_value(save_user_as, '')
|
||||
return True
|
||||
|
||||
def compute_stats(self) -> list:
|
||||
food = []
|
||||
try:
|
||||
full_food = full_config.get_foods_dict()[self.food]
|
||||
# [[5, 120], [0, 0], [26, 82]]
|
||||
if user.initial_craftsmanship * full_food[0][0] / 100 > full_food[0][1]:
|
||||
food.append(full_food[0][1])
|
||||
else:
|
||||
|
|
@ -51,7 +52,6 @@ class User:
|
|||
pot = []
|
||||
try:
|
||||
full_pot = full_config.get_pots_dict()[self.pot]
|
||||
# [(0, 0), (0, 0), (6, 21)]
|
||||
if user.initial_craftsmanship * full_pot[0][0] / 100 > full_pot[0][1]:
|
||||
pot.append(full_pot[0][1])
|
||||
else:
|
||||
|
|
@ -77,6 +77,8 @@ class User:
|
|||
self.control = self.initial_control + food[1] + pot[1] + specialist[1]
|
||||
self.cp = self.initial_cp + food[2] + pot[2] + specialist[2]
|
||||
|
||||
return [self.craftsmanship, self.control, self.cp]
|
||||
|
||||
def set_initial_stats(self, _, app_data, __) -> list:
|
||||
self.initial_craftsmanship = app_data[0]
|
||||
self.initial_control = app_data[1]
|
||||
|
|
@ -102,81 +104,215 @@ class User:
|
|||
self.refresh_gui()
|
||||
return self.food
|
||||
|
||||
def set_name_combo(self, _, app_data, __) -> str:
|
||||
self.name = app_data
|
||||
self.set_initial_stats(0, full_config.get_users_dict()[self.name], None)
|
||||
dpg.set_value(user_stats, [self.initial_craftsmanship, self.initial_control, self.initial_cp])
|
||||
return self.name
|
||||
|
||||
|
||||
class Recipe:
|
||||
name = ''
|
||||
name = ' '
|
||||
progress = 0
|
||||
quality = 0
|
||||
difficulty = 0
|
||||
durability = 0
|
||||
quality_difficulty = 0
|
||||
progress_difficulty = 0
|
||||
quality_extra_difficulty = 0
|
||||
progress_extra_difficulty = 0
|
||||
|
||||
def set_recipe_stats(self, _, app_data, __):
|
||||
self.quality = app_data[0]
|
||||
self.difficulty = app_data[1]
|
||||
self.durability = app_data[2]
|
||||
return self.quality, self.difficulty, self.durability
|
||||
def refresh_gui(self):
|
||||
dpg.set_value(recipe_stats, self.get_recipe_stats()[0:3])
|
||||
dpg.set_value(advanced_recipe_stats, self.get_recipe_stats()[3:7])
|
||||
if self.name != ' ':
|
||||
dpg.set_value(save_recipe_as, self.name)
|
||||
else:
|
||||
dpg.set_value(save_recipe_as, '')
|
||||
|
||||
def get_recipe_stats(self):
|
||||
return self.quality, self.difficulty, self.durability
|
||||
def set_recipe_stats(self, tag, app_data, _) -> list[int, int, int, int, int, int, int]:
|
||||
stats = [0, 0, 0]
|
||||
advanced_stats = [0, 0, 0, 0]
|
||||
|
||||
if tag == 'recipe_tooltip':
|
||||
stats = app_data
|
||||
advanced_stats = dpg.get_value(advanced_recipe_stats)
|
||||
elif tag == 'advanced_recipe_tooltip':
|
||||
stats = dpg.get_value(recipe_stats)
|
||||
advanced_stats = app_data
|
||||
elif tag == 0:
|
||||
stats = [app_data[0], app_data[1], app_data[2]]
|
||||
advanced_stats = [app_data[3], app_data[4], app_data[5], app_data[6]]
|
||||
else:
|
||||
loggers.add_log('Something went very wrong in recipe stat assignment.')
|
||||
|
||||
self.progress = stats[0]
|
||||
self.quality = stats[1]
|
||||
self.durability = stats[2]
|
||||
self.progress_difficulty = advanced_stats[0]
|
||||
self.quality_difficulty = advanced_stats[1]
|
||||
self.progress_extra_difficulty = advanced_stats[2]
|
||||
self.quality_extra_difficulty = advanced_stats[3]
|
||||
|
||||
return [self.progress, self.quality, self.durability, self.progress_difficulty, self.quality_difficulty,
|
||||
self.progress_extra_difficulty, self.quality_extra_difficulty]
|
||||
|
||||
def get_recipe_stats(self) -> list[int, int, int, int, int, int, int]:
|
||||
return [self.progress, self.quality, self.durability, self.progress_difficulty, self.quality_difficulty,
|
||||
self.progress_extra_difficulty, self.quality_extra_difficulty]
|
||||
|
||||
def set_recipe_name(self, _, app_data, __):
|
||||
self.name = app_data
|
||||
self.set_recipe_stats(0, full_config.get_recipes_dict()[self.name], 0)
|
||||
dpg.set_value(recipe_stats, self.get_recipe_stats())
|
||||
self.refresh_gui()
|
||||
return self.name
|
||||
|
||||
def get_recipe_name(self) -> str:
|
||||
return self.name
|
||||
|
||||
|
||||
with dpg.window(label="Settings", width=500, height=700, no_resize=True, no_title_bar=True):
|
||||
user = User()
|
||||
recipe = Recipe()
|
||||
class Solution:
|
||||
def __init__(self, title, logger):
|
||||
self.loggers = logger
|
||||
self.result = None
|
||||
self.title = title
|
||||
|
||||
full_config = loader.Loader()
|
||||
characters_names = full_config.get_users_names()
|
||||
foods_names = full_config.get_foods_names()
|
||||
pots_names = full_config.get_pots_names()
|
||||
recipe_names = full_config.get_recipes_names()
|
||||
def print_result(self):
|
||||
if self.result:
|
||||
dpg.set_value(results, self.result)
|
||||
else:
|
||||
self.loggers.add_log('No solution to display.')
|
||||
|
||||
dpg.add_text("Character")
|
||||
user_combo = dpg.add_combo(items=characters_names, label="Your character")
|
||||
dpg.set_value(user_combo, "NEW")
|
||||
# TODO: Load 1rst user in users.yaml by default
|
||||
# TODO: Make NEW prompt for a name when saving
|
||||
user_stats = dpg.add_input_intx(size=3, label="Stats", tag="stats_tooltip", callback=user.set_initial_stats)
|
||||
with dpg.tooltip("stats_tooltip"):
|
||||
dpg.add_text("Craftsmanship / Control / CP")
|
||||
dpg.add_button(label="Save!", indent=282)
|
||||
specialist_checkbox = dpg.add_checkbox(label="Specialist", tag="specialist", callback=user.set_specialist)
|
||||
dpg.add_text(" ")
|
||||
user_effective_stats = dpg.add_input_intx(size=3, label="Effective stats", tag="effective_stats_tooltip", readonly=True)
|
||||
with dpg.tooltip("effective_stats_tooltip"):
|
||||
dpg.add_text("Craftsmanship / Control / CP")
|
||||
def print_macro_1(self):
|
||||
if self.result and self.result.macro1:
|
||||
dpg.set_value(results, self.result.macro1)
|
||||
else:
|
||||
self.loggers.add_log('No macro to display.')
|
||||
|
||||
dpg.add_separator()
|
||||
def print_macro_2(self):
|
||||
if self.result and self.result.macro2:
|
||||
dpg.set_value(results, self.result.macro2)
|
||||
else:
|
||||
self.loggers.add_log('No macro to display.')
|
||||
|
||||
dpg.add_text("Consumables")
|
||||
food_combo = dpg.add_combo(items=foods_names, label="Food", callback=user.set_food)
|
||||
pot_combo = dpg.add_combo(items=pots_names, label="Pot", callback=user.set_pot)
|
||||
def print_macro_3(self):
|
||||
if self.result and self.result.macro3:
|
||||
dpg.set_value(results, self.result.macro3)
|
||||
else:
|
||||
self.loggers.add_log('No macro to display.')
|
||||
|
||||
dpg.add_separator()
|
||||
|
||||
dpg.add_text("Recipe")
|
||||
recipe_combo = dpg.add_combo(items=recipe_names, label="Recipe", callback=recipe.set_recipe_name)
|
||||
dpg.set_value(recipe_combo, "NEW")
|
||||
recipe_stats = dpg.add_input_intx(size=3, label="Stats", tag="recipe_tooltip", callback=recipe.set_recipe_stats)
|
||||
with dpg.tooltip("recipe_tooltip"):
|
||||
dpg.add_text("Quality / Difficulty / Durability")
|
||||
# TODO: add a small grey text message if recipe matches a known recipe
|
||||
dpg.add_button(label="Save!", indent=282)
|
||||
def request_solve() -> True:
|
||||
loggers.add_log('Solver initialised. Please stand by.')
|
||||
all_results = solver.Solver(user, recipe)
|
||||
best_quality.result = all_results.best_quality
|
||||
least_steps.result = all_results.least_steps
|
||||
safe_50.result = all_results.safe_50
|
||||
dpg.set_value(results, best_quality.result)
|
||||
loggers.add_log('Solved!')
|
||||
return True
|
||||
|
||||
dpg.add_button(label="Solve!")
|
||||
dpg.add_collapsing_header(label="Result")
|
||||
|
||||
# TODO: add a log space at the bottom
|
||||
def refresh_log() -> True:
|
||||
dpg.set_value(log_window, loggers.log)
|
||||
return True
|
||||
|
||||
dpg.setup_dearpygui()
|
||||
dpg.show_viewport()
|
||||
while dpg.is_dearpygui_running():
|
||||
jobs = dpg.get_callback_queue() # retrieves and clears queue
|
||||
dpg.run_callbacks(jobs)
|
||||
dpg.render_dearpygui_frame()
|
||||
dpg.start_dearpygui()
|
||||
dpg.destroy_context()
|
||||
|
||||
if __name__ == '__main__':
|
||||
dpg.create_context()
|
||||
dpg.configure_app(manual_callback_management=True)
|
||||
dpg.create_viewport(title='XIV Solver', width=500, height=700)
|
||||
|
||||
with dpg.window(label="Settings", width=500, height=700, no_resize=True, no_title_bar=True, no_move=True):
|
||||
# Initialization of all our classes
|
||||
loggers = log.Loggers()
|
||||
|
||||
user = User()
|
||||
recipe = Recipe()
|
||||
best_quality = Solution("Best Quality", loggers)
|
||||
least_steps = Solution("Least Steps", loggers)
|
||||
safe_50 = Solution("Safe Margin", loggers)
|
||||
|
||||
full_config = loader.Loader(loggers)
|
||||
characters_names = full_config.get_users_names()
|
||||
foods_names = full_config.get_foods_names()
|
||||
pots_names = full_config.get_pots_names()
|
||||
recipe_names = full_config.get_recipes_names()
|
||||
|
||||
# Start of GUI drawing
|
||||
# CHARACTER
|
||||
dpg.add_text("Character")
|
||||
user_combo = dpg.add_combo(items=characters_names, label="Your character", callback=user.set_name_combo)
|
||||
dpg.set_value(user_combo, ' ')
|
||||
# TODO: Load 1rst user in users.yaml by default
|
||||
user_stats = dpg.add_input_intx(size=3, label="Stats", tag="stats_tooltip", callback=user.set_initial_stats)
|
||||
with dpg.tooltip("stats_tooltip"):
|
||||
dpg.add_text("Craftsmanship / Control / CP")
|
||||
with dpg.group(horizontal=True):
|
||||
save_user_as = dpg.add_input_text(hint='Save as...')
|
||||
dpg.add_button(label="Save!")
|
||||
# TODO: Can't save if value == ' '
|
||||
|
||||
# EFFECTIVE STATS
|
||||
dpg.add_separator()
|
||||
user_effective_stats = dpg.add_input_intx(size=3, label="Effective stats", tag="effective_stats_tooltip", readonly=True)
|
||||
with dpg.tooltip("effective_stats_tooltip"):
|
||||
dpg.add_text("Craftsmanship / Control / CP")
|
||||
dpg.add_separator()
|
||||
|
||||
# MODIFIERS
|
||||
dpg.add_text("Modifiers")
|
||||
food_combo = dpg.add_combo(items=foods_names, label="Food", callback=user.set_food)
|
||||
pot_combo = dpg.add_combo(items=pots_names, label="Pot", callback=user.set_pot)
|
||||
specialist_checkbox = dpg.add_checkbox(label="Specialist", tag="specialist", callback=user.set_specialist)
|
||||
|
||||
# RECIPE
|
||||
dpg.add_separator()
|
||||
dpg.add_text("Recipe")
|
||||
recipe_combo = dpg.add_combo(items=recipe_names, label="Recipe", callback=recipe.set_recipe_name)
|
||||
dpg.set_value(recipe_combo, " ")
|
||||
recipe_stats = dpg.add_input_intx(size=3, label="Stats", tag="recipe_tooltip", callback=recipe.set_recipe_stats)
|
||||
with dpg.tooltip("recipe_tooltip"):
|
||||
dpg.add_text("Progress / Quality / Durability")
|
||||
advanced_recipe_stats = dpg.add_input_intx(
|
||||
size=4, label="Advanced stats", tag="advanced_recipe_tooltip", callback=recipe.set_recipe_stats
|
||||
)
|
||||
with dpg.tooltip("advanced_recipe_tooltip"):
|
||||
dpg.add_text("Progress / Quality difficulty // Progress / Quality extra difficulty")
|
||||
# TODO: add a log if recipe matches a known recipe
|
||||
with dpg.group(horizontal=True):
|
||||
save_recipe_as = dpg.add_input_text(hint='Save as...')
|
||||
dpg.add_button(label="Save!", callback=request_solve)
|
||||
# TODO: Can't save if value == ' '
|
||||
|
||||
# SOLVE
|
||||
dpg.add_separator()
|
||||
dpg.add_button(label="Solve!", callback=request_solve)
|
||||
dpg.add_text()
|
||||
dpg.add_collapsing_header(label="Results", leaf=True)
|
||||
# TODO: Add feedback when pressed
|
||||
|
||||
with dpg.group(horizontal=True):
|
||||
results = dpg.add_input_text(multiline=True, height=220, readonly=True)
|
||||
with dpg.child_window(autosize_x=True, height=220):
|
||||
dpg.add_button(label="BEST QUALITY", width=136, callback=best_quality.print_result)
|
||||
dpg.add_button(label="Macro 1", width=136, callback=best_quality.print_macro_1)
|
||||
dpg.add_button(label="Macro 2", width=136, callback=best_quality.print_macro_2)
|
||||
dpg.add_button(label="SAFE MARGIN", width=136, callback=safe_50.print_result)
|
||||
dpg.add_button(label="Macro 1", width=136, callback=safe_50.print_macro_1)
|
||||
dpg.add_button(label="Macro 2", width=136, callback=safe_50.print_macro_2)
|
||||
dpg.add_button(label="QUICKEST", width=136, callback=least_steps.print_result)
|
||||
dpg.add_button(label="Macro 1", width=136, callback=least_steps.print_macro_1)
|
||||
dpg.add_button(label="Macro 2", width=136, callback=least_steps.print_macro_2)
|
||||
|
||||
# LOG
|
||||
log_window = dpg.add_input_text(multiline=True, default_value=loggers.log, height=50, width=500,
|
||||
tab_input=True, pos=[0, 642], tracked=False, readonly=True, tag="log_window")
|
||||
|
||||
dpg.setup_dearpygui()
|
||||
dpg.show_viewport()
|
||||
while dpg.is_dearpygui_running():
|
||||
jobs = dpg.get_callback_queue() # retrieves and clears queue
|
||||
dpg.run_callbacks(jobs)
|
||||
dpg.render_dearpygui_frame()
|
||||
dpg.start_dearpygui()
|
||||
dpg.destroy_context()
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
# Name: [Quality, difficulty, durability]
|
||||
Grade 7 Tincture of Strength: [12628, 5060, 70]
|
||||
Grade 5 Strength Alkahest: [6200, 1300, 35]
|
||||
# Name: [Progress, quality, durability, progress difficulty, quality difficulty, extra progress difficulty, extra quality difficulty]
|
||||
# as can be found on other solver websites, such as https://yyyy.games/crafter/index.html#/simulator and checking custom recipe.
|
||||
# The language option is the second menu to the left from the top-right hand corner.
|
||||
# If this seems super convoluted, and you'd rather it was just the three in-game values, know that me too.
|
||||
# Unfortunately that is how Square Enix chose to make crafting work in FFXIV.
|
||||
|
||||
Grade 7 Tincture of Strength: [5060, 12628, 70, 130, 115, 80, 70]
|
||||
Grade 5 Strength Alkahest: [1300, 6200, 40, 123, 107, 100, 100]
|
||||
|
|
@ -7,7 +7,7 @@ rich.inspect(xiv_craft_solver.test_result())
|
|||
rich.inspect(xiv_craft_solver.test_result())
|
||||
|
||||
|
||||
class feedMeDaddy:
|
||||
class FeedMeDaddy:
|
||||
durability = 70
|
||||
progress = 3900
|
||||
quality = 10920
|
||||
|
|
@ -27,6 +27,6 @@ class feedMeDaddy:
|
|||
verbose = 0
|
||||
|
||||
|
||||
el_daddy=feedMeDaddy()
|
||||
el_daddy = FeedMeDaddy()
|
||||
rich.inspect(xiv_craft_solver.solve_from_python(el_daddy))
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import rich
|
||||
import yaml
|
||||
import os
|
||||
from ffcraft_solver.modules import log
|
||||
|
||||
|
||||
class DefaultConfig:
|
||||
yaml_user = 'configs/users.yaml'
|
||||
|
|
@ -8,40 +9,43 @@ class DefaultConfig:
|
|||
yaml_recipes = 'configs/recipes.yaml'
|
||||
|
||||
|
||||
|
||||
|
||||
class Loader:
|
||||
# TODO: create folder/file if missing when clicking "save"
|
||||
# TODO: log any missing file(s) or the whole folder
|
||||
def __init__(self):
|
||||
self.user_list = {'NEW': [0, 0, 0]}
|
||||
def __init__(self, loggers: log.Loggers):
|
||||
self.loggers = loggers
|
||||
self.user_list = {' ': [0, 0, 0]}
|
||||
self.foods_list = {' ': [[0, 0], [0, 0], [0, 0]]}
|
||||
self.pots_list = {' ': [[0, 0], [0, 0], [0, 0]]}
|
||||
self.recipes_list = {'NEW': [0, 0, 0]}
|
||||
self.recipes_list = {' ': [0, 0, 0, 0, 0, 0, 0]}
|
||||
self.config = DefaultConfig()
|
||||
|
||||
try:
|
||||
with open(self.relative_import(self.config.yaml_user), 'r') as file:
|
||||
self.user_list.update(yaml.safe_load(file))
|
||||
except FileNotFoundError as e:
|
||||
print(e)
|
||||
self.loggers.add_log(e)
|
||||
|
||||
try:
|
||||
with open(self.relative_import(self.config.yaml_consumable), 'r') as file:
|
||||
loaded_file = yaml.safe_load(file)
|
||||
self.foods_list.update(loaded_file['Foods'])
|
||||
self.pots_list.update(loaded_file['Pots'])
|
||||
except FileNotFoundError as e:
|
||||
print(e)
|
||||
self.loggers.add_log(e)
|
||||
|
||||
try:
|
||||
with open(self.relative_import(self.config.yaml_recipes), 'r') as file:
|
||||
self.recipes_list.update(yaml.safe_load(file))
|
||||
except (FileNotFoundError,IsADirectoryError) as e:
|
||||
print(e)
|
||||
except (FileNotFoundError, IsADirectoryError) as e:
|
||||
self.loggers.add_log(e)
|
||||
|
||||
def relative_import(self, path):
|
||||
return (os.path.normpath(os.path.join(__file__,"../..",path)))
|
||||
@staticmethod
|
||||
def relative_import(path):
|
||||
return os.path.normpath(os.path.join(__file__, "../..", path))
|
||||
|
||||
def get_users_dict(self) -> dict:
|
||||
self.loggers.add_log('Loaded user dictionary from users.yaml')
|
||||
return self.user_list
|
||||
|
||||
def get_users_names(self) -> list:
|
||||
|
|
@ -76,7 +80,3 @@ class Loader:
|
|||
for r in self.recipes_list:
|
||||
recipes_names.append(r)
|
||||
return recipes_names
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
loader = Loader()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
from datetime import datetime
|
||||
import dearpygui.dearpygui as dpg
|
||||
|
||||
|
||||
class Loggers:
|
||||
def __init__(self, log=None):
|
||||
timestamp = self.get_timestamp()
|
||||
if not log:
|
||||
self.log = f"{timestamp} Log initialised."
|
||||
else:
|
||||
self.log = log
|
||||
|
||||
def add_log(self, other: str) -> str:
|
||||
timestamp = self.get_timestamp()
|
||||
self.log = timestamp + ' ' + other + '\n' + self.log
|
||||
dpg.set_value('log_window', self.log)
|
||||
return self.log
|
||||
|
||||
# noinspection PyMethodMayBeStatic
|
||||
def get_timestamp(self) -> str:
|
||||
now = datetime.now()
|
||||
almost_timestamp = str(now.time())
|
||||
timestamp = almost_timestamp.rsplit('.')
|
||||
return f'[{timestamp[0]}]'
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
loggers = Loggers()
|
||||
print(loggers.log)
|
||||
|
|
@ -0,0 +1,171 @@
|
|||
import rich
|
||||
import xiv_craft_solver as xcs
|
||||
from ffcraft_solver.__main__ import User, Recipe
|
||||
from ffcraft_solver.modules import log, translator
|
||||
|
||||
|
||||
class Result:
|
||||
def __init__(self, result, title: str):
|
||||
self.title = title
|
||||
self.original = result
|
||||
self.quality = result.quality
|
||||
self.actions = result.actions
|
||||
self.steps = result.steps
|
||||
self.remaining_cp = result.cp
|
||||
|
||||
self.all_buffs_list = ['manipulation', 'veneration', 'mastersMend', 'wasteNot', 'wasteNot2', 'greatStrides',
|
||||
'innovation', 'finalAppraisal', 'carefulObservation', 'heartAndSoul']
|
||||
|
||||
self.readable_actions = self.text_wrap(self.actions)
|
||||
|
||||
self.macro1 = ''
|
||||
self.macro2 = ''
|
||||
self.macro3 = ''
|
||||
self.make_macro()
|
||||
|
||||
self.readable = f"""/// {self.title}
|
||||
Rotation:
|
||||
{self.readable_actions}
|
||||
Quality: {self.quality}
|
||||
Steps: {self.steps}
|
||||
Remaining CP: {self.remaining_cp}"""
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.readable
|
||||
|
||||
@staticmethod # il est con ou quoi?
|
||||
def text_wrap(text: list[str]) -> str:
|
||||
"""Transforms a list of words into a string and wraps them at 34 characters with an indent."""
|
||||
line = ' '
|
||||
saved_lines = []
|
||||
justified_text = ''
|
||||
for w in text:
|
||||
if len(line) < 31:
|
||||
line += w + ' '
|
||||
else:
|
||||
saved_lines.append(line)
|
||||
line = ' ' + w + ' '
|
||||
|
||||
if line != saved_lines[-1]:
|
||||
saved_lines.append(line)
|
||||
|
||||
for line in saved_lines:
|
||||
justified_text += line + '\n'
|
||||
|
||||
return justified_text[:-1]
|
||||
|
||||
def make_macro(self) -> True:
|
||||
saved_lines = ['']
|
||||
translated_actions = translator.translate_list(self.actions, "en")
|
||||
count = 0
|
||||
|
||||
for action in translated_actions:
|
||||
line = f'/ac "{action}" <wait.{"2" if self.actions[count] in self.all_buffs_list else "3"}>'
|
||||
saved_lines.append(line)
|
||||
count += 1
|
||||
saved_lines = saved_lines[1:]
|
||||
|
||||
if self.steps != 15 and self.steps != 29 and self.steps != 44:
|
||||
saved_lines.append('/echo Craft complete ! <se.3>')
|
||||
else:
|
||||
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
|
||||
for line in saved_lines:
|
||||
count += 1
|
||||
if count < 16:
|
||||
self.macro1 += line + '\n'
|
||||
elif 15 < count < 31:
|
||||
self.macro2 += line + '\n'
|
||||
elif 30 < count < 46:
|
||||
self.macro3 += line + '\n'
|
||||
|
||||
self.macro1 = self.macro1[:-1]
|
||||
self.macro2 = self.macro2[:-1]
|
||||
self.macro3 = self.macro3[:-1]
|
||||
return True
|
||||
|
||||
|
||||
class Solver:
|
||||
def __init__(self, user: User, recipe: Recipe):
|
||||
self.durability = recipe.durability
|
||||
self.progress = recipe.progress
|
||||
self.quality = recipe.quality
|
||||
self.progress_divider = recipe.progress_difficulty
|
||||
self.quality_divider = recipe.quality_difficulty
|
||||
self.progress_modifier = recipe.progress_extra_difficulty
|
||||
self.quality_modifier = recipe.quality_extra_difficulty
|
||||
|
||||
self.craftsmanship = user.craftsmanship
|
||||
self.control = user.control
|
||||
self.max_cp = user.cp
|
||||
|
||||
self.depth = 10
|
||||
self.byregot_step = 10
|
||||
self.desperate = False
|
||||
self.threads = 8
|
||||
self.verbose = 0
|
||||
|
||||
self.solutions = []
|
||||
self.best_quality = None
|
||||
self.least_steps = None
|
||||
self.safe_50 = None
|
||||
|
||||
self.solve()
|
||||
self.compute_all()
|
||||
|
||||
def solve(self) -> str:
|
||||
self.solutions = xcs.solve_from_python(self)
|
||||
return xcs.solve_from_python(self)
|
||||
|
||||
def compute_all(self) -> True:
|
||||
if self.solutions:
|
||||
self.sort_quality()
|
||||
self.compute_best_quality()
|
||||
self.compute_least_steps()
|
||||
self.compute_50percent_quality()
|
||||
|
||||
def sort_quality(self) -> True:
|
||||
self.solutions.sort(key=lambda x: x.quality)
|
||||
return True
|
||||
|
||||
def compute_best_quality(self) -> Result:
|
||||
self.best_quality = Result(self.solutions[-1], 'Best quality')
|
||||
return self.best_quality
|
||||
|
||||
def compute_50percent_quality(self) -> Result:
|
||||
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
|
||||
|
||||
def compute_least_steps(self) -> Result:
|
||||
least_steps = 100
|
||||
output = None
|
||||
if self.solutions:
|
||||
for e in self.solutions:
|
||||
if e.steps < least_steps:
|
||||
least_steps = e.steps
|
||||
output = e
|
||||
self.least_steps = Result(output, 'Least steps')
|
||||
|
||||
return self.least_steps
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
from ffcraft_solver.modules import log
|
||||
|
||||
loggers = log.Loggers
|
||||
|
||||
supported_languages = {
|
||||
"en": {
|
||||
'basicSynth': 'Basic Synthesis',
|
||||
'basicSynth2': 'Basic Synthesis',
|
||||
'basicTouch': 'Basic Touch',
|
||||
'mastersMend': "Master's mend",
|
||||
'hastyTouch': 'Hasty Touch',
|
||||
'rapidSynthesis': 'Rapid Synthesis',
|
||||
'wasteNot': 'Waste Not',
|
||||
'veneration': 'Veneration',
|
||||
'standardTouch': 'Standard Touch',
|
||||
'greatStrides': 'Great Strides',
|
||||
'innovation': 'Innovation',
|
||||
'finalAppraisal': 'Final Appraisal',
|
||||
'wasteNot2': 'Waste Not II',
|
||||
'byregotsBlessing': "Byregot's Blessing",
|
||||
'preciseTouch': 'Precise Touch',
|
||||
'muscleMemory': 'Muscle Memory',
|
||||
'carefulSynthesis': 'Careful Synthesis',
|
||||
'manipulation': 'Manipulation',
|
||||
'prudentTouch': 'Prudent Touch',
|
||||
'focusedSynthesis': 'Focused Synthesis',
|
||||
'focusedTouch': 'Focused Touch',
|
||||
'reflect': 'Reflect',
|
||||
'preparatoryTouch': 'Preparatory Touch',
|
||||
'groundwork': 'Groundwork',
|
||||
'delicateSynthesis': 'Delicate Synthesis',
|
||||
'intensiveSynthesis': 'Intensive Synthesis',
|
||||
'trainedEye': 'Trained Eye',
|
||||
'advancedTouch': 'Advanced Touch',
|
||||
'prudentSynthesis': 'Prudent Synthesis',
|
||||
'trainedFinesse': 'Trained Finesse'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def translate_list(actions: list, lang: str):
|
||||
output = []
|
||||
if lang in supported_languages:
|
||||
dictionary = supported_languages[lang]
|
||||
for action in actions:
|
||||
try:
|
||||
output.append(dictionary[action])
|
||||
except KeyError:
|
||||
output.append(supported_languages["en"][action])
|
||||
loggers.log('Translation not found. Defaulting to English.\n'
|
||||
' Macros will probably be broken because of this.')
|
||||
|
||||
else:
|
||||
loggers.add_log(f'Language code "{lang}" not recognised.')
|
||||
|
||||
return output
|
||||
|
||||
Reference in New Issue