sc: option to order by build time
[sheet.git] / sc.plp
diff --git a/sc.plp b/sc.plp
index b20e51df3597e6feda0506b2f8af7ea2233c6701..d0b269144c5df9db3712d882d69389465b1403d6 100644 (file)
--- a/sc.plp
+++ b/sc.plp
@@ -95,7 +95,7 @@ sub coltoggle {
        <th><:= coltoggle(name => 'name') :></th>
        <th class="val min" title=minerals><:= coltoggle(cost => 'cost') :></th>
        <th class="val gas">gas</th>
-       <th class="val time">build</th>
+       <th class="val time"><:= coltoggle(build => 'build') :></th>
        <th class="unit" colspan="2"><:= coltoggle(qw'size size') :></th>
        <th class="unit" colspan="2">attr</th>
        <th class="val unit-hp"><:= coltoggle(HP => 'hp') :></th>
@@ -356,6 +356,15 @@ sub showrangeint {
                                $_->{gas}*1.5 + $_->{min} + $_->{pop}/8 + $_->{build}/256/8
                        ) for @rows;
                }
+               elsif ($get{order} eq 'build') {
+                       my %unittime = map { ($_->{name} => $_->{warp} // $_->{build}) } @rows;
+                       $unittime{Templar} = $unittime{'High Templar'};
+                       $_->{order} = (
+                               ($_->{warp} // $_->{build})
+                               + ($_->{gas}*1.5 + $_->{min} + $_->{pop}/8)/1024
+                               + ($_->{base} ? ($unittime{$_->{base}->[0]} // 100) + 1 : 0)
+                       ) for @rows;
+               }
                elsif ($get{order} eq 'size') {
                        $_->{order} = (
                                $_->{pop}*16 + ($_->{size} // $_->{suit}) + $_->{cargo}/8