<?php
define("DATETIMEFORMAT","yyyy-mm-tt, HH:MM Uhr");

function calculate_rank($rate,$bill,$missed_games) {
  $return=0;
  $bill_factor=3000/(user_max_bill()-user_min_bill());
  $return = ($rate+$bill_factor*$bill);  //50% Quote, 50% max Bill
  switch ($missed_games)
  {
    case 0:
    case 1:
      $return *= 1;
      break;
    case 2:
      $return *= 0.8;
      break;
    case 3:
      $return *= 0.6;
      break;
    case 4:
      $return *= 0.4;
      break;
    case 5:
      $return *= 0.2;
      break;
    default:
      $return *= 0;
  }
  //$return *= (-1/5)*(($missed_games<5)? $missed_games:5) + 1;
  //$return *= exp ( -1 * $missed_games );
  $return = ($return*10) / 6; //normalize to 10000
  return ($return);
}
?>
