#!/bin/awk -f
#
#	Condenses a log file down to interesting entries

/^Spy deported from/ { next; }
/^You have a new/ { next; }
/^ *.+\(# *[0-9]+\) .+ #[0-9]+ @ .+,.+/ 
/^[A-Za-z].+ \(#[0-9]+\) .+ [0-9]+% efficient .* @ .+,.+/
/^Kawhomp! Mine detected by .+ \(#[0-9]+\) in .+,.+!/
/^\[fert:[0-9]+\]/
/^\[oil:[0-9]+\]/
/^> BULLETIN/, /^([a-zA-Z0-9]+ \[)|(\[[0-9]+:[0-9]+\] Command :)|(> Product)|(> Telegram)/

/^SPY report/ {
	print $lastline;
  print;
  do { getline; print; } while (length($0)>0);
  print "[313:512] Command : look *\n";
}

/^SPY Plane report/ {
  print $lastline;
  print;
  do {
    getline;
    print;
    if (match($0,"^firing [0-9]+ flak guns in .*\.\.\.")) {
      do { getline; } while (match($0,".* .* \(#[0-9]\) takes [0-9]+\."));
      getline; print;
      getline; print;
    } else if (match($0,"own  lnd# unit type         sector   eff")) {
      do { getline; print; } while (length($0)>0);
      getline; print;
    }
  } while (length($0));
  print "[313:512] Command : look *\n";
}

{
  $lastline=$0;
}