BEGIN {
my @levels = ( initiate => 1,
novice => 20,
acolyte => 50,
scribe => 100,
monk => 200,
friar => 500,
abbot => 1000,
bishop => 1600,
pontiff => 2300,
saint => 3000 );
while ( @levels ) {
my ( $level, $xp ) = splice @levels, 0, 2;
eval "sub $level () { $xp }";
}
}
$xp = 0 + shift;
printf
"XP = $xp
%0.2f initiates
%0.2f novices, %d to promotion
%0.2f acolytes, %d to promotion
%0.2f scribes, %d to promotion
%0.2f monks, %d to promotion
%0.2f friars, %d to promotion
%0.2f abbots, %d to promotion
%0.2f bishops, %d to promotion
%0.2f pontiffs, %d to promotion
%.02f saints, %d to promotion
",
$xp / initiate,
$xp / novice, novice - ( $xp % novice ),
$xp / acolyte, acolyte - ( $xp % acolyte ),
$xp / scribe, scribe - ( $xp % scribe ),
$xp / monk, monk - ( $xp % monk ),
$xp / friar, friar - ( $xp % friar ),
$xp / abbot, abbot - ( $xp % abbot ),
$xp / bishop, bishop - ( $xp % bishop ),
$xp / pontiff, pontiff - ( $xp % pontiff ),
$xp / saint, saint - ( $xp % saint );
# I wish this was lisp.
for ( qw( saint pontiff bishop abbot friar monk scribe acolyte novice
+initiate ) ) {
eval "if ( \$xp >= $_ ) { push \@change, int( \$xp / $_ ) . \" ${_
+}s\";
\$xp %= $_ }";
}
for ( @change ) {
if ( 1 == $_ ) {
s/s$//;
}
}
$_ = join( ', ', @change, ) . "\n";
# Replaced w/ NinthWave's code. No, I didn't read it first.
s<(?:^|\D)(1 [a-z]+(?:, 1 [a-z]+)*)>{
my @ranks = $1 =~ /[a-z]+/g;
" a " . join ', ', @ranks;
}ge;
s/^ //;
if ( /,.+,/ ) {
s/(.+),([^,]+)/$1, and$2/;
}
print
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.