home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Esportes / CrossingCup.swf / scripts / __Packages / CMatch.as < prev    next >
Text File  |  2007-12-11  |  3KB  |  113 lines

  1. class CMatch
  2. {
  3.    function CMatch(group, _team1, _team2)
  4.    {
  5.       this.played = false;
  6.       this.round = 1;
  7.       this.totalkick1 = CSessionManager.ins().numPlayPerGame;
  8.       this.totalkick2 = CSessionManager.ins().numPlayPerGame;
  9.       this.scoreteam1 = 0;
  10.       this.scoreteam2 = 0;
  11.       this.team1 = _team1;
  12.       this.team2 = _team2;
  13.    }
  14.    function tied()
  15.    {
  16.       if(this.scoreteam1 == this.scoreteam2)
  17.       {
  18.          return true;
  19.       }
  20.       return false;
  21.    }
  22.    function endRound(kicks)
  23.    {
  24.       if(kicks == undefined)
  25.       {
  26.          kicks = true;
  27.       }
  28.       if(this.round == 1)
  29.       {
  30.          if(kicks)
  31.          {
  32.             this.totalkick1 = this.totalkick1 - 1;
  33.          }
  34.          this.round = 2;
  35.       }
  36.       else
  37.       {
  38.          if(kicks)
  39.          {
  40.             this.totalkick2 = this.totalkick2 - 1;
  41.          }
  42.          this.round = 1;
  43.       }
  44.    }
  45.    function addScore()
  46.    {
  47.       if(this.round == 1)
  48.       {
  49.          this.scoreteam1 = this.scoreteam1 + 1;
  50.       }
  51.       else
  52.       {
  53.          this.scoreteam2 = this.scoreteam2 + 1;
  54.       }
  55.       this.played = true;
  56.    }
  57.    function addScorea(sc1, sc2)
  58.    {
  59.       this.scoreteam1 = sc1;
  60.       this.scoreteam2 = sc2;
  61.       this.played = true;
  62.       this.round = 2;
  63.    }
  64.    function randomMatch(cantied)
  65.    {
  66.       this.played = true;
  67.       if(!cantied)
  68.       {
  69.          while(this.tied())
  70.          {
  71.             this.scoreteam1 = Math.floor(Math.random() * CSessionManager.ins().numPlayPerGame);
  72.             this.scoreteam2 = Math.floor(Math.random() * CSessionManager.ins().numPlayPerGame);
  73.          }
  74.       }
  75.       else
  76.       {
  77.          this.scoreteam1 = Math.floor(Math.random() * CSessionManager.ins().numPlayPerGame);
  78.          this.scoreteam2 = Math.floor(Math.random() * CSessionManager.ins().numPlayPerGame);
  79.       }
  80.       this.round = 2;
  81.    }
  82.    function calculateResult()
  83.    {
  84.       if(CTournament.ins().tournamentPhase > 4)
  85.       {
  86.          return undefined;
  87.       }
  88.       if(this.scoreteam1 == this.scoreteam2)
  89.       {
  90.          this.team1.tied = this.team1.tied + 1;
  91.          this.team2.tied = this.team2.tied + 1;
  92.       }
  93.       else if(this.scoreteam1 > this.scoreteam2)
  94.       {
  95.          this.teamwin = this.team1;
  96.          this.team1.gap += this.scoreteam1 - this.scoreteam2;
  97.          this.team1.won = this.team1.won + 1;
  98.          this.team2.lost = this.team2.lost + 1;
  99.       }
  100.       else
  101.       {
  102.          this.teamwin = this.team2;
  103.          this.team2.gap += this.scoreteam2 - this.scoreteam1;
  104.          this.team2.won = this.team2.won + 1;
  105.          this.team1.lost = this.team1.lost + 1;
  106.       }
  107.       this.team1.goalin += this.scoreteam1;
  108.       this.team2.goalin += this.scoreteam2;
  109.       this.team1.calculateScore();
  110.       this.team2.calculateScore();
  111.    }
  112. }
  113.