Get the Agent of the last Player alive

Woops, sorry, got lost in my code, you’d do this instead :

    # Returns true when there's one player (or less) alive
    CheckOneAlive() : tuple(logic, ?player) =
        var Count : int = 0
        var LastIteratedPlayer : ?player = false
        for (Player : GetPlayspace().GetPlayers(), FortCharacter := Player.GetFortCharacter[], FortCharacter.IsActive[]):
            set Count += 1
            set LastIteratedPlayer = option{Player}
        return if(Count <= 1) then (true, LastIteratedPlayer) else (false, LastIteratedPlayer)

Then in your function, you’d call :

        Result := CheckOneAlive()
        IsCountUnderOne := Result(0)
        FoundPlayer := Result(1)

        if(IsCountUnderOne?):
            if(_FoundPlayer := FoundPlayer?):
                # Do your logic with the actual last player alive (_FoundPlayer)
            else:
               # There might be no more player alive ?

There might be cleaner way to do this with multiple functions, but this should work, I hope !

1 Like