@@ -34,6 +34,7 @@ var CreateMatch = function(team1,team2,stage)
34
34
var forceQuit_ = false ;
35
35
var forceQuitReason_ = 0 ;
36
36
var isAIMatch_ = false ;
37
+ var roundOverFrame_ = CONSTANTS . NO_FRAME ;
37
38
38
39
var nbAirborne_ = 0 ;
39
40
game_ . resetFrame ( ) ;
@@ -78,7 +79,6 @@ var CreateMatch = function(team1,team2,stage)
78
79
Match . prototype . getTeamB = function ( ) { return teamB_ ; }
79
80
Match . prototype . getDefeatedTeam = function ( ) { return defeatedTeam_ ; }
80
81
Match . prototype . setDefeatedTeam = function ( value ) { defeatedTeam_ = value ; }
81
- Match . prototype . isRoundOver = function ( ) { return isRoundOver_ ; }
82
82
Match . prototype . setRoundOver = function ( value ) { isRoundOver_ = value ; }
83
83
Match . prototype . getGotoNewRoundFrame = function ( ) { return gotoNewRoundFrame_ ; }
84
84
Match . prototype . setGotoNewRoundFrame = function ( value ) { gotoNewRoundFrame_ = value ; }
@@ -94,6 +94,12 @@ var CreateMatch = function(team1,team2,stage)
94
94
Match . prototype . setAllowInput = function ( value ) { allowInput_ = value ; }
95
95
96
96
Match . prototype . getStage = function ( ) { return stage_ ; }
97
+
98
+ Match . prototype . isRoundOver = function ( )
99
+ {
100
+ return isRoundOver_ ;
101
+ }
102
+
97
103
Match . prototype . resetKeys = function ( )
98
104
{
99
105
for ( var i = 0 ; i < teamA_ . getPlayers ( ) . length ; ++ i )
@@ -206,7 +212,7 @@ var CreateMatch = function(team1,team2,stage)
206
212
if ( teamA_ . getPlayer ( i ) . Id != loseIgnoreId )
207
213
teamA_ . getPlayer ( i ) . forceLose ( attackDirection ) ;
208
214
for ( var i = 0 ; i < teamB_ . getPlayers ( ) . length ; ++ i )
209
- teamB_ . getPlayer ( i ) . justWon ( frame ) ;
215
+ teamB_ . getPlayer ( i ) . onOtherTeamDead ( frame ) ;
210
216
break ;
211
217
}
212
218
case CONSTANTS . TEAM2 :
@@ -215,41 +221,80 @@ var CreateMatch = function(team1,team2,stage)
215
221
if ( teamB_ . getPlayer ( i ) . Id != loseIgnoreId )
216
222
teamB_ . getPlayer ( i ) . forceLose ( attackDirection ) ;
217
223
for ( var i = 0 ; i < teamA_ . getPlayers ( ) . length ; ++ i )
218
- teamA_ . getPlayer ( i ) . justWon ( frame ) ;
224
+ teamA_ . getPlayer ( i ) . onOtherTeamDead ( frame ) ;
219
225
break ;
220
226
}
221
227
}
222
228
}
223
- /*Should be called after the player who was defeated hits the ground*/
224
- Match . prototype . deadAnimationComplete = function ( player , frame )
229
+
230
+ Match . prototype . onCanEndRound = function ( teamThatLost )
225
231
{
226
- if ( ! this . isRoundOver ( ) )
232
+ if ( roundOverFrame_ == CONSTANTS . NO_FRAME && this . canEndRound ( ) )
227
233
{
228
- this . setRoundOver ( true ) ;
229
- game_ . resetSpeed ( ) ;
230
- this . setGotoNewRoundFrame ( frame ) ;
231
-
232
- announcer_ . endRound ( ) ;
233
-
234
- var t1Dead = teamA_ . getHealthbar ( ) . getAmount ( ) == 0 ;
235
- var t2Dead = teamB_ . getHealthbar ( ) . getAmount ( ) == 0 ;
234
+ roundOverFrame_ = game_ . getCurrentFrame ( ) + CONSTANTS . ROUND_OVER_DELAY ;
235
+ }
236
236
237
- if ( t1Dead && t2Dead )
238
- {
239
- teamA_ . onDrawRound ( ) ;
240
- teamB_ . onDrawRound ( ) ;
241
- }
242
- else if ( t1Dead )
237
+ //reset the game speed if all of the dead players have completed their "dead animation"
238
+ switch ( teamThatLost )
239
+ {
240
+ case CONSTANTS . TEAM1 :
243
241
{
244
- teamA_ . onLostRound ( ) ;
245
- teamB_ . onWonRound ( ) ;
242
+ for ( var i = 0 ; i < teamA_ . getPlayers ( ) . length ; ++ i )
243
+ if ( ! teamA_ . getPlayer ( i ) . CanEndRound )
244
+ return ;
245
+ game_ . resetSpeed ( ) ;
246
+ break ;
246
247
}
247
- else if ( t2Dead )
248
+ case CONSTANTS . TEAM2 :
248
249
{
249
- teamA_ . onWonRound ( ) ;
250
- teamB_ . onLostRound ( ) ;
250
+ for ( var i = 0 ; i < teamB_ . getPlayers ( ) . length ; ++ i )
251
+ if ( ! teamB_ . getPlayer ( i ) . CanEndRound )
252
+ return ;
253
+ game_ . resetSpeed ( ) ;
254
+ break ;
251
255
}
256
+ }
257
+ }
252
258
259
+ //this function should be used to ensure the round winner isnt computed prematurely!
260
+ Match . prototype . canEndRound = function ( )
261
+ {
262
+ for ( var i = 0 ; i < teamA_ . getPlayers ( ) . length ; ++ i )
263
+ if ( ! teamA_ . getPlayer ( i ) . CanEndRound )
264
+ return false ;
265
+ for ( var i = 0 ; i < teamB_ . getPlayers ( ) . length ; ++ i )
266
+ if ( ! teamB_ . getPlayer ( i ) . CanEndRound )
267
+ return false ;
268
+
269
+ return true ;
270
+ }
271
+
272
+ /*Should be called after the player who was defeated hits the ground*/
273
+ Match . prototype . onEndRound = function ( frame )
274
+ {
275
+ this . setRoundOver ( true ) ;
276
+ game_ . resetSpeed ( ) ;
277
+ this . setGotoNewRoundFrame ( frame ) ;
278
+
279
+ announcer_ . endRound ( ) ;
280
+
281
+ var t1Dead = teamA_ . getHealthbar ( ) . getAmount ( ) == 0 ;
282
+ var t2Dead = teamB_ . getHealthbar ( ) . getAmount ( ) == 0 ;
283
+
284
+ if ( t1Dead && t2Dead )
285
+ {
286
+ teamA_ . onDrawRound ( ) ;
287
+ teamB_ . onDrawRound ( ) ;
288
+ }
289
+ else if ( t1Dead )
290
+ {
291
+ teamA_ . onLostRound ( ) ;
292
+ teamB_ . onWonRound ( frame ) ;
293
+ }
294
+ else if ( t2Dead )
295
+ {
296
+ teamA_ . onWonRound ( frame ) ;
297
+ teamB_ . onLostRound ( ) ;
253
298
}
254
299
}
255
300
/*Registers an action*/
@@ -638,6 +683,12 @@ var CreateMatch = function(team1,team2,stage)
638
683
teamA_ . frameMove ( frame , stage_ . X , stage_ . getGroundY ( ) , this . getAllowInput ( ) ) ;
639
684
teamB_ . frameMove ( frame , stage_ . X , stage_ . getGroundY ( ) , this . getAllowInput ( ) ) ;
640
685
686
+ if ( ( roundOverFrame_ != CONSTANTS . NO_FRAME ) && ( frame > roundOverFrame_ ) )
687
+ {
688
+ roundOverFrame_ = CONSTANTS . NO_FRAME ;
689
+ this . onEndRound ( frame ) ;
690
+ }
691
+
641
692
if ( round_ != 1 )
642
693
{
643
694
this . handleOtherRounds ( frame ) ;
0 commit comments