/* GameUpdate **CLIENT LIBRARY**
 * Turn weird data things into pretty strings
 * 
 */

var prettyPrint = {};

prettyPrint.headline = function(gameupdate) {
    if (!gameupdate) {
        return "";
    }
    var teams = gameupdate.getTeams();
    return teams[0].location + " " + teams[0].nickname +
            " vs " + teams[1].location + " " + teams[1].nickname;
}


/* TIME TAG LOGIC */

var QUARTER_TO_NAME = {
    1: "1st",
    2: "2nd",
    3: "3rd",
    4: "4th",
    5: "OT1",
    6: "OT2",
    7: "OT3",
    8: "OT4"
}

var INACTIVE_QUARTERS = {
  1: "End First",
  2: "Halftime",
  3: "End Third",
  4: "End Fourth",
  5: "End OT1",
  6: "End OT2",
  7: "End OT3",
  8: "End OT4",
}

prettyPrint.timeTag = function(gameupdate) {
    if (!gameupdate) 
        return "";
    var status = gameupdate.getStatus();
    var name = QUARTER_TO_NAME[status.period];
    if (!status.isActive) {
     return INACTIVE_QUARTERS[status.period];
    }
    if (status.name != "In-Progress") {
    return "final"
    }
    else {
      return name + " - " + getTime(status);
    }
}

function getTime(event_status_json) {
    return "" + event_status_json.minutes + ":" + event_status_json.seconds;
}

function isEndOfQuarter(event_status_json) {
    return (event_status_json.minHeight == 0 && event_status_json.seconds == 0)
}
