From a282d4ee540e89cde99e1aaa0eff91080a6819c3 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sun, 17 May 2009 10:02:18 +0000 Subject: added TPartyGame.RoundPlayed some changes to GetWinnerString, it can now be used for the game winner, too. adapted UScreenPartyScore uses TPartyGame.RoundPlayed in UScreenPartyScore git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/experimental@1748 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Lua/src/base/UParty.pas | 50 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 15 deletions(-) (limited to 'Lua/src/base') diff --git a/Lua/src/base/UParty.pas b/Lua/src/base/UParty.pas index fc741768..3d916f64 100644 --- a/Lua/src/base/UParty.pas +++ b/Lua/src/base/UParty.pas @@ -163,6 +163,9 @@ type been played } function NextRound: integer; + { indicates that current round has already been played } + procedure RoundPlayed; + { true if in a Party Game (not in standard mode) } property PartyGame: Boolean read BPartyGame; @@ -624,6 +627,13 @@ begin end; end; +{ indicates that current round has already been played } +procedure TPartyGame.RoundPlayed; +begin + if (bPartyStarted) and (CurRound >= 0) and (CurRound <= High(Rounds)) then + Rounds[CurRound].AlreadyPlayed := True; +end; + { returns true if last round was already played } function TPartyGame.GameFinished: Boolean; begin @@ -788,35 +798,45 @@ begin end; end; -{ returns a string like "Team 1 (and Team 2) win" } +{ returns a string like "Team 1 (and Team 2) win" + if Round is in range from 0 to high(Rounds) then + result is name of winners of specified round. + if Round is -1 the result is name of winners of + the whole party game} function TPartyGame.GetWinnerString(Round: Integer): String; var Winners: array of String; I: integer; + Ranking: AParty_TeamRanking; begin Result := ''; - + Ranking := nil; + if (Round >= 0) and (Round <= High(Rounds)) then begin if (not Rounds[Round].AlreadyPlayed) then - begin - Result := Language.Translate('PARTY_NOTPLAYEDYET'); - end + Result := Language.Translate('PARTY_NOTPLAYEDYET') else + Ranking := Rounds[Round].Ranking; + end + else if (Round = -1) then + Ranking := GetTeamRanking; + + + if (Ranking <> nil) then + begin + SetLength(Winners, 0); + for I := 0 to High(Ranking) do begin - SetLength(Winners, 0); - for I := 0 to High(Rounds[Round].Ranking) do + if (Ranking[I].Rank = PR_First) and (Ranking[I].Team >= 0) and (Ranking[I].Team <= High(Teams)) then begin - if Rounds[Round].Ranking[I].Rank = PR_First then - begin - SetLength(Winners, Length(Winners) + 1); - Winners[high(Winners)] := Teams[I].Name; - end; + SetLength(Winners, Length(Winners) + 1); + Winners[high(Winners)] := Teams[Ranking[I].Team].Name; end; - - if (Length(Winners) > 0) then - Result := Language.Implode(Winners); end; + + if (Length(Winners) > 0) then + Result := Language.Implode(Winners); end; if (Length(Result) = 0) then -- cgit v1.2.3