home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
404 Jogos
/
CLJG.iso
/
Esportes
/
CrossingCup.swf
/
scripts
/
__Packages
/
CMatch.as
< prev
next >
Wrap
Text File
|
2007-12-11
|
3KB
|
113 lines
class CMatch
{
function CMatch(group, _team1, _team2)
{
this.played = false;
this.round = 1;
this.totalkick1 = CSessionManager.ins().numPlayPerGame;
this.totalkick2 = CSessionManager.ins().numPlayPerGame;
this.scoreteam1 = 0;
this.scoreteam2 = 0;
this.team1 = _team1;
this.team2 = _team2;
}
function tied()
{
if(this.scoreteam1 == this.scoreteam2)
{
return true;
}
return false;
}
function endRound(kicks)
{
if(kicks == undefined)
{
kicks = true;
}
if(this.round == 1)
{
if(kicks)
{
this.totalkick1 = this.totalkick1 - 1;
}
this.round = 2;
}
else
{
if(kicks)
{
this.totalkick2 = this.totalkick2 - 1;
}
this.round = 1;
}
}
function addScore()
{
if(this.round == 1)
{
this.scoreteam1 = this.scoreteam1 + 1;
}
else
{
this.scoreteam2 = this.scoreteam2 + 1;
}
this.played = true;
}
function addScorea(sc1, sc2)
{
this.scoreteam1 = sc1;
this.scoreteam2 = sc2;
this.played = true;
this.round = 2;
}
function randomMatch(cantied)
{
this.played = true;
if(!cantied)
{
while(this.tied())
{
this.scoreteam1 = Math.floor(Math.random() * CSessionManager.ins().numPlayPerGame);
this.scoreteam2 = Math.floor(Math.random() * CSessionManager.ins().numPlayPerGame);
}
}
else
{
this.scoreteam1 = Math.floor(Math.random() * CSessionManager.ins().numPlayPerGame);
this.scoreteam2 = Math.floor(Math.random() * CSessionManager.ins().numPlayPerGame);
}
this.round = 2;
}
function calculateResult()
{
if(CTournament.ins().tournamentPhase > 4)
{
return undefined;
}
if(this.scoreteam1 == this.scoreteam2)
{
this.team1.tied = this.team1.tied + 1;
this.team2.tied = this.team2.tied + 1;
}
else if(this.scoreteam1 > this.scoreteam2)
{
this.teamwin = this.team1;
this.team1.gap += this.scoreteam1 - this.scoreteam2;
this.team1.won = this.team1.won + 1;
this.team2.lost = this.team2.lost + 1;
}
else
{
this.teamwin = this.team2;
this.team2.gap += this.scoreteam2 - this.scoreteam1;
this.team2.won = this.team2.won + 1;
this.team1.lost = this.team1.lost + 1;
}
this.team1.goalin += this.scoreteam1;
this.team2.goalin += this.scoreteam2;
this.team1.calculateScore();
this.team2.calculateScore();
}
}