Show
Ignore:
Timestamp:
07/19/07 11:46:56 (3 years ago)
Author:
eevee
Message:

Added EV support to Perlbui's IV calculator.
Also gave Perlbui a slightly more reasonable default IRC channel to connect to: #veekun.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • veekun/trunk/lib/Vee/Bot.pm

    r229 r262  
    9595        (\d+)   \s+ 
    9696        with 
    97         ( (?: \s+ \d+ ){6} ) 
     97        ( (?: \s+ \d+ (?: \+ \d+ )? ){6} ) 
    9898    $/ix); 
    9999 
     
    101101        # didn't match 
    102102        return "Syntax for that command is 'ivs for {nature} {pokemon} " . 
    103                "at level {level} with {hp} {atk} {def} {spatk} {spdef} {spd}'."; 
     103               "at level {level} with {hp} {atk} {def} {spatk} {spdef} {spd}'.  " . 
     104               "You may specify EVs as +{effort} immediately after a stat."; 
    104105    } 
    105106 
    106107    # I cheat here and use the special ' ' delimeter to avoid the leading empty 
    107108    # string I'd get otherwise.  It IS documented, trust me. 
    108     my @stats = split ' ', $stats; 
     109    my (@stats, @evs); 
     110    for my $stat_string (split ' ', $stats) { 
     111        my ($iv, $ev) = split /\+/, $stat_string; 
     112        push @stats, $iv; 
     113        push @evs,   $ev || 0; 
     114    } 
    109115 
    110116    my $pokemon_id = get_pokemon($pokemon_name) 
     
    136142        my ($min, $max); 
    137143        for my $iv (0 .. 31) { 
    138             my $calculated = $func->($base, $level, $iv, 0); 
     144            my $calculated = $func->($base, $level, $iv, $evs[$s]); 
    139145            $calculated = int( $calculated * $nature_changes[$s] ); 
    140146            if ($calculated == $stats[$s]) { 
     
    149155 
    150156        for my $iv (reverse $min .. 31) { 
    151             my $calculated = $func->($base, $level, $iv, 0); 
     157            my $calculated = $func->($base, $level, $iv, $evs[$s]); 
    152158            $calculated = int( $calculated * $nature_changes[$s] ); 
    153159            if ($calculated == $stats[$s]) {