| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839 |
- /*
- * 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/>.
- */
- /**
- * @file runeoptimizer.h
- *
- * Declarations of the functions and data types used across the application.
- *
- * This file declares all the functions and data types used from anywhere in the
- * program.
- */
- #pragma once
- #include <sqlite3.h>
- /**
- * Application version.
- *
- * Metadata, only used in the help and version commands.
- */
- #define VERSION "0.1-RC1"
- /**
- * Application author.
- *
- * Metadata, only used in the help command.
- */
- #define AUTHOR "Iñigo Valentin"
- /**
- * Application author email.
- *
- * Metadata, only used in the help command.
- */
- #define MAIL "i@inigovalentin.com"
- /**
- * Boolean value TRUE.
- *
- * Mocked boolean for consistence across functions.
- */
- #define TRUE 1
- /**
- * Boolean value FALSE.
- *
- * Mocked boolean for consistence across functions.
- */
- #define FALSE 0
- /**
- * Energy Set.
- *
- * Set ID of Energy runes, as given by Com2Us.
- */
- #define ENERGY 1
- /**
- * Guard Set.
- *
- * Set ID of Guard runes, as given by Com2Us.
- */
- #define GUARD 2
- /**
- * Swift Set.
- *
- * Set ID of Swift runes, as given by Com2Us.
- */
- #define SWIFT 3
- /**
- * Blade Set.
- *
- * Set ID of Blade runes, as given by Com2Us.
- */
- #define BLADE 4
- /**
- * Rage Set.
- *
- * Set ID of Rage runes, as given by Com2Us.
- */
- #define RAGE 5
- /**
- * Focus Set.
- *
- * Set ID of Focus runes, as given by Com2Us.
- */
- #define FOCUS 6
- /**
- * Endure Set.
- *
- * Set ID of Endure runes, as given by Com2Us.
- */
- #define ENDURE 7
- /**
- * Fatal Set.
- *
- * Set ID of Fatal runes, as given by Com2Us.
- */
- #define FATAL 8
- /**
- * Despair Set.
- *
- * Set ID of Despair runes, as given by Com2Us.
- */
- #define DESPAIR 10
- /**
- * Vampire Set.
- *
- * Set ID of Vampire runes, as given by Com2Us.
- */
- #define VAMPIRE 11
- /**
- * Violent Set.
- *
- * Set ID of Violent runes, as given by Com2Us.
- */
- #define VIOLENT 13
- /**
- * Nemesis Set.
- *
- * Set ID of Nemesis runes, as given by Com2Us.
- */
- #define NEMESIS 14
- /**
- * Will Set.
- *
- * Set ID of Will runes, as given by Com2Us.
- */
- #define WILL 15
- /**
- * Shield Set.
- *
- * Set ID of Shield runes, as given by Com2Us.
- */
- #define SHIELD 16
- /**
- * Revenge Set.
- *
- * Set ID of Revenge runes, as given by Com2Us.
- */
- #define REVENGE 17
- /**
- * Destroy Set.
- *
- * Set ID of Destroy runes, as given by Com2Us.
- */
- #define DESTROY 18
- /**
- * Fight Set.
- *
- * Set ID of Fight runes, as given by Com2Us.
- */
- #define FIGHT 19
- /**
- * Determination Set.
- *
- * Set ID of Determination runes, as given by Com2Us.
- */
- #define DETERMINATION 20
- /**
- * Enhance Set.
- *
- * Set ID of Enhance runes, as given by Com2Us.
- */
- #define ENHANCE 21
- /**
- * Accuracy Set.
- *
- * Set ID of Accuracy runes, as given by Com2Us.
- */
- #define ACCURACY 22
- /**
- * Tolerance Set.
- *
- * Set ID of Tolerance runes, as given by Com2Us.
- */
- #define TOLERANCE 23
- /**
- * HP rune stat.
- *
- * Rune stat ID for HP in runes, as given by Com2Us.
- */
- #define HP_FLAT 1
- /**
- * HP% rune stat.
- *
- * Rune stat ID for HP% in runes, as given by Com2Us.
- */
- #define HP_PERCENT 2
- /**
- * ATK rune stat.
- *
- * Rune stat ID for ATK in runes, as given by Com2Us.
- */
- #define ATK_FLAT 3
- /**
- * ATK% rune stat.
- *
- * Rune stat ID for ATK% in runes, as given by Com2Us.
- */
- #define ATK_PERCENT 4
- /**
- * DEF rune stat.
- *
- * Rune stat ID for DEF in runes, as given by Com2Us.
- */
- #define DEF_FLAT 5
- /**
- * DEF% rune stat.
- *
- * Rune stat ID for DEF% in runes, as given by Com2Us.
- */
- #define DEF_PERCENT 6
- /**
- * SPD rune stat.
- *
- * Rune stat ID for SPD in runes, as given by Com2Us.
- */
- #define SPD 8
- /**
- * CRR rune stat.
- *
- * Rune stat ID for CRR in runes, as given by Com2Us.
- */
- #define CRR 9
- /**
- * CRD rune stat.
- *
- * Rune stat ID for CRD in runes, as given by Com2Us.
- */
- #define CRD 10
- /**
- * RES rune stat.
- *
- * Rune stat ID for RES in runes, as given by Com2Us.
- */
- #define RES 11
- /**
- * ACC rune stat.
- *
- * Rune stat ID for ACC in runes, as given by Com2Us.
- */
- #define ACC 12
- /**
- * Maximum length of Unit IDs.
- *
- * It can never be higher thahn this.
- */
- #define UNIT_ID_LEN 14
- /**
- * Maximum length of Unit name.
- *
- * It can never be higher thahn this.
- */
- #define UNIT_NAME_LEN 128
- /**
- * Maximum length of Rune IDs.
- *
- * It can never be higher thahn this.
- */
- #define RUNE_ID_LEN 14
- /**
- * Maximum length of Teams IDs.
- *
- * It can never be higher thahn this.
- */
- #define TEAM_ID_LEN 4
- /**
- * Length for the database file path.
- *
- * Totally arbitrary.
- * @todo This may be worriesome.
- */
- #define DB_PATH_LEN 512
- /**
- * Rune slots.
- *
- * Number of rune slots. In-game, and in many parts of this program, slots are
- * used with a 1-index.
- */
- #define RUNE_SLOTS 6
- /**
- * CRR Cap.
- *
- * Critical rate does nothing over 100%, so for more realistic calcultations,
- * it's better to have it capped.
- */
- #define CRR_CAP 100.0f
- /**
- * RES Cap.
- *
- * Resistance does nothing over 100%, so for more realistic calcultations, it's
- * better to have it capped.
- */
- #define RES_CAP 100.0f
- /**
- * ACC Cap.
- *
- * In the game, accurary is effectively capped at 85%, so for more realistic
- * calcultations, it's better to have it capped.
- */
- #define ACC_CAP 85.0f
- /**
- * Number of stats defined in the game.
- *
- * It's not actually 13, because 0 and 7 are never used in game, but is a good
- * value for counters and loops.
- */
- #define DIFFERENT_STATS 13
- /**
- * Number of rune sets defined in the game.
- *
- * It's not actually 25, because 0, 9 and 12 are never used in game, but is a
- * good value for counters and loops.
- */
- #define DIFFERENT_SETS 25
- /**
- * Number of rune sets defined in the game.
- *
- * It's not actually 26, because a lot of them are never used in game, but is a
- * good value for counters and loops.
- */
- #define DIFFERENT_QUALITIES 16
- /**
- * Rune max stars.
- *
- * Watch out, a rune can't have 0 stars, so in loos, better start at 1.
- */
- #define RUNE_MAX_STARS 6
- /**
- * Structure representing a unit.
- *
- * Represents an entity from the table 'unit', but is doesn't have that mucha
- * data, just the mambers needed for optimization and some other thigs. For a
- * more complete representation of the table, {@link DB_Unit} can be used.
- */
- typedef struct Unit {
- /**
- * Unit ID.
- *
- * The ID as given by Com2Us.
- */
- unsigned char id[UNIT_ID_LEN];
- /**
- * The Unit name.
- *
- * The name as given by Com2Us, except for Homunculus. For them, the user
- * given by the naem will be used.
- */
- unsigned char name[UNIT_NAME_LEN];
- /**
- * The unit base HP.
- *
- * The Unit HP, at it's current level, without counting runes, artifacts,
- * towers...
- */
- unsigned int base_hp;
- /**
- * The unit base ATK.
- *
- * The Unit ATK, at it's current level, without counting runes, artifacts,
- * towers...
- */
- unsigned short base_atk;
- /**
- * The unit base DEF.
- *
- * The Unit DEF, at it's current level, without counting runes, artifacts,
- * towers...
- */
- unsigned short base_def;
- /**
- * The unit base SPD.
- *
- * The Unit SPD, at it's current level, without counting runes, artifacts,
- * towers...
- */
- unsigned short base_spd;
- /**
- * The unit base CRR.
- *
- * The Unit CRR, at it's current level, without counting runes, artifacts,
- * towers...
- */
- unsigned short base_crr;
- /**
- * The unit base CRD.
- *
- * The Unit CRD, at it's current level, without counting runes, artifacts,
- * towers...
- */
- unsigned short base_crd;
- /**
- * The unit base RES.
- *
- * The Unit RES, at it's current level, without counting runes, artifacts,
- * towers...
- */
- unsigned short base_res;
- /**
- * The unit base ACC.
- *
- * The Unit ACC, at it's current level, without counting runes, artifacts,
- * towers...
- */
- unsigned short base_acc;
- /**
- * The unit base EHP.
- *
- * The Unit EHP, at it's current level, without counting runes, artifacts,
- * towers... See {@link calculate_ehp} for more details bout EHP.
- */
- unsigned int base_ehp;
- /**
- * The unit base DMG.
- *
- * The Unit DMG, at it's current level, without counting runes, artifacts,
- * towers...See {@link calculate_ehp} for more details bout EHP.
- */
- unsigned short base_dmg;
- /**
- * The unit base HP.
- *
- * The Unit HP, at it's current level, counting equiped runes, but not
- * artifacts or towers.
- */
- unsigned int current_hp;
- /**
- * The unit base ATK.
- *
- * The Unit ATK, at it's current level, counting equiped runes, but not
- * artifacts or towers.
- */
- unsigned short current_atk;
- /**
- * The unit base DEF.
- *
- * The Unit DEF, at it's current level, counting equiped runes, but not
- * artifacts or towers.
- */
- unsigned short current_def;
- /**
- * The unit base SPD.
- *
- * The Unit SPD, at it's current level, counting equiped runes, but not
- * artifacts or towers.
- */
- unsigned short current_spd;
- /**
- * The unit base CRR.
- *
- * The Unit CRR, at it's current level, counting equiped runes, but not
- * artifacts or towers.
- */
- unsigned short current_crr;
- /**
- * The unit base CRD.
- *
- * The Unit CRD, at it's current level, counting equiped runes, but not
- * artifacts or towers.
- */
- unsigned short current_crd;
- /**
- * The unit base RES.
- *
- * The Unit RES, at it's current level, counting equiped runes, but not
- * artifacts or towers.
- */
- unsigned short current_res;
- /**
- * The unit base ACC.
- *
- * The Unit ACC, at it's current level, counting equiped runes, but not
- * artifacts or towers.
- */
- unsigned short current_acc;
- /**
- * The unit base EHP.
- *
- * The Unit EHP, at it's current level, counting equiped runes, but not
- * artifacts or towers.See {@link calculate_ehp} for more details bout EHP.
- */
- unsigned int current_ehp;
- /**
- * The unit base DMG.
- *
- * The Unit DMG, at it's current level, counting equiped runes, but not
- * artifacts or towers. See {@link calculate_ehp} for more details bout EHP.
- */
- unsigned short current_dmg;
- } Unit;
- /**
- * Number of runes for a given list of runes.
- *
- * It just holds numbers of rune sets. See {@link optimize_count_runes_for_sets}
- * for a use case.
- */
- typedef struct Rune_Set_Count {
- /**
- * Energy count.
- *
- * Number of Energy runes.
- */
- unsigned short energy;
- /**
- * Guard count.
- *
- * Number of Guard runes.
- */
- unsigned short guard;
- /**
- * Swift count.
- *
- * Number of Swift runes.
- */
- unsigned short swift;
- /**
- * Blade count.
- *
- * Number of Blade runes.
- */
- unsigned short blade;
- /**
- * Rage count.
- *
- * Number of Rage runes.
- */
- unsigned short rage;
- /**
- * Focus count.
- *
- * Number of Focus runes.
- */
- unsigned short focus;
- /**
- * Endure count.
- *
- * Number of Endure runes.
- */
- unsigned short endure;
- /**
- * Fatal count.
- *
- * Number of Fatal runes.
- */
- unsigned short fatal;
- /**
- * Despair count.
- *
- * Number of Despair runes.
- */
- unsigned short despair;
- /**
- * Vampire count.
- *
- * Number of Vampire runes.
- */
- unsigned short vampire;
- /**
- * Violent count.
- *
- * Number of Violent runes.
- */
- unsigned short violent;
- /**
- * Nemesis count.
- *
- * Number of Nemesis runes.
- */
- unsigned short nemesis;
- /**
- * Will count.
- *
- * Number of Will runes.
- */
- unsigned short will;
- /**
- * Shield count.
- *
- * Number of Shield runes.
- */
- unsigned short shield;
- /**
- * Revenge count.
- *
- * Number of Revenge runes.
- */
- unsigned short revenge;
- /**
- * Destroy count.
- *
- * Number of Destroy runes.
- */
- unsigned short destroy;
- /**
- * Fight count.
- *
- * Number of Fight runes.
- */
- unsigned short fight;
- /**
- * Determination count.
- *
- * Number of Determination runes.
- */
- unsigned short determination;
- /**
- * Enhance count.
- *
- * Number of Enhance runes.
- */
- unsigned short enhance;
- /**
- * Accuracy count.
- *
- * Number of Accuracy runes.
- */
- unsigned short accuracy;
- /**
- * Tolerance count.
- *
- * Number of Tolerance runes.
- */
- unsigned short tolerance;
- } Rune_Set_Count;
- /**
- * Names for run stats.
- *
- * Indexed by Com2Us ID. Watch out for indexes 0 and 7, they are undefined in
- * the game.
- */
- extern const char STAT_NAMES[DIFFERENT_STATS][9];
- /**
- * Names for rune sets.
- *
- * Indexed by Com2Us ID.Watch out for indexes 0, 9 and 12, they are undefined in
- * the game.
- */
- extern const char SET_NAMES[DIFFERENT_SETS][9];
- /**
- * Names for rune qualities.
- *
- * Indexed by Com2Us ID. 1-5 are qualities for normal runes, 11-15 for ancient
- * runes. All the others are not defined in the game,
- */
- extern const char QUALITY_NAMES[DIFFERENT_QUALITIES][9];
- /**
- * Names for rune stats, in a printable format.
- *
- * They hold a 4 digit stat, padded to the right, with a percent sign on the
- * right for the stats that are percentual. All padded to the right with a
- * single space, for a total length of 10 characters.
- *
- * Indexed by Com2Us ID. Watch out for indexes 0 and 7, they are undefined in
- * the game.
- */
- extern const char STAT_NAMES_PRINTABLE[DIFFERENT_STATS][12];
- /**
- * Names for rune sets.
- *
- * Thy don't indicate if it's for a flat or a percentile stat.
- *
- * Indexed by Com2Us ID.Watch out for indexes 0, 9 and 12, they are undefined in
- * the game.
- */
- extern const char STAT_NAMES_UNSIGNED[DIFFERENT_STATS][4];
- /**
- * Max roll values for each stat.
- *
- * Used for efficiency calculations. Indexed by
- * - Stat id (indexes 0 and 7 undefined in game).
- * - Rune stars (1-6, dont use index 0).
- *
- * @todo For ancient runes, the initial rolls are higher.
- */
- extern const int STAT_ROLL_MAX[DIFFERENT_STATS][RUNE_MAX_STARS + 1];
- /**
- * Global database connection.
- *
- * Used across the app. Opened in {@link db_open}.
- */
- extern sqlite3 *db;
- /**
- * Path to the database.
- *
- * When possible, use be an absolute path.
- */
- extern char db_location[DB_PATH_LEN];
- /**
- * Calculates effective HP.
- *
- * EHP is a complex stat, depending on HP and DEF. In short, the formula is
- * ((( def * 3.5) + 1140) * hp) / 1000 .
- *
- * @param[in] hp HP stat.
- * @param[in] def DEF stat.
- * @return Calculated EHP.
- */
- extern unsigned int calculate_ehp(unsigned int hp, unsigned short def);
- /**
- * Calculates damage.
- *
- * DMG is a complex stat, depending on ATK, CRR and CRD. In short, the formula
- * is
- * (atk * ((100 - crr) / 100)) + (atk * (crr / 100) * ((100 + crd) / 100)) .
- *
- * @param[in] atk ATK stat.
- * @param[in] crr CRR stat.
- * @param[in] crd CRD stat.
- * @return Calculated DMG.
- */
- extern unsigned short calculate_dmg(
- unsigned short atk, unsigned short crr, unsigned short crd
- );
- /**
- * Starts the program.
- *
- * Reads command line parameters and runs the appropiate command.
- *
- * @param argc Number of arguments passed to the program.
- * @param argv Arguments passed to the program.
- * @return SUCCESS on success, other on error. Most errors are listed in
- * <a href="file:../error/error.h">../error/error.h</a>
- */
- int main(int argc, char *argv[]);
|