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

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