diff options
author | Adam Borowski <kilobyte@angband.pl> | 2012-08-31 00:44:20 +0200 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2012-08-31 00:44:20 +0200 |
commit | a9eeb4a370e85069c25286e5cedc9682d5d04b2e (patch) | |
tree | 450c0ccd5f5353553d5b96edee2850623dffcc03 /crawl-ref/source/skills2.cc | |
parent | 57aec7d2a0ae1095fb1babd8f0fcc276927bf8e5 (diff) | |
parent | 35613e094ca5d0be028ee9261afebf3e35faa563 (diff) | |
download | crawl-ref-a9eeb4a370e85069c25286e5cedc9682d5d04b2e.tar.gz crawl-ref-a9eeb4a370e85069c25286e5cedc9682d5d04b2e.zip |
Merge branch 'master' into glasnost
Yay for conflicts galore (wax removal, std:: purge, tileidx changes).
Diffstat (limited to 'crawl-ref/source/skills2.cc')
-rw-r--r-- | crawl-ref/source/skills2.cc | 102 |
1 files changed, 45 insertions, 57 deletions
diff --git a/crawl-ref/source/skills2.cc b/crawl-ref/source/skills2.cc index 9d63c10287..36355f8015 100644 --- a/crawl-ref/source/skills2.cc +++ b/crawl-ref/source/skills2.cc @@ -24,8 +24,8 @@ #include "species.h" #include "skills.h" -typedef std::string (*string_fn)(); -typedef std::map<std::string, string_fn> skill_op_map; +typedef string (*string_fn)(); +typedef map<string, string_fn> skill_op_map; static skill_op_map Skill_Op_Map; @@ -40,10 +40,10 @@ public: Skill_Op_Map[k] = o; } - static std::string get(const std::string &_key) + static string get(const string &_key) { skill_op_map::const_iterator i = Skill_Op_Map.find(_key); - return (i == Skill_Op_Map.end()? std::string() : (i->second)()); + return (i == Skill_Op_Map.end()? string() : (i->second)()); } private: const char *key; @@ -168,7 +168,7 @@ const char *skill_name(skill_type which_skill) return (skills[which_skill][0]); } -skill_type str_to_skill(const std::string &skill) +skill_type str_to_skill(const string &skill) { for (int i = SK_FIRST_SKILL; i < NUM_SKILLS; ++i) if (skills[i][0] && skill == skills[i][0]) @@ -177,29 +177,29 @@ skill_type str_to_skill(const std::string &skill) return SK_FIGHTING; } -static std::string _stk_adj_cap() +static string _stk_adj_cap() { return species_name(Skill_Species, false, true); } -static std::string _stk_genus_cap() +static string _stk_genus_cap() { return species_name(Skill_Species, true, false); } -static std::string _stk_genus_nocap() +static string _stk_genus_nocap() { - std::string s = _stk_genus_cap(); + string s = _stk_genus_cap(); return lowercase(s); } -static std::string _stk_genus_short_cap() +static string _stk_genus_short_cap() { return (Skill_Species == SP_DEMIGOD ? "God" : _stk_genus_cap()); } -static std::string _stk_walker() +static string _stk_walker() { return (Skill_Species == SP_NAGA ? "Slider" : Skill_Species == SP_TENGU ? "Glider" : @@ -207,7 +207,7 @@ static std::string _stk_walker() : "Walker"); } -static std::string _stk_weight() +static string _stk_weight() { switch (Skill_Species) { @@ -249,19 +249,19 @@ static skill_title_key_t _skill_title_keys[] = { stk("Weight", _stk_weight), }; -static std::string _replace_skill_keys(const std::string &text) +static string _replace_skill_keys(const string &text) { - std::string::size_type at = 0, last = 0; - std::ostringstream res; - while ((at = text.find('@', last)) != std::string::npos) + string::size_type at = 0, last = 0; + ostringstream res; + while ((at = text.find('@', last)) != string::npos) { res << text.substr(last, at - last); - const std::string::size_type end = text.find('@', at + 1); - if (end == std::string::npos) + const string::size_type end = text.find('@', at + 1); + if (end == string::npos) break; - const std::string key = text.substr(at + 1, end - at - 1); - const std::string value = stk::get(key); + const string key = text.substr(at + 1, end - at - 1); + const string value = stk::get(key); ASSERT(!value.empty()); @@ -286,8 +286,8 @@ unsigned get_skill_rank(unsigned skill_lev) /* level 27 */ : 4); } -std::string skill_title_by_rank(skill_type best_skill, uint8_t skill_rank, - int species, int str, int dex, int god) +string skill_title_by_rank(skill_type best_skill, uint8_t skill_rank, + int species, int str, int dex, int god) { // paranoia if (is_invalid_skill(best_skill)) @@ -308,7 +308,7 @@ std::string skill_title_by_rank(skill_type best_skill, uint8_t skill_rank, // Increment rank by one to "skip" skill name in array {dlb}: ++skill_rank; - std::string result; + string result; if (best_skill < NUM_SKILLS) { @@ -365,17 +365,17 @@ std::string skill_title_by_rank(skill_type best_skill, uint8_t skill_rank, result = _replace_skill_keys(result); } - return (result.empty() ? std::string("Invalid Title") + return (result.empty() ? string("Invalid Title") : result); } -std::string skill_title(skill_type best_skill, uint8_t skill_lev, - int species, int str, int dex, int god) +string skill_title(skill_type best_skill, uint8_t skill_lev, + int species, int str, int dex, int god) { return skill_title_by_rank(best_skill, get_skill_rank(skill_lev), species, str, dex, god); } -std::string player_title() +string player_title() { const skill_type best = best_skill(SK_FIRST_SKILL, SK_LAST_SKILL); return skill_title(best, you.skills[ best ]); @@ -466,7 +466,7 @@ void calc_hp() void calc_mp() { you.max_magic_points = get_real_mp(true); - you.magic_points = std::min(you.magic_points, you.max_magic_points); + you.magic_points = min(you.magic_points, you.max_magic_points); you.redraw_magic_points = true; } @@ -475,6 +475,11 @@ bool is_useless_skill(skill_type skill) return species_apt(skill) == -99; } +bool is_harmful_skill(skill_type skill) +{ + return is_magic_skill(skill) && you.religion == GOD_TROG; +} + int skill_bump(skill_type skill, int scale) { int sk = you.skill_rdiv(skill, scale); @@ -490,22 +495,6 @@ static float _apt_to_factor(int apt) return (1 / exp(log(2) * apt / APT_DOUBLE)); } -// Base skill cost, i.e. old-style human aptitudes. -static int _base_cost(skill_type sk) -{ - switch (sk) - { - case SK_SPELLCASTING: - return 130; - case SK_STEALTH: - case SK_INVOCATIONS: - case SK_EVOCATIONS: - return 80; - default: - return 100; - } -} - unsigned int skill_exp_needed(int lev, skill_type sk, species_type sp) { const int exp[28] = { 0, 50, 150, 300, 500, 750, // 0-5 @@ -517,7 +506,7 @@ unsigned int skill_exp_needed(int lev, skill_type sk, species_type sp) ASSERT(lev >= 0); ASSERT(lev <= 27); - return exp[lev] * species_apt_factor(sk, sp) * _base_cost(sk) / 100; + return exp[lev] * species_apt_factor(sk, sp); } int species_apt(skill_type skill, species_type species) @@ -547,9 +536,9 @@ float species_apt_factor(skill_type sk, species_type sp) return _apt_to_factor(species_apt(sk, sp)); } -static std::vector<skill_type> _get_crosstrain_skills(skill_type sk) +static vector<skill_type> _get_crosstrain_skills(skill_type sk) { - std::vector<skill_type> ret; + vector<skill_type> ret; switch (sk) { @@ -587,7 +576,7 @@ float crosstrain_bonus(skill_type sk) { int bonus = 1; - std::vector<skill_type> crosstrain_skills = _get_crosstrain_skills(sk); + vector<skill_type> crosstrain_skills = _get_crosstrain_skills(sk); for (unsigned int i = 0; i < crosstrain_skills.size(); ++i) if (you.skill(crosstrain_skills[i], 10, true) @@ -601,7 +590,7 @@ float crosstrain_bonus(skill_type sk) bool crosstrain_other(skill_type sk, bool show_zero) { - std::vector<skill_type> crosstrain_skills = _get_crosstrain_skills(sk); + vector<skill_type> crosstrain_skills = _get_crosstrain_skills(sk); for (unsigned int i = 0; i < crosstrain_skills.size(); ++i) if (you.skill(crosstrain_skills[i], 10, true) @@ -666,7 +655,7 @@ bool antitrain_other(skill_type sk, bool show_zero) && you.skills[opposite] < 27 && _compare_skills(sk, opposite)); } -void dump_skills(std::string &text) +void dump_skills(string &text) { for (uint8_t i = 0; i < NUM_SKILLS; i++) { @@ -697,7 +686,7 @@ int skill_transfer_amount(skill_type sk) if (you.skill_points[sk] < 1000) return you.skill_points[sk] - skill_exp_needed(1, sk); else - return std::max<int>(1000, you.skill_points[sk] / 2); + return max<int>(1000, you.skill_points[sk] / 2); } // Transfer skill points from one skill to another (Ashenzari transfer @@ -726,7 +715,7 @@ int transfer_skill_points(skill_type fsk, skill_type tsk, int skp_max, while (total_skp_lost < skp_max && (simu || total_skp_lost < (int)you.transfer_skill_points)) { - int skp_lost = std::min(20, skp_max - total_skp_lost); + int skp_lost = min(20, skp_max - total_skp_lost); int skp_gained = skp_lost * penalty / 100; float ct_bonus = crosstrain_bonus(tsk); @@ -742,14 +731,14 @@ int transfer_skill_points(skill_type fsk, skill_type tsk, int skp_max, int ct_penalty = skp_lost * you.ct_skill_points[fsk] / (you.skill_points[fsk] - you.ct_skill_points[fsk]); - ct_penalty = std::min<int>(ct_penalty, you.ct_skill_points[fsk]); + ct_penalty = min<int>(ct_penalty, you.ct_skill_points[fsk]); you.ct_skill_points[fsk] -= ct_penalty; skp_lost += ct_penalty; if (!simu) { - skp_lost = std::min<int>(skp_lost, you.transfer_skill_points - - total_skp_lost); + skp_lost = min<int>(skp_lost, you.transfer_skill_points + - total_skp_lost); } total_skp_lost += skp_lost; @@ -860,8 +849,7 @@ void fixup_skills() skill_type sk = static_cast<skill_type>(i); if (is_useless_skill(sk)) you.skill_points[i] = 0; - you.skill_points[i] = std::min(you.skill_points[i], - skill_exp_needed(27, sk)); + you.skill_points[i] = min(you.skill_points[i], skill_exp_needed(27, sk)); check_skill_level_change(sk); } init_can_train(); |