- my @ship = $ND::DBH->selectrow_array(q{
-SELECT name,target,"type",armor,metal+crystal+eonium,init,"class",eres,race
-FROM ship_stats WHERE name ILIKE ?
- }, undef, $ship);
- if (@ship){
- $ship[0] = "${ND::C}04$ship[0]$ND::C" if $ship[2] eq 'Norm';
- $ship[0] = "${ND::C}12$ship[0]$ND::C" if $ship[2] eq 'Emp';
- $ship[0] = "${ND::C}13$ship[0]$ND::C" if $ship[2] eq 'Steal';
-
- $amount = int(($value*100/$ship[4])) if $amount eq 'value';
- $feud = '(FEUD: '.int($amount/0.75).') ' if defined $value;
- $value = prettyValue(($amount*$ship[4]/100));
- my $text = "To stop $amount $feud $ship[0] ($ship[5]:$value) you need:";
- my $st = $ND::DBH->prepare(q{
- SELECT name,"class","type",damage,metal+crystal+eonium,init,target,guns,race
- FROM ship_stats WHERE "target" = ?
- });
- $st->execute($ship[6]);
- while (my @stopper = $st->fetchrow()){
- my $needed = $stopper[2] eq 'Emp' ? ceil($amount*100/(100-$ship[7])/$stopper[7]) : ceil($amount*$ship[3]/$stopper[3]);
- $value = prettyValue($needed*$stopper[4]/100);
- if (($stopper[1] eq $ship[1]) and ($ship[5] <= $stopper[5])){
- $stopper[5] = "${ND::C}04$stopper[5]$ND::C";
- }elsif(($stopper[1] eq $ship[1]) and ($ship[5] > $stopper[5])){
- $stopper[5] = "${ND::C}12$stopper[5]$ND::C";
- }
- $stopper[0] = "${ND::C}04$stopper[0]$ND::C" if $stopper[2] eq 'Norm' || $stopper[2] eq 'Cloak';
- $stopper[0] = "${ND::C}12$stopper[0]$ND::C" if $stopper[2] eq 'Emp';
- $stopper[0] = "${ND::C}13$stopper[0]$ND::C" if $stopper[2] eq 'Steal';
- $text .= " $ND::B$needed$ND::B $stopper[0] ($stopper[5]:$value),";
+ my $number = 0;
+ if ($eff){
+ $number = $s->{type} eq 'Emp' ?
+ ($amount*$s->{guns}*(100-$t->{eres})/100)
+ : ($amount*$s->{damage}/$t->{armor});
+ }else{
+ $number = $t->{type} eq 'Emp' ?
+ ($amount*100/(100 - $s->{eres})/$t->{guns})
+ : ($amount*$s->{armor}/$t->{damage});
+ }
+
+ for my $tn ('t1','t2','t3'){
+ my ($s1,$t1) = $eff ? ($s,$t) : ($t,$s);
+ next unless (defined $t1->{$tn});
+ next unless ($t1->{$tn} eq $s1->{class});
+
+ if($t1->{init} <= $s1->{init}){
+ $t->{init} = "${ND::C}04$t->{init}$ND::O";
+ }else{
+ $t->{init} = "${ND::C}12$t->{init}$ND::O";