define(['/socket.io/socket.io.js'], function () {
  var Score = function () {
    this.moves = []
  };

  Score.prototype.init = function (x, y) {
    this.moves = [];
  };

  Score.prototype.submit = function(){
    console.log('Submitting score...');
    var socket = io.connect();
    socket.emit('scoreSubmit', { score: this.calculate() });
  };

  Score.prototype.calculate = function(){
    var total = 0;
    for(var i = 0; i < this.moves.length; i++){
      for (var j = 0; j < this.moves[i].length; j++ ) {
        // * j is a basic combo modifier, the deeper into the array's
        // second dimension we go, the bigger the combo was
        var point = this.moves[i][j];
        if (point > 0){
          if (point > 10)
            point = point * 1.5;
          else if (point > 20)
            point = point * 2;

          total += ((point * 10)) * (j + 1);
        }
      }
    }

    return total;
  };
  return Score;
});

