|
|
@@ -147,11 +147,130 @@ char set_names[][24] = {
|
|
|
"FIGHT", "DETERMINATION", "ENHANCE", "ACCURACY", "TOLERANCE"
|
|
|
};
|
|
|
|
|
|
+/**
|
|
|
+ * Parses the arguments for the optimize command.
|
|
|
+ *
|
|
|
+ * @param[in] argc Argument count.
|
|
|
+ * @param[in] argv Argument list.
|
|
|
+ * @param[out] id Unit id or name.
|
|
|
+ * @param[out] level Level to treat the runes as.
|
|
|
+ * @param[out] sets List of requested sets.
|
|
|
+ * @param[out] stats List of requested stats.
|
|
|
+ * @param[out] min_stats Minimum stats for the optimization.
|
|
|
+ * @param[out] gui 1 to format the output for the GUI
|
|
|
+ * @return SUCCESS or an error code.
|
|
|
+ */
|
|
|
+int parse_optimization_arguments(
|
|
|
+ int argc, char *argv[], char id[64], char *level,
|
|
|
+ int *sets, int *stats, struct Stats *min_stats, char *gui
|
|
|
+
|
|
|
+);
|
|
|
+
|
|
|
+/**
|
|
|
+ * Populates a Unit structure with data from the database.
|
|
|
+ *
|
|
|
+ * @param[in] id Argument count.
|
|
|
+ * @param[out] unit Structure to populate.
|
|
|
+ * @return SUCCESS or an error code.
|
|
|
+ */
|
|
|
+int retrieveUnit(char id[64], struct Unit *unit);
|
|
|
+
|
|
|
+/**
|
|
|
+ * Populates a Rune_Set_Count structure with the number of each rune requested
|
|
|
+ * for the optimization.
|
|
|
+ *
|
|
|
+ * @param[in] sets Sets requested as arguments.
|
|
|
+ * @param[out] requested_set_count Structure to populate.
|
|
|
+ * @return Number of requested runes.
|
|
|
+ */
|
|
|
+char calculateRequiredSetCount(
|
|
|
+ int sets[3],
|
|
|
+ struct Rune_Set_Count *requested_set_count
|
|
|
+);
|
|
|
+
|
|
|
+/**
|
|
|
+ * Generates the query to get the runes from the databas for even slots.
|
|
|
+ *
|
|
|
+ * @param[in] level Level to consider runes at.
|
|
|
+ * @param[in] sets Requested sets.
|
|
|
+ * @param[in] stats Requested sets for even slots.
|
|
|
+ * @param[out] query String with the query.
|
|
|
+ */
|
|
|
+void createQueryForEvenSlots(char level, int* sets, int* stats, char query[1500]);
|
|
|
+
|
|
|
+/**
|
|
|
+ * Generates the query to get the runes from the databas for odd slots.
|
|
|
+ *
|
|
|
+ * @param[in] level Level to consider runes at.
|
|
|
+ * @param[in] sets Requested sets.
|
|
|
+ * @param[out] query String with the query.
|
|
|
+ */
|
|
|
+void createQueryForOddSlots(char level, int* sets, char query[1500]);
|
|
|
+
|
|
|
+/**
|
|
|
+ * Gets the list of runes to test during the optimization from the database.
|
|
|
+ *
|
|
|
+ * Im assumming 600 runes per slot is a safe estimate. I hope it doesn't
|
|
|
+ * come back to bite me.
|
|
|
+ * Im using a 7 position array, and the index 0 is ignored. This is
|
|
|
+ * is because I REALLY NEED to use 1-indexes to match rune slots.
|
|
|
+ *
|
|
|
+ * @param[in] query_even Query to execute for even slots.
|
|
|
+ * @param[in] query_odd Query to execute for odd slots.
|
|
|
+ * @param[out] runes List of runes to populate.
|
|
|
+ * @param[out] rune_count Number of runes retrieved for each slot.
|
|
|
+ * @return SUCCESS or an error code.
|
|
|
+ */
|
|
|
+int get_runes(
|
|
|
+ char query_even[1500], char query_odd[1500],
|
|
|
+ struct Rune runes[7][600], int rune_count[7]
|
|
|
+);
|
|
|
+
|
|
|
+/**
|
|
|
+ * Print a nice summary with all the data fethced from the command line and db.
|
|
|
+ *
|
|
|
+ * It is 17 lines high and un to 80 characters wide.
|
|
|
+ *
|
|
|
+ * @param[in] unit Unit data.
|
|
|
+ * @param[in] sets Requested rune sets.
|
|
|
+ * @param[in] stats Requested stats for even slots.
|
|
|
+ * @param[in] min_stats Requested minimum stats sets.
|
|
|
+ * @param[in] level Level to treat runes as.
|
|
|
+ * @param[in] rune_count Number of runes for each slot.
|
|
|
+ * @param[in] max_combinations Total combinations to test during optimization.
|
|
|
+ */
|
|
|
+void print_summary(
|
|
|
+ struct Unit *unit, int* sets, int* stats, struct Stats *min_stats,
|
|
|
+ char level, int rune_count[7], unsigned long max_combinations
|
|
|
+);
|
|
|
+
|
|
|
+/**
|
|
|
+ * Prints a nice summary with all de details of a result.
|
|
|
+ *
|
|
|
+ * It is 43 lines high and 97 characters wide.
|
|
|
+ *
|
|
|
+ * @param[in] unit Unit data.
|
|
|
+ * @param[in] result Result to display.
|
|
|
+ * @return SUCCESS or an error code.
|
|
|
+ */
|
|
|
+int present_option(struct Unit *unit, Result *result);
|
|
|
+
|
|
|
+/**
|
|
|
+ * Prepares and prints the output for the GUI.
|
|
|
+ *
|
|
|
+ * Basically, it's JSON.
|
|
|
+ *
|
|
|
+ * @param[in] results All results.
|
|
|
+ * @param[in] result_count Number of results.
|
|
|
+ * @return SUCCESS or an error code.
|
|
|
+ */
|
|
|
+int gui_output(Result results[5000], int result_count);
|
|
|
+
|
|
|
/**
|
|
|
* Starts the optimization process.
|
|
|
*
|
|
|
- * @param argc Argument count.
|
|
|
- * @param argv Argument list.
|
|
|
+ * @param[in] argc Argument count.
|
|
|
+ * @param[in] argv Argument list.
|
|
|
* @return 0 on success, other on error.
|
|
|
*/
|
|
|
int optimize(int argc, char *argv[]);
|
|
|
@@ -161,16 +280,16 @@ int optimize(int argc, char *argv[]);
|
|
|
*
|
|
|
* Sorts them by rating.
|
|
|
*
|
|
|
- * @param results List of results to sort.
|
|
|
- * @param total Number of results.
|
|
|
+ * @param[in,out] results List of results to sort.
|
|
|
+ * @param[in] total Number of results.
|
|
|
*/
|
|
|
void sort_results(Result results[1000], int total);
|
|
|
|
|
|
/**
|
|
|
* Calculates efficient HP.
|
|
|
*
|
|
|
- * @param hp HP stat.
|
|
|
- * @param def DEF stat.
|
|
|
+ * @param[in] hp HP stat.
|
|
|
+ * @param[in] def DEF stat.
|
|
|
* @return Calculated EHP.
|
|
|
*/
|
|
|
unsigned int calculate_ehp(unsigned int hp, unsigned short def);
|
|
|
@@ -178,9 +297,9 @@ unsigned int calculate_ehp(unsigned int hp, unsigned short def);
|
|
|
/**
|
|
|
* Calculates damage.
|
|
|
*
|
|
|
- * @param atk ATK stat.
|
|
|
- * @param crr CRR stat.
|
|
|
- * @param crd CRD stat.
|
|
|
+ * @param[in] atk ATK stat.
|
|
|
+ * @param[in] crr CRR stat.
|
|
|
+ * @param[in] crd CRD stat.
|
|
|
* @return Calculated DMG.
|
|
|
*/
|
|
|
unsigned short calculate_dmg(unsigned short atk, unsigned short crr, unsigned short crd);
|