Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

Commit

Permalink
Splitting the library into the c part that does the work and the node…
Browse files Browse the repository at this point in the history
… interface.
  • Loading branch information
gsmcwhirter committed May 25, 2013
1 parent 893d5c7 commit 3550c82
Show file tree
Hide file tree
Showing 5 changed files with 369 additions and 357 deletions.
1 change: 1 addition & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"target_name": "swtor_tanking_optimizer"
, "sources": [
"src/swtor_tanking_optimizer.cc"
, "src/optimizer.c"
, "src/randomkit.c"
]
, "libraries": [
Expand Down
107 changes: 107 additions & 0 deletions include/optimizer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#ifndef OPTIMIZER_H
#define OPTIMIZER_H

#define RELIC_TYPE_PROC 1
#define RELIC_TYPE_CLICK 2

#define RELIC_STATTYPE_DEF 1
#define RELIC_STATTYPE_SHIELD 2
#define RELIC_STATTYPE_ABSORB 3

#ifdef __cplusplus
extern "C" {
#endif

struct ClassData {
double defenseAdd;
double defenseBonus;
double shieldAdd;
double shieldBonus;
double absorbAdd;
double absorbBonus;
double drAddKE;
double drAddIE;
double drBonus;
double resistPct;
unsigned int useKW;
};

typedef struct ClassData classdata_t;

struct StatDistribution {
unsigned int defRating;
unsigned int shieldRating;
unsigned int absorbRating;
};

typedef struct StatDistribution statdist_t;

struct DamageTypes {
double MRKE;
double FTKE;
double FTIE;
};

typedef struct DamageTypes dmgtypes_t;

struct OptimizerResult {
statdist_t *stats;
double mitigation;
};

typedef struct OptimizerResult oresult_t;

struct ShieldBounds {
double low;
double high;
};

typedef struct ShieldBounds shieldbounds_t;

struct ProcRelic {
unsigned int stat;
unsigned int bonus_rating;
double rate;
double duration_time;
double cooldown_time;
unsigned int can_stack;
};

typedef struct ProcRelic procrelic_t;

struct ClickRelic {
unsigned int stat1;
unsigned int stat2;
unsigned int bonus_rating1;
unsigned int bonus_rating2;
double duration_time;
double cooldown_time;
};

typedef struct ClickRelic clickrelic_t;

union Relic {
procrelic_t *prelic;
clickrelic_t *crelic;
};

typedef union Relic relic_t;

double kineticWardAvgAbsorbBonus(dmgtypes_t *dtypes, double def_miss_pct, double resist_pct, double shield_pct, double time_per_swing);
double relicBonusPct(const unsigned int base_rating, const unsigned int bonus_rating, unsigned int stat);
double procRelicUptime(procrelic_t *relic, dmgtypes_t *dtypes, double def_miss_pct, double resist_pct, double shield_pct, double time_per_swing);
double clickRelicUptime(clickrelic_t *relic);
double defenseChance(const unsigned int rating, const double bonus);
double shieldChance(const unsigned int rating, const double bonus);
double absorbChance(const unsigned int rating, const double bonus);
double dmgReductionKE(const unsigned int armor, const double bonus);
double dmgReductionIE(const double bonus);
double mitigation(dmgtypes_t *dtypes, classdata_t *cdata, statdist_t *stats, unsigned int armor, unsigned int stimDefense, int num_relics, relic_t **relics, unsigned int *relictypes, double time_per_swing);
statdist_t * randomStats(shieldbounds_t * sbounds, const unsigned int budget, rk_state *rand_state_ptr);
oresult_t * optimalStats(dmgtypes_t *dtypes, shieldbounds_t * sbounds, classdata_t *cdata, unsigned int statBudget, unsigned int armor, int num_relics, relic_t **relics, unsigned int *relictypes, unsigned int stimBonus, double time_per_swing, unsigned int numSamples, rk_state *rand_state_ptr);

#ifdef __cplusplus
}
#endif

#endif
98 changes: 0 additions & 98 deletions include/swtor_tanking_optimizer.h
Original file line number Diff line number Diff line change
@@ -1,104 +1,6 @@
#ifndef SWTOR_TANKING_H
#define SWTOR_TANKING_H

#define RELIC_TYPE_PROC 1
#define RELIC_TYPE_CLICK 2

#define RELIC_STATTYPE_DEF 1
#define RELIC_STATTYPE_SHIELD 2
#define RELIC_STATTYPE_ABSORB 3

extern "C" {
struct ClassData {
double defenseAdd;
double defenseBonus;
double shieldAdd;
double shieldBonus;
double absorbAdd;
double absorbBonus;
double drAddKE;
double drAddIE;
double drBonus;
double resistPct;
unsigned int useKW;
};

typedef struct ClassData classdata_t;

struct StatDistribution {
unsigned int defRating;
unsigned int shieldRating;
unsigned int absorbRating;
};

typedef struct StatDistribution statdist_t;

struct DamageTypes {
double MRKE;
double FTKE;
double FTIE;
};

typedef struct DamageTypes dmgtypes_t;

struct OptimizerResult {
statdist_t *stats;
double mitigation;
};

typedef struct OptimizerResult oresult_t;

struct ShieldBounds {
double low;
double high;
};

typedef struct ShieldBounds shieldbounds_t;

struct ProcRelic {
unsigned int stat;
unsigned int bonus_rating;
double rate;
double duration_time;
double cooldown_time;
unsigned int can_stack;
};

typedef struct ProcRelic procrelic_t;

struct ClickRelic {
unsigned int stat1;
unsigned int stat2;
unsigned int bonus_rating1;
unsigned int bonus_rating2;
double duration_time;
double cooldown_time;
};

typedef struct ClickRelic clickrelic_t;

union Relic {
procrelic_t *prelic;
clickrelic_t *crelic;
};

typedef union Relic relic_t;

double kineticWardAvgAbsorbBonus(dmgtypes_t *dtypes, double def_miss_pct, double resist_pct, double shield_pct, double time_per_swing);
double relicBonusPct(const unsigned int base_rating, const unsigned int bonus_rating, unsigned int stat);
double procRelicUptime(procrelic_t *relic, dmgtypes_t *dtypes, double def_miss_pct, double resist_pct, double shield_pct, double time_per_swing);
double clickRelicUptime(clickrelic_t *relic);
double defenseChance(const unsigned int rating, const double bonus);
double shieldChance(const unsigned int rating, const double bonus);
double absorbChance(const unsigned int rating, const double bonus);
double dmgReductionKE(const unsigned int armor, const double bonus);
double dmgReductionIE(const double bonus);
double mitigation(dmgtypes_t *dtypes, classdata_t *cdata, statdist_t *stats, unsigned int armor, unsigned int stimDefense, int num_relics, relic_t **relics, unsigned int *relictypes, double time_per_swing);
statdist_t * randomStats(shieldbounds_t * sbounds, const unsigned int budget, rk_state *rand_state_ptr);
oresult_t * optimalStats(dmgtypes_t *dtypes, shieldbounds_t * sbounds, classdata_t *cdata, unsigned int statBudget, unsigned int armor, int num_relics, relic_t **relics, unsigned int *relictypes, unsigned int stimBonus, double time_per_swing, unsigned int numSamples, rk_state *rand_state_ptr);

}

using namespace v8;
using namespace node;

Expand Down
Loading

0 comments on commit 3550c82

Please sign in to comment.