Planet lost: If a planet was lost in combat, it changes ownership. If the planet had a starbase, that one is destroyed.

Defense_after_combat =
   0
Colonists_after_combat =
   Trunc(Colonists * ColonistCombatSurvivalRate / 100)
Colonist_happiness_after_combat =
   Colonist_happiness - Trunc(ColonistCombatSurvivalRate / 2)
      ...at least MinimumHappiness
Experience_points_after_combat =
   Trunc(Experience_points * ColonistCombatSurvivalRate / 100)
Natives_after_combat =
   Trunc(Natives * NativeCombatSurvivalRate / 100)
Native_happiness_after_combat =
   Native_happiness - 20
      ...at least MinimumHappiness

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.

This is a testing version.
It may be incomplete, and have more bugs (or features) than the public live version at planetscentral.com.