|
@@ -0,0 +1,317 @@
|
|
|
|
|
+/*
|
|
|
|
|
+ * This file is part of RuneOptimizer.
|
|
|
|
|
+ *
|
|
|
|
|
+ * RuneOptimizer is free software: you can redistribute it and/or modify it
|
|
|
|
|
+ * under the terms of the GNU General Public License as published by the Free
|
|
|
|
|
+ * Software Foundation, either version 3 of the License, or (at your option)
|
|
|
|
|
+ * any later version.
|
|
|
|
|
+ *
|
|
|
|
|
+ * RuneOptimizer is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
|
+ * more details.
|
|
|
|
|
+ *
|
|
|
|
|
+ * You should have received a copy of the GNU General Public License along with
|
|
|
|
|
+ * RuneOptimizer. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+int unit_list(char *search){
|
|
|
|
|
+
|
|
|
|
|
+ char query[300] = "SELECT id, name, priority FROM teams ";
|
|
|
|
|
+ char search_name[96] = "%";
|
|
|
|
|
+ strcat(search_name, search);
|
|
|
|
|
+ strcat(search_name, "%");
|
|
|
|
|
+ char *parameters[2] = {search, search_name};
|
|
|
|
|
+ sqlite3_stmt *stmt_units;
|
|
|
|
|
+ sqlite3_stmt *stmt_runes;
|
|
|
|
|
+ sqlite3_stmt *stmt_stats;
|
|
|
|
|
+ char rune_lines[30][80];
|
|
|
|
|
+ db_query(
|
|
|
|
|
+ &stmt_units,
|
|
|
|
|
+ "SELECT "
|
|
|
|
|
+ " id, name, stars, level, storage, "
|
|
|
|
|
+ " base_hp, base_atk, base_def, base_spd, "
|
|
|
|
|
+ " base_crr, base_crd, base_res, base_acc, "
|
|
|
|
|
+ " current_hp, current_atk, current_def, current_spd, "
|
|
|
|
|
+ " current_crr, current_crd, current_res, current_acc "
|
|
|
|
|
+ "FROM units WHERE id = ? OR name LIKE ?",
|
|
|
|
|
+ parameters
|
|
|
|
|
+ );
|
|
|
|
|
+ int units_found = 0;
|
|
|
|
|
+ int unit_has_runes = FALSE;
|
|
|
|
|
+ char tmp[32];
|
|
|
|
|
+ while (SQLITE_ROW ==sqlite3_step(stmt_units)){
|
|
|
|
|
+ char unit_name[14];
|
|
|
|
|
+
|
|
|
|
|
+ // Print a separator between units
|
|
|
|
|
+ if (units_found > 0){
|
|
|
|
|
+ printf(
|
|
|
|
|
+ "##############################################################\n"
|
|
|
|
|
+ "##############################################################\n\n"
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ units_found ++;
|
|
|
|
|
+
|
|
|
|
|
+ printf(" ----------------------------\n");
|
|
|
|
|
+ printf(" | STAT | BASE | CURR. |\n");
|
|
|
|
|
+ printf(" ============= ----------------------------\n");
|
|
|
|
|
+ strncpy(unit_name, sqlite3_column_text(stmt_units, 1), 13);
|
|
|
|
|
+ printf(" %*s ", 14, unit_name);
|
|
|
|
|
+ printf(
|
|
|
|
|
+ "| HP: | %*d | %*d |\n",
|
|
|
|
|
+ 6, sqlite3_column_int(stmt_units, 5),
|
|
|
|
|
+ 6, sqlite3_column_int(stmt_units, 13)
|
|
|
|
|
+ );
|
|
|
|
|
+ printf(" #%*s", -13, sqlite3_column_text(stmt_units, 0));
|
|
|
|
|
+ printf(
|
|
|
|
|
+ "| ATK: | %*d | %*d |\n",
|
|
|
|
|
+ 6, sqlite3_column_int(stmt_units, 6),
|
|
|
|
|
+ 6, sqlite3_column_int(stmt_units, 14)
|
|
|
|
|
+ );
|
|
|
|
|
+ printf(
|
|
|
|
|
+ " ============= | DEF: | %*d | %*d |\n",
|
|
|
|
|
+ 6, sqlite3_column_int(stmt_units, 7),
|
|
|
|
|
+ 6, sqlite3_column_int(stmt_units, 15)
|
|
|
|
|
+ );
|
|
|
|
|
+ printf(
|
|
|
|
|
+ " | SPD: | %*d | %*d |\n",
|
|
|
|
|
+ 6, sqlite3_column_int(stmt_units, 8),
|
|
|
|
|
+ 6, sqlite3_column_int(stmt_units, 16)
|
|
|
|
|
+ );
|
|
|
|
|
+ printf(" Lv.%*d", -2, sqlite3_column_int(stmt_units, 3));
|
|
|
|
|
+ printf(" %d* ", sqlite3_column_int(stmt_units, 2));
|
|
|
|
|
+ printf(
|
|
|
|
|
+ "| CRR: | %*d% | %*d% |\n",
|
|
|
|
|
+ 6, sqlite3_column_int(stmt_units, 9),
|
|
|
|
|
+ 6, sqlite3_column_int(stmt_units, 17)
|
|
|
|
|
+ );
|
|
|
|
|
+ printf(
|
|
|
|
|
+ " | CRD: | %*d% | %*d% |\n",
|
|
|
|
|
+ 6, sqlite3_column_int(stmt_units, 10),
|
|
|
|
|
+ 6, sqlite3_column_int(stmt_units, 18)
|
|
|
|
|
+ );
|
|
|
|
|
+ printf(" Storage: ");
|
|
|
|
|
+ if (1 == sqlite3_column_int(stmt_units, 4)){
|
|
|
|
|
+ printf("Yes");
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ printf("No ");
|
|
|
|
|
+ }
|
|
|
|
|
+ printf(
|
|
|
|
|
+ " | RES: | %*d% | %*d% |\n",
|
|
|
|
|
+ 6, sqlite3_column_int(stmt_units, 11),
|
|
|
|
|
+ 6, sqlite3_column_int(stmt_units, 19)
|
|
|
|
|
+ );
|
|
|
|
|
+ printf(
|
|
|
|
|
+ " | ACC: | %*d% | %*d% |\n",
|
|
|
|
|
+ 6, sqlite3_column_int(stmt_units, 12),
|
|
|
|
|
+ 6, sqlite3_column_int(stmt_units, 20)
|
|
|
|
|
+ );
|
|
|
|
|
+ printf(
|
|
|
|
|
+ " | EHP: | %*d | %*d |\n",
|
|
|
|
|
+ 6,
|
|
|
|
|
+ optimize_calculate_ehp(
|
|
|
|
|
+ sqlite3_column_int(stmt_units, 5),
|
|
|
|
|
+ sqlite3_column_int(stmt_units, 7)
|
|
|
|
|
+ ),
|
|
|
|
|
+ 6,
|
|
|
|
|
+ optimize_calculate_ehp(
|
|
|
|
|
+ sqlite3_column_int(stmt_units, 13),
|
|
|
|
|
+ sqlite3_column_int(stmt_units, 15)
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
+ printf(
|
|
|
|
|
+ " | DMG: | %*d | %*d |\n",
|
|
|
|
|
+ 6,
|
|
|
|
|
+ optimize_calculate_dmg(
|
|
|
|
|
+ sqlite3_column_int(stmt_units, 6),
|
|
|
|
|
+ sqlite3_column_int(stmt_units, 9),
|
|
|
|
|
+ sqlite3_column_int(stmt_units, 10)
|
|
|
|
|
+ ),
|
|
|
|
|
+ 6,
|
|
|
|
|
+ optimize_calculate_dmg(
|
|
|
|
|
+ sqlite3_column_int(stmt_units, 14),
|
|
|
|
|
+ sqlite3_column_int(stmt_units, 17),
|
|
|
|
|
+ sqlite3_column_int(stmt_units, 18)
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
+ printf(" ----------------------------\n");
|
|
|
|
|
+
|
|
|
|
|
+ // Get runes
|
|
|
|
|
+ strcpy(tmp, sqlite3_column_text(stmt_units, 0));
|
|
|
|
|
+ char *rune_parameters[1] = {tmp};
|
|
|
|
|
+ db_query(
|
|
|
|
|
+ &stmt_runes,
|
|
|
|
|
+ "SELECT "
|
|
|
|
|
+ " id, slot, type, stars, "
|
|
|
|
|
+ " level, quality, efficiency, max_efficiency "
|
|
|
|
|
+ "FROM runes WHERE unit = ? "
|
|
|
|
|
+ "ORDER BY slot = 3, slot = 4, slot = 5, slot = 2, slot = 1, slot = 6",
|
|
|
|
|
+ rune_parameters
|
|
|
|
|
+ );
|
|
|
|
|
+ for (int i = 0; i < 30; i ++){
|
|
|
|
|
+ if (i == 0 || i == 13 || i == 15 || i == 28){
|
|
|
|
|
+ strcpy(
|
|
|
|
|
+ rune_lines[i],
|
|
|
|
|
+ " ------------------- "
|
|
|
|
|
+ " ------------------- "
|
|
|
|
|
+ " -------------------\n"
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (i == 3 || i == 10 || i == 18 || i == 25){
|
|
|
|
|
+ strcpy(
|
|
|
|
|
+ rune_lines[i],
|
|
|
|
|
+ " |-----------------| "
|
|
|
|
|
+ " |-----------------| "
|
|
|
|
|
+ " |-----------------|\n"
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (
|
|
|
|
|
+ i == 1 || i == 2 || (i > 3 && i < 10) ||i == 11 ||
|
|
|
|
|
+ i == 12 || i == 16 || i == 17 || (i > 18 && i < 29)
|
|
|
|
|
+ ){
|
|
|
|
|
+ strcpy(
|
|
|
|
|
+ rune_lines[i],
|
|
|
|
|
+ " | | "
|
|
|
|
|
+ " | | "
|
|
|
|
|
+ " | |\n"
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ strcpy(rune_lines[i], "\n");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ unit_has_runes = FALSE;
|
|
|
|
|
+ while (SQLITE_ROW == sqlite3_step(stmt_runes)){
|
|
|
|
|
+ unit_has_runes = TRUE;
|
|
|
|
|
+ int slot = sqlite3_column_int(stmt_runes, 1);
|
|
|
|
|
+ int top_line_to_add = -1;
|
|
|
|
|
+ int position_to_add = -1;
|
|
|
|
|
+ if (slot == 6 || slot == 1 || slot == 2){
|
|
|
|
|
+ top_line_to_add = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ top_line_to_add = 15;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (slot == 6 || slot == 5){
|
|
|
|
|
+ position_to_add = 3;
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (slot == 1 || slot == 4){
|
|
|
|
|
+ position_to_add = 24;
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ position_to_add = 45;
|
|
|
|
|
+ }
|
|
|
|
|
+ // Rune slot
|
|
|
|
|
+ strncpy(
|
|
|
|
|
+ rune_lines[top_line_to_add + 1] + position_to_add,
|
|
|
|
|
+ sqlite3_column_text(stmt_runes, 1),
|
|
|
|
|
+ 1
|
|
|
|
|
+ );
|
|
|
|
|
+ // Slot / ID separator
|
|
|
|
|
+ strncpy(
|
|
|
|
|
+ rune_lines[top_line_to_add + 1] + position_to_add + 1, "| #", 3
|
|
|
|
|
+ );
|
|
|
|
|
+ // ID
|
|
|
|
|
+ strncpy(
|
|
|
|
|
+ rune_lines[top_line_to_add + 1] + position_to_add + 4,
|
|
|
|
|
+ sqlite3_column_text(stmt_runes, 0),
|
|
|
|
|
+ strlen(sqlite3_column_text(stmt_runes, 0))
|
|
|
|
|
+ );
|
|
|
|
|
+ // Set name
|
|
|
|
|
+ strncpy(
|
|
|
|
|
+ rune_lines[top_line_to_add + 2] + position_to_add,
|
|
|
|
|
+ set_names[sqlite3_column_int(stmt_runes, 2)],
|
|
|
|
|
+ strlen(set_names[sqlite3_column_int(stmt_runes, 2)])
|
|
|
|
|
+ );
|
|
|
|
|
+ // Power up level
|
|
|
|
|
+ strncpy(
|
|
|
|
|
+ rune_lines[top_line_to_add + 2] + position_to_add + 7,
|
|
|
|
|
+ " + ",
|
|
|
|
|
+ 7
|
|
|
|
|
+ );
|
|
|
|
|
+ strncpy(
|
|
|
|
|
+ rune_lines[top_line_to_add + 2] + position_to_add + 9,
|
|
|
|
|
+ sqlite3_column_text(stmt_runes, 4),
|
|
|
|
|
+ strlen(sqlite3_column_text(stmt_runes, 4))
|
|
|
|
|
+ );
|
|
|
|
|
+ // Stars
|
|
|
|
|
+ strncpy(
|
|
|
|
|
+ rune_lines[top_line_to_add + 2] + position_to_add + 13,
|
|
|
|
|
+ sqlite3_column_text(stmt_runes, 3),
|
|
|
|
|
+ 1
|
|
|
|
|
+ );
|
|
|
|
|
+ strncpy(
|
|
|
|
|
+ rune_lines[top_line_to_add + 2] + position_to_add + 14, "*", 1
|
|
|
|
|
+ );
|
|
|
|
|
+ // Quality
|
|
|
|
|
+ strncpy(
|
|
|
|
|
+ rune_lines[top_line_to_add + 11] + position_to_add,
|
|
|
|
|
+ quality_names[sqlite3_column_int(stmt_runes, 5)],
|
|
|
|
|
+ strlen(quality_names[sqlite3_column_int(stmt_runes, 5)])
|
|
|
|
|
+ );
|
|
|
|
|
+ // Efficiency
|
|
|
|
|
+ sprintf(
|
|
|
|
|
+ tmp,
|
|
|
|
|
+ "%6.2f%%/%6.2f%%",
|
|
|
|
|
+ sqlite3_column_double(stmt_runes, 6),
|
|
|
|
|
+ sqlite3_column_double(stmt_runes, 7)
|
|
|
|
|
+ );
|
|
|
|
|
+ strncpy(
|
|
|
|
|
+ rune_lines[top_line_to_add + 12] + position_to_add,
|
|
|
|
|
+ tmp,
|
|
|
|
|
+ strlen(tmp)
|
|
|
|
|
+ );
|
|
|
|
|
+ // Get stats
|
|
|
|
|
+ strcpy(tmp, sqlite3_column_text(stmt_runes, 0));
|
|
|
|
|
+ char *stat_parameters[1] = {tmp};
|
|
|
|
|
+ db_query(
|
|
|
|
|
+ &stmt_stats,
|
|
|
|
|
+ "SELECT slot, stat, value, grind, enchant "
|
|
|
|
|
+ "FROM rune_stats WHERE rune = ? ORDER BY slot",
|
|
|
|
|
+ stat_parameters
|
|
|
|
|
+ );
|
|
|
|
|
+ while (SQLITE_ROW == sqlite3_step(stmt_stats)){
|
|
|
|
|
+ // Stat name and value
|
|
|
|
|
+ sprintf(
|
|
|
|
|
+ tmp,
|
|
|
|
|
+ stat_names_printable[sqlite3_column_int(stmt_stats, 1)],
|
|
|
|
|
+ sqlite3_column_int(stmt_stats, 2)
|
|
|
|
|
+ );
|
|
|
|
|
+ strncpy(
|
|
|
|
|
+ rune_lines[
|
|
|
|
|
+ top_line_to_add + 5 + sqlite3_column_int(stmt_stats, 0)
|
|
|
|
|
+ ] + position_to_add,
|
|
|
|
|
+ tmp,
|
|
|
|
|
+ 9
|
|
|
|
|
+ );
|
|
|
|
|
+ // Enchanted?
|
|
|
|
|
+ if (1 == sqlite3_column_int(stmt_stats, 4)){
|
|
|
|
|
+ strncpy(
|
|
|
|
|
+ rune_lines[top_line_to_add + 5 + sqlite3_column_int(stmt_stats, 0)] + position_to_add + 9,
|
|
|
|
|
+ "*",
|
|
|
|
|
+ 1
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ // Grinded?
|
|
|
|
|
+ if (0 < sqlite3_column_int(stmt_stats, 3)){
|
|
|
|
|
+ sprintf(tmp, "+%-4d", sqlite3_column_int(stmt_stats, 3));
|
|
|
|
|
+ strncpy(
|
|
|
|
|
+ rune_lines[top_line_to_add + 5 + sqlite3_column_int(stmt_stats, 0)] + position_to_add + 10,
|
|
|
|
|
+ tmp,
|
|
|
|
|
+ 5
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ sqlite3_finalize(stmt_stats);
|
|
|
|
|
+ }
|
|
|
|
|
+ sqlite3_finalize(stmt_runes);
|
|
|
|
|
+ if (TRUE == unit_has_runes){
|
|
|
|
|
+ for (int i = 0; i < 30; i ++){
|
|
|
|
|
+ printf("%s",rune_lines[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ sqlite3_finalize(stmt_units);
|
|
|
|
|
+ return(units_found);
|
|
|
|
|
+}
|