summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2006-12-11 17:36:10 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2006-12-11 17:36:10 +0000
commit605ad1a626360b651b73805372bf74453a6f2410 (patch)
tree2646e8daf9d0dd14a16eaf9efefd55975c56f79c /crawl-ref
parent914104c2b2d2600c415caa321690708317a4db6c (diff)
downloadcrawl-ref-605ad1a626360b651b73805372bf74453a6f2410.tar.gz
crawl-ref-605ad1a626360b651b73805372bf74453a6f2410.zip
More streamlining, this time of code which shows power and spell failure.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@616 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/abl-show.cc19
-rw-r--r--crawl-ref/source/chardump.cc28
-rw-r--r--crawl-ref/source/spl-cast.cc61
-rw-r--r--crawl-ref/source/spl-cast.h2
4 files changed, 41 insertions, 69 deletions
diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc
index 073dffe2d1..197e4e46a8 100644
--- a/crawl-ref/source/abl-show.cc
+++ b/crawl-ref/source/abl-show.cc
@@ -1379,20 +1379,7 @@ char show_abilities( void )
gotoxy(60, wherey());
- int spell_f = Curr_abil[loopy].fail;
-
- cprintf( (spell_f >= 100) ? "Useless" :
- (spell_f > 90) ? "Terrible" :
- (spell_f > 80) ? "Cruddy" :
- (spell_f > 70) ? "Bad" :
- (spell_f > 60) ? "Very Poor" :
- (spell_f > 50) ? "Poor" :
- (spell_f > 40) ? "Fair" :
- (spell_f > 30) ? "Good" :
- (spell_f > 20) ? "Very Good" :
- (spell_f > 10) ? "Great" :
- (spell_f > 0) ? "Excellent" :
- "Perfect" );
+ cprintf( "%s", failure_rate_to_string(Curr_abil[loopy].fail));
gotoxy(70, wherey());
} // end if conditional
@@ -1435,7 +1422,6 @@ bool generate_abilities( void )
/*****************************/
{
int loopy;
- int ability = -1; // used with draconian checks {dlb}
// fill array of structs with "empty" values {dlb}:
for (loopy = 0; loopy < 52; loopy++)
@@ -1478,7 +1464,7 @@ bool generate_abilities( void )
{
if (you.experience_level >= 7)
{
- ability = (
+ const int ability = (
(you.species == SP_GREEN_DRACONIAN) ? ABIL_BREATHE_POISON :
(you.species == SP_RED_DRACONIAN) ? ABIL_BREATHE_FIRE :
(you.species == SP_WHITE_DRACONIAN) ? ABIL_BREATHE_FROST :
@@ -1488,7 +1474,6 @@ bool generate_abilities( void )
(you.species == SP_PALE_DRACONIAN) ? ABIL_BREATHE_STEAM :
(you.species == SP_MOTTLED_DRACONIAN)? ABIL_BREATHE_STICKY_FLAME:
-1);
-
if (ability != -1)
insert_ability( ability );
}
diff --git a/crawl-ref/source/chardump.cc b/crawl-ref/source/chardump.cc
index 04b12201eb..51e2dc6d59 100644
--- a/crawl-ref/source/chardump.cc
+++ b/crawl-ref/source/chardump.cc
@@ -896,36 +896,12 @@ static void sdump_spells(const std::string &, std::string & text)
for (int i = spell_line.length(); i < 41; ++i )
spell_line += ' ';
- int spell_p = calc_spell_power( spell, true );
- spell_line += ( (spell_p > 100) ? "Enormous" :
- (spell_p > 90) ? "Huge" :
- (spell_p > 80) ? "Massive" :
- (spell_p > 70) ? "Major" :
- (spell_p > 60) ? "Impressive" :
- (spell_p > 50) ? "Reasonable" :
- (spell_p > 40) ? "Moderate" :
- (spell_p > 30) ? "Adequate" :
- (spell_p > 20) ? "Mediocre" :
- (spell_p > 10) ? "Minor"
- : "Negligible");
+ spell_line += spell_power_to_string(calc_spell_power(spell,true));
for (int i = spell_line.length(); i < 56; ++i )
spell_line += ' ';
- int fail_rate = spell_fail( spell );
-
- spell_line += (fail_rate == 100) ? "Useless" :
- (fail_rate > 90) ? "Terrible" :
- (fail_rate > 80) ? "Cruddy" :
- (fail_rate > 70) ? "Bad" :
- (fail_rate > 60) ? "Very Poor" :
- (fail_rate > 50) ? "Poor" :
- (fail_rate > 40) ? "Fair" :
- (fail_rate > 30) ? "Good" :
- (fail_rate > 20) ? "Very Good" :
- (fail_rate > 10) ? "Great" :
- (fail_rate > 0) ? "Excellent"
- : "Perfect";
+ spell_line += failure_rate_to_string(spell_fail(spell));
for (int i = spell_line.length(); i < 68; i++)
spell_line += ' ';
diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc
index 19e28d8dd9..0495670490 100644
--- a/crawl-ref/source/spl-cast.cc
+++ b/crawl-ref/source/spl-cast.cc
@@ -174,36 +174,12 @@ char list_spells(void)
// 35--48 is the spell schools
gotoxy(51, wherey());
- int spell_p = calc_spell_power( spell, true );
- cprintf( (spell_p > 100) ? "Enormous" :
- (spell_p > 90) ? "Huge" :
- (spell_p > 80) ? "Massive" :
- (spell_p > 70) ? "Major" :
- (spell_p > 60) ? "Impressive" :
- (spell_p > 50) ? "Reasonable" :
- (spell_p > 40) ? "Moderate" :
- (spell_p > 30) ? "Adequate" :
- (spell_p > 20) ? "Mediocre" :
- (spell_p > 10) ? "Minor"
- : "Negligible");
+ cprintf("%s",spell_power_to_string(calc_spell_power(spell,true)));
//gotoxy(58, wherey());
gotoxy(65, wherey());
- int spell_f = spell_fail( spell );
-
- cprintf( (spell_f == 100) ? "Useless" :
- (spell_f > 90) ? "Terrible" :
- (spell_f > 80) ? "Cruddy" :
- (spell_f > 70) ? "Bad" :
- (spell_f > 60) ? "Very Poor" :
- (spell_f > 50) ? "Poor" :
- (spell_f > 40) ? "Fair" :
- (spell_f > 30) ? "Good" :
- (spell_f > 20) ? "Very Good" :
- (spell_f > 10) ? "Great" :
- (spell_f > 0) ? "Excellent"
- : "Perfect" );
+ cprintf( "%s", failure_rate_to_string(spell_fail(spell)));
gotoxy(77, wherey());
@@ -3610,3 +3586,36 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail,
return (true);
} // end miscast_effect()
+
+const char* failure_rate_to_string( int fail )
+{
+ return
+ (fail == 100) ? "Useless" :
+ (fail > 90) ? "Terrible" :
+ (fail > 80) ? "Cruddy" :
+ (fail > 70) ? "Bad" :
+ (fail > 60) ? "Very Poor" :
+ (fail > 50) ? "Poor" :
+ (fail > 40) ? "Fair" :
+ (fail > 30) ? "Good" :
+ (fail > 20) ? "Very Good" :
+ (fail > 10) ? "Great" :
+ (fail > 0) ? "Excellent"
+ : "Perfect";
+}
+
+const char* spell_power_to_string( int power )
+{
+ return
+ (power > 100) ? "Enormous" :
+ (power > 90) ? "Huge" :
+ (power > 80) ? "Massive" :
+ (power > 70) ? "Major" :
+ (power > 60) ? "Impressive" :
+ (power > 50) ? "Reasonable" :
+ (power > 40) ? "Moderate" :
+ (power > 30) ? "Adequate" :
+ (power > 20) ? "Mediocre" :
+ (power > 10) ? "Minor"
+ : "Negligible";
+}
diff --git a/crawl-ref/source/spl-cast.h b/crawl-ref/source/spl-cast.h
index b5e97d8b38..30f5a49c2e 100644
--- a/crawl-ref/source/spl-cast.h
+++ b/crawl-ref/source/spl-cast.h
@@ -47,5 +47,7 @@ int your_spells( int spc2, int powc = 0, bool allow_fail = true );
bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail,
int force_effect, const char *cause = NULL );
+const char* failure_rate_to_string( int fail );
+const char* spell_power_to_string( int power );
#endif