Planet won: Ammunition that was fired in combat is used from the starbase's storage first. The base also takes damage first.

Fighters_lost =
   Min(Fighters_launched_in_combat, Base_fighters)

Torpedoes used in combat are made up of all types' storage, so after combat, the base loses torpedoes of all types. PHost uses the following algorithm:

Torpedo_costs =
   Torps_fired * Torp_money_cost(Torp_type)

Repeat
   For i:=1 To 10     (iterate through all torpedo types)
      If (Torps_in_storage(i) > 0) And (Torpedo_costs > Torp_money_cost(i))
         Remove one torpedo of type i
         Decrease Torpedo_costs by Torp_money_cost(i)
      EndIf
   EndFor
Until the above loop didn't find any more torpedoes to remove

This attempts to make sure losses are distributed equally among all types.

Ending Status: The planet can take part in several fights during a turn. After all these fights are completed, damage effects are computed.

Base_damage_after_combat =
   Base_damage + Damage_taken
   ...if that is 100 or more, the base is destroyed

Base_defense_after_combat =
   Trunc(Base_defense * Damage_taken / 100)

Max_base_tech =
   Max(1, Trunc((100 - Base_damage_after_combat) / 10))

Defense_after_combat =
   Trunc(Planet_defense * Damage_taken / 100)

The Max_base_tech is the maximum tech level the base can have after combat. Tech levels above that limit are reduced.