Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update role calc, role prefs, custom role bug
- re-wrote role calculations to use new checks and transformations based on thistleknot's latest role work - added highlighting of which preferences are matched in roles, and additionally listed the exact matches - updated role preference names, and added a check to update general material names on load - updated roles to have proper member variables - split the crop role preference category into crops (gather/grow) and crops (grow) - removed the 'wagon' creature from roles - fixed a bug with role attributes rounding due to passing int instead of double - fixed a bug with roles where having invalid/bad weights resulted in invalid ratings which caused drawing anomalies
- Loading branch information
1 parent
480ad9d
commit ec6a34f
Showing
35 changed files
with
608 additions
and
622 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| #ifndef ROLECALCBASE_H | ||
| #define ROLECALCBASE_H | ||
|
|
||
| #include <QVector> | ||
|
|
||
| class RoleCalcBase{ | ||
| public: | ||
| RoleCalcBase(const QVector<double> &sorted); | ||
| virtual ~RoleCalcBase(); | ||
|
|
||
| virtual double rating(const double val); | ||
| double base_rating(const double val); | ||
|
|
||
| double operator()(double val, bool leq = true)const{ | ||
| return leq ? pos_upper(val) : pos_lower(val);} | ||
|
|
||
| static double find_median(QVector<double> v); | ||
| static double range_transform(double val, double min, double mid, double max); | ||
|
|
||
| protected: | ||
| QVector<double> m_sorted; | ||
| QVector<double>::const_iterator m_begin, m_end; | ||
| void init_list(); | ||
| double m_count; | ||
| double m_div; | ||
| double pos_upper(double val)const; | ||
| double pos_lower(double val)const; | ||
| }; | ||
| #endif // ROLECALCBASE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #ifndef ROLECALCMINMAX_H | ||
| #define ROLECALCMINMAX_H | ||
|
|
||
| #include <QVector> | ||
| #include "rolecalcbase.h" | ||
|
|
||
| class RoleCalcMinMax: public RoleCalcBase{ | ||
| public: | ||
| RoleCalcMinMax(const QVector<double> &sorted) | ||
| : RoleCalcBase(sorted) | ||
| , m_min(sorted.first()) | ||
| , m_max(sorted.last()) | ||
| { | ||
| m_diff = m_max - m_min; | ||
| if(m_diff == 0) | ||
| m_diff = 1; | ||
| } | ||
|
|
||
| double rating(const double val){ | ||
| return (base_rating(val) + calc_min_max(val)) * 0.25 + 0.5f; | ||
| } | ||
|
|
||
| private: | ||
| double m_min; | ||
| double m_max; | ||
| double m_diff; | ||
| double calc_min_max(double val){ | ||
| return (val - m_min) / m_diff; | ||
| } | ||
| }; | ||
| #endif // ROLECALCMINMAX_H |
Oops, something went wrong.