If the battle ends with the hero winning, then TPoS is triggered and the hero is discarded. If the battle ends and the hero is defeated by numbers or by discard, and as a result is discarded, then TPoS's ability is still triggered, thus the ability on the artifact is used once. If the hero is defeated by withdraw, underdecked or set aside, then TPoS's ability is triggered and the hero is instead discarded. TPoS can be used twice in one or a combination of these ways.