home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Esportes / VirtualCurling.swf / scripts / frame_142 / DoAction.as
Encoding:
Text File  |  2005-08-08  |  3.2 KB  |  139 lines

  1. function check_results()
  2. {
  3.    dist_to_middle = new array();
  4.    correct_dtm = new array();
  5.    sorted = new array();
  6.    CForder_of_array = new array("xx","c","h","c","h","c","h","c","h");
  7.    UForder_of_array = new array("xx","h","c","h","c","h","c","h","c");
  8.    temp_c_OR_H = new array();
  9.    c_OR_H = new array();
  10.    if(first_play == "user")
  11.    {
  12.       temp_C_OR_H = UForder_of_array;
  13.    }
  14.    else
  15.    {
  16.       temp_C_OR_H = CForder_of_array;
  17.    }
  18.    ball = 1;
  19.    while(8 >= ball)
  20.    {
  21.       if(in_zone[ball])
  22.       {
  23.          thisball = eval("stone" + ball);
  24.          dtmx = middle_movie._x - realx[ball];
  25.          dtmy = middle_movie._y - (400 - realy[ball]);
  26.          trace("mmmy = " + middle_movie._y);
  27.          trace("mmmx = " + middle_movie._x);
  28.          dist_to_middle[ball] = Math.sqrt(dtmx * dtmx + dtmy * dtmy);
  29.       }
  30.       else
  31.       {
  32.          dist_to_middle[ball] = 999999;
  33.          temp_c_or_h[ball] = "x";
  34.       }
  35.       trace("dist_to_middle" + dist_to_middle[ball]);
  36.       if(home_radius + 26 < dist_to_middle[ball])
  37.       {
  38.          dist_to_middle[ball] = 999999;
  39.          temp_c_or_h[ball] = "x";
  40.       }
  41.       ball++;
  42.    }
  43.    ball = 1;
  44.    while(8 >= ball)
  45.    {
  46.       correct_dtm[ball] = dist_to_middle[ball];
  47.       c_or_h[ball] = temp_c_or_h[ball];
  48.       ball++;
  49.    }
  50.    sorted_list = false;
  51.    while(!sorted_list)
  52.    {
  53.       sorted_list = true;
  54.       i = 1;
  55.       while(7 >= i)
  56.       {
  57.          if(correct_dtm[i + 1] < correct_dtm[i])
  58.          {
  59.             sorted_list = false;
  60.             temp_sc = correct_dtm[i];
  61.             correct_dtm[i] = correct_dtm[i + 1];
  62.             correct_dtm[i + 1] = temp_sc;
  63.             temp_sc = c_or_h[i];
  64.             c_or_h[i] = c_or_h[i + 1];
  65.             c_or_h[i + 1] = temp_sc;
  66.          }
  67.          i++;
  68.       }
  69.    }
  70.    ball = 1;
  71.    while(8 >= ball)
  72.    {
  73.       trace("stone " + ball + " dist " + correct_dtm[ball] + " " + c_or_h[ball]);
  74.       ball++;
  75.    }
  76.    nearest = c_or_h[1];
  77.    if(nearest == "c" or nearest == "h")
  78.    {
  79.       pts = 1;
  80.       found_end = false;
  81.       i = 2;
  82.       while(4 >= i)
  83.       {
  84.          if(nearest == c_or_h[i] and !found_end)
  85.          {
  86.             pts++;
  87.          }
  88.          else
  89.          {
  90.             found_end = true;
  91.          }
  92.          i++;
  93.       }
  94.    }
  95.    else
  96.    {
  97.       pts = 0;
  98.    }
  99.    trace("score is...... " + pts + " to " + nearest);
  100.    if(nearest == "c")
  101.    {
  102.       computer_score += pts;
  103.    }
  104.    else
  105.    {
  106.       user_score += pts;
  107.    }
  108. }
  109. if(stone_in_use == 8)
  110. {
  111.    check_results();
  112.    totals_message = "";
  113.    if(end_no == 1)
  114.    {
  115.       if(user_score < computer_score)
  116.       {
  117.          totals_message = " RED: " + (computer_score - user_score);
  118.       }
  119.       if(computer_score < user_score)
  120.       {
  121.          totals_message = " BLUE: " + (- computer_score + user_score);
  122.       }
  123.       if(computer_score == user_score)
  124.       {
  125.          totals_message = "";
  126.       }
  127.    }
  128.    else
  129.    {
  130.       totals_message = " BLUE: " + user_score + " RED: " + computer_score;
  131.    }
  132.    ends_message = "";
  133.    score_message = ends_message + totals_message;
  134.    if(end_no == 2)
  135.    {
  136.       winpoints = user_score - computer_score;
  137.    }
  138. }
  139.