56 function CheckForWin: boolean; |
56 function CheckForWin: boolean; |
57 var AliveClan: PClan; |
57 var AliveClan: PClan; |
58 s, cap: ansistring; |
58 s, cap: ansistring; |
59 ts: array[0..(cMaxTeams - 1)] of ansistring; |
59 ts: array[0..(cMaxTeams - 1)] of ansistring; |
60 t, AliveCount, i, j: LongInt; |
60 t, AliveCount, i, j: LongInt; |
|
61 allWin: boolean; |
61 begin |
62 begin |
62 CheckForWin:= false; |
63 CheckForWin:= false; |
63 AliveCount:= 0; |
64 AliveCount:= 0; |
64 for t:= 0 to Pred(ClansCount) do |
65 for t:= 0 to Pred(ClansCount) do |
65 if ClansArray[t]^.ClanHealth > 0 then |
66 if ClansArray[t]^.ClanHealth > 0 then |
73 CheckForWin:= true; |
74 CheckForWin:= true; |
74 |
75 |
75 TurnTimeLeft:= 0; |
76 TurnTimeLeft:= 0; |
76 ReadyTimeLeft:= 0; |
77 ReadyTimeLeft:= 0; |
77 |
78 |
78 // if the game ends during a multishot, do last TurnReaction |
79 // If the game ends during a multishot, or after the Sudden Death |
79 if (not bBetweenTurns) and isInMultiShoot then |
80 // water has risen, do last turn stats / reaction. |
80 TurnReaction(); |
81 if ((not bBetweenTurns) and isInMultiShoot) or (bDuringWaterRise) then |
|
82 begin |
|
83 TurnStats(); |
|
84 if (not bDuringWaterRise) then |
|
85 TurnReaction(); |
|
86 TurnStatsReset(); |
|
87 end; |
81 |
88 |
82 if not TeamsGameOver then |
89 if not TeamsGameOver then |
83 begin |
90 begin |
84 if AliveCount = 0 then |
91 if AliveCount = 0 then |
85 begin // draw |
92 begin // draw |
86 AddCaption(GetEventString(eidRoundDraw), capcolDefault, capgrpGameState); |
93 AddCaption(GetEventString(eidRoundDraw), capcolDefault, capgrpGameState); |
87 if SendGameResultOn then |
94 if SendGameResultOn then |
88 SendStat(siGameResult, shortstring(trmsg[sidDraw])); |
95 SendStat(siGameResult, shortstring(trmsg[sidDraw])); |
|
96 if PreviousTeam <> nil then |
|
97 AddVoice(sndNutter, PreviousTeam^.voicepack) |
|
98 else |
|
99 AddVoice(sndNutter, TeamsArray[0]^.voicepack); |
89 AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000); |
100 AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000); |
90 end |
101 end |
91 else // win |
102 else // win |
92 begin |
103 begin |
|
104 allWin:= false; |
93 with AliveClan^ do |
105 with AliveClan^ do |
94 begin |
106 begin |
95 if TeamsNumber = 1 then // single team wins |
107 if TeamsNumber = 1 then // single team wins |
96 begin |
108 begin |
97 s:= ansistring(Teams[0]^.TeamName); |
109 s:= ansistring(Teams[0]^.TeamName); |
108 ts[j] := Teams[j]^.TeamName; |
120 ts[j] := Teams[j]^.TeamName; |
109 end; |
121 end; |
110 |
122 |
111 // Write victory message for caption and stats page |
123 // Write victory message for caption and stats page |
112 if (TeamsNumber = cMaxTeams) or (TeamsCount = TeamsNumber) then |
124 if (TeamsNumber = cMaxTeams) or (TeamsCount = TeamsNumber) then |
|
125 begin |
113 // No enemies for some reason … Everyone wins!!1! |
126 // No enemies for some reason … Everyone wins!!1! |
114 s:= trmsg[sidWinnerAll] |
127 s:= trmsg[sidWinnerAll]; |
|
128 allWin:= true; |
|
129 end |
115 else if (TeamsNumber >= 2) and (TeamsNumber < cMaxTeams) then |
130 else if (TeamsNumber >= 2) and (TeamsNumber < cMaxTeams) then |
116 // List all winning teams in a list |
131 // List all winning teams in a list |
117 s:= FormatA(trmsg[TMsgStrId(Ord(sidWinner2) + (TeamsNumber - 2))], ts); |
132 s:= FormatA(trmsg[TMsgStrId(Ord(sidWinner2) + (TeamsNumber - 2))], ts); |
118 |
133 |
119 // The winner caption is the same as the stats message and not randomized |
134 // The winner caption is the same as the stats message and not randomized |
134 AddVoice(sndVictory, Teams[0]^.voicepack); |
149 AddVoice(sndVictory, Teams[0]^.voicepack); |
135 end; |
150 end; |
136 |
151 |
137 if SendGameResultOn then |
152 if SendGameResultOn then |
138 SendStat(siGameResult, shortstring(s)); |
153 SendStat(siGameResult, shortstring(s)); |
|
154 if allWin and SendAchievementsStatsOn then |
|
155 SendStat(siEverAfter, ''); |
139 AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000) |
156 AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000) |
140 end; |
157 end; |
141 SendStats; |
158 SendStats; |
142 end; |
159 end; |
143 TeamsGameOver:= true; |
160 TeamsGameOver:= true; |