summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/makeitem.cc
diff options
context:
space:
mode:
authorNicholas Feinberg <pleasingfung@gmail.com>2014-07-12 20:16:45 -0700
committerNicholas Feinberg <pleasingfung@gmail.com>2014-07-13 00:33:57 -0700
commit9b6b733bccd0de2af35eb6c28e94e4708a92004d (patch)
tree30400b1991c700b09fff5dc4644dc43a2c693121 /crawl-ref/source/makeitem.cc
parent3663d864c83a72c7cf624617e9a9a5b8b5deaf6a (diff)
downloadcrawl-ref-9b6b733bccd0de2af35eb6c28e94e4708a92004d.tar.gz
crawl-ref-9b6b733bccd0de2af35eb6c28e94e4708a92004d.zip
Refactor weapon_skill()
This function was misleadingly named (it only provided the skill used for melee weapons, not ranged weapons), and incomplete; code along the lines of "is_ranged_weapon(*it) ? range_skill(*it) : weapon_skill(*it)" was scattered in about half a dozen different functions. I've corrected both of those problems (renaming weapon_ skill() to melee_skill() and adding item_weapon_skill()), and also possibly fixed two bugs in the process - an l_you.cc function that claimed to provide the skill used for the starting weapon (but actually only gave the melee skill), and unrand creation code that checked if a potential unrand swap used the same (melee) skill as the weapon type being generated.
Diffstat (limited to 'crawl-ref/source/makeitem.cc')
-rw-r--r--crawl-ref/source/makeitem.cc77
1 files changed, 25 insertions, 52 deletions
diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc
index 48b3ba3699..e2216efbf6 100644
--- a/crawl-ref/source/makeitem.cc
+++ b/crawl-ref/source/makeitem.cc
@@ -77,7 +77,6 @@ static int _exciting_colour()
static int _weapon_colour(const item_def &item)
{
- int item_colour = BLACK;
// fixed artefacts get predefined colours
string itname = item.name(DESC_PLAIN);
@@ -89,58 +88,32 @@ static int _weapon_colour(const item_def &item)
if (is_demonic(item))
return LIGHTRED;
- if (is_range_weapon(item))
- {
- switch (range_skill(item))
- {
- case SK_BOWS:
- item_colour = BLUE;
- break;
- case SK_CROSSBOWS:
- item_colour = LIGHTBLUE;
- break;
- case SK_THROWING:
- item_colour = WHITE;
- break;
- case SK_SLINGS:
- item_colour = BROWN;
- break;
- default:
- // huh?
- item_colour = LIGHTGREEN;
- break;
- }
- }
- else
- {
- switch (weapon_skill(item))
- {
- case SK_SHORT_BLADES:
- item_colour = CYAN;
- break;
- case SK_LONG_BLADES:
- item_colour = LIGHTCYAN;
- break;
- case SK_AXES:
- item_colour = MAGENTA;
- break;
- case SK_MACES_FLAILS:
- item_colour = LIGHTGREY;
- break;
- case SK_POLEARMS:
- item_colour = RED;
- break;
- case SK_STAVES:
- item_colour = GREEN;
- break;
- default:
- // huh?
- item_colour = LIGHTGREEN;
- break;
- }
+ switch (item_attack_skill(item))
+ {
+ case SK_BOWS:
+ return BLUE;
+ case SK_CROSSBOWS:
+ return LIGHTBLUE;
+ case SK_THROWING:
+ return WHITE;
+ case SK_SLINGS:
+ return BROWN;
+ case SK_SHORT_BLADES:
+ return CYAN;
+ case SK_LONG_BLADES:
+ return LIGHTCYAN;
+ case SK_AXES:
+ return MAGENTA;
+ case SK_MACES_FLAILS:
+ return LIGHTGREY;
+ case SK_POLEARMS:
+ return RED;
+ case SK_STAVES:
+ return GREEN;
+ default:
+ // huh?
+ return LIGHTGREEN;
}
-
- return item_colour;
}
static int _missile_colour(const item_def &item)