/* * 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 . */ /** * @file update.c * * Implementation of the update command. * * This file implements the update command declared in {@link update.h}. */ #include #include #include "../runeoptimizer.h" #include "../error/error.h" #include "update.h" const int MAIN_STATS_VALUES[DIFFERENT_STATS][RUNE_MAX_STARS + 1][2] = { { //NULL (unused) {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} }, { //HP_FLAT {0, 0}, // 0 stars (unused) {580, 804}, // 1 stars {790, 1092}, // 2 stars {1000, 1380}, // 3 stars {1240, 1704}, // 4 stars {1530, 2088}, // 5 stars {1800, 2448} // 6 stars }, { //HP_PERCENT {0, 0}, // 0 stars (unused) {13, 18}, // 1 stars {14, 19}, // 2 stars {28, 38}, // 3 stars {31, 43}, // 4 stars {37, 51}, // 5 stars {47, 63} // 6 stars }, { //ATK_FLAT {0, 0}, // 0 stars (unused) {39, 54}, // 1 stars {53, 73}, // 2 stars {67, 92}, // 3 stars {82, 112}, // 4 stars {99, 135}, // 5 stars {118, 160}, // 6 stars }, { //ATK_PERCENT {0, 0}, // 0 stars (unused) {13, 18}, // 1 stars {14, 19}, // 2 stars {28, 38}, // 3 stars {31, 43}, // 4 stars {37, 51}, // 5 stars {47, 63} // 6 stars }, { //DEF_FLAT {0, 0}, // 0 stars (unused) {39, 54}, // 1 stars {53, 73}, // 2 stars {67, 92}, // 3 stars {82, 112}, // 4 stars {99, 135}, // 5 stars {118, 160}, // 6 stars }, { //DEF_PERCENT {0, 0}, // 0 stars (unused) {13, 18}, // 1 stars {14, 19}, // 2 stars {28, 38}, // 3 stars {31, 43}, // 4 stars {37, 51}, // 5 stars {47, 63} // 6 stars }, { //NULL (unused) {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} }, { //SPD {0, 0}, // 0 stars (unused) {13, 18}, // 1 stars {14, 19}, // 2 stars {18, 25}, // 3 stars {22, 30}, // 4 stars {29, 39}, // 5 stars {31, 42} // 6 stars }, { //CRR {0, 0}, // 0 stars (unused) {13, 18}, // 1 stars {14, 19}, // 2 stars {27, 37}, // 3 stars {30, 41}, // 4 stars {34, 47}, // 5 stars {43, 58} // 6 stars }, { //CRD {0, 0}, // 0 stars (unused) {14, 19}, // 1 stars {27, 37}, // 2 stars {32, 43}, // 3 stars {42, 57}, // 4 stars {48, 65}, // 5 stars {59, 80} // 6 stars }, { //RES {0, 0}, // 0 stars (unused) {13, 18}, // 1 stars {14, 19}, // 2 stars {28, 38}, // 3 stars {32, 44}, // 4 stars {38, 51}, // 5 stars {48, 64} // 6 stars }, { //ACC {0, 0}, // 0 stars (unused) {13, 18}, // 1 stars {14, 19}, // 2 stars {28, 38}, // 3 stars {32, 44}, // 4 stars {38, 51}, // 5 stars {48, 64} // 6 stars } }; extern int update(int argc, char *argv[]){ // Options unsigned char six_stars = FALSE; unsigned char with_runes = FALSE; unsigned char clear_teams = FALSE; unsigned char gui = FALSE; // One argument mandatory if (argc == 0){ fprintf( stderr, "update command takes 1 or more arguments, %d supplied\n", argc - 3 ); return ERROR_INPUT_UPDATE_NO_ARGUMENTS; } // Parse options, skip first arg for (int i = 1; i < argc; i ++){ if (strcmp("--six-stars", argv[i]) == 0 || strcmp("-s", argv[i]) == 0){ six_stars = TRUE; } else if ( strcmp("--with-runes", argv[i]) == 0 || strcmp("-r", argv[i]) == 0 ){ with_runes = TRUE; } else if ( strcmp("--clear-teams", argv[i]) == 0 || strcmp("-t", argv[i]) == 0 ){ clear_teams = TRUE; } else if ( strcmp("--gui", argv[i]) == 0 || strcmp("-g", argv[i]) == 0 ){ gui = TRUE; } } // First, test json if (strlen(argv[0]) > 5){ char extension[6]; strncpy(extension, argv[0] + strlen(argv[0]) - 5, 5); extension[5] = '\0'; if (strcmp(extension, ".json") == 0){ return update_json( argv[0], six_stars, with_runes, clear_teams, gui ); } } // TODO: More ifs as more options are implemented... fprintf(stderr, "Unknwon source supplied: %s\n", argv[0]); return ERROR_INPUT_UPDATE_UNKNOWN_SOURCE; }