The trophy system is also a lot like the fleet system in that all the code is also available in the trophy table.
Let's look at some of the specific examples you brought up.
Here is the code for the distance covered trophy:
FOR players IN
player_round_stats.round_id = _round_id
round_stats.round_id = _round_id
player_round_stats.distance_travelled > round_stats.avg_distance_travelled
winner.round := _round_id;
winner.trophy_id := this_trophy_id;
winner.player_id := players.player_id;
RETURN NEXT winner;
The trophy code in this case is basing the results off the player_round_stats, so we also need to jump over to the stats view to see how that is calculated
COALESCE((( SELECT sum(r.location <-> r2.location)::bigint AS sum
FROM ship_flight_recorder r, ship_flight_recorder r2, ship s
WHERE s.player_id = player.id AND r.ship_id = s.id AND r2.ship_id = r.ship_id AND r2.tic = (r.tic + 1)))::numeric, 0::numeric) AS distance_travelled,
This piece is likely a bit confusing but basically, it just adds up each section travelled by a ship and then sums them all up together. So it doesn't matter if you have 5 ships moving 1 or 1 ship moving 5.
As for the Most Powerful, that is this trophy:
which also pulls the results from stats (ship_upgrades). The stats is generated through a lookup of the event table (also known as my_events to players):
WHEN event.action = 'UPGRADE_SHIP'::bpchar THEN event.descriptor_numeric
END) AS ship_upgrades,
Basically, any time you upgrade a part of your ship, this stat goes up.
The stats and trophies are all a tad complicated but if you are starting to wonder what exactly they are then you are on the right track to begin very good at this game. The top players study these pretty closely when working not their strategy.