<commit_before>var type;
var level;

var Tower = function(worldX, worldY, tileX, tileY, tile) {
    var index = (tileX + "-" + tileY);

    if ($.inArray(index, tileForbiden) == -1) {
      this.tower = game.add.sprite(worldX, worldY, tile);
      this.tower.worldX = worldX;
      this.tower.worldY = worldY;
      this.tower.tileX = tileX;
      this.tower.tileY = tileY;
      this.tower.tile = tile;
      tileForbiden.push(index);

      if(towerSelected === "cannonTower") {
        this.tower.towerCost = 75;
        this.tower.animations.add("levelOne", [0,1,2,3,4], 5, true);
        this.tower.animations.add("levelTwo", [6,7,8,9,10,11], 5, true);
        this.tower.animations.add("levelThree", [13,14,15,16,17,18], 5, true);
        this.tower.fireTime = 500;
        this.tower.radius = 100;
        this.tower.level = 1;
        this.tower.type = "cannonTower";
        cash -= this.tower.towerCost;
        this.tower.ammunition = "cannon";
        this.tower.bulletDamage = 3;
        towers.add(this.tower);
        this.tower.animations.play("levelOne");
      }
      else if(towerSelected === 'frostTower') {
        this.tower.animations.add("levelOne", [0,1], 5, true);
        this.tower.animations.add("levelTwo", [2,3], 5, true);
        this.tower.animations.add("levelThree", [4,5], 5, true);
        this.tower.animations.play('levelOne');
        this.tower.towerCost = 150;
        this.tower.fireTime = 10;
        this.tower.radius = 100;
        this.tower.level = 1;
        this.tower.type = "frostTower";
        cash -= this.tower.towerCost;
        this.tower.ammunition = "frost";
        this.tower.bulletDamage = 0;
        towers.add(this.tower);
      } else if(towerSelected === 'plasmaTower'){
        this.tower.towerCost = 500;
        this.tower.animations.add("levelOne", [0], 10, true);
        this.tower.animations.add("levelTwo", [1], 10, true);
        this.tower.animations.add("levelThree", [2], 10, true);
        this.tower.fireTime = 10;
        this.tower.radius = 200;
        cash -= this.tower.towerCost;
        this.tower.level = 1;
        this.tower.type = "plasmaTower";
        this.tower.ammunition = "plasma";
        this.tower.bulletDamage = .02;
        towers.add(this.tower);
      } else if(towerSelected === 'flameTower'){
        this.tower.towerCost = 300;
        this.tower.animations.add("levelOne", [0,1,2], 10, true);
        this.tower.animations.add("levelTwo", [3,4,5], 10, true);
        this.tower.animations.add("levelThree", [6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21], 10, true);
        this.tower.animations.play("levelOne")
        this.tower.animations
        this.tower.fireTime = 100;
        this.tower.radius = 200;
        cash -= this.tower.towerCost;
        this.tower.level = 1;
        this.tower.type = "flameTower";
        this.tower.ammunition = "flame";
        this.tower.bulletDamage = .005;
        towers.add(this.tower);
      } else if(towerSelected === 'archerTower'){
        this.tower.towerCost = 50;
        this.tower.animations.add("levelOne", [0], 10, true);
        this.tower.animations.add("levelTwo", [1], 10, true);
        this.tower.animations.add("levelThree", [2], 10, true);
        this.tower.fireTime = 500;
        this.tower.radius = 200;
        cash -= this.tower.towerCost;
        this.tower.level = 1;
        this.tower.type = "archerTower";
        this.tower.ammunition = "arrow";
        this.tower.bulletDamage = .75;
        towers.add(this.tower);
      }
      this.tower.killZone = [];
      this.tower.fireLastTime = game.time.now + this.tower.fireTime;
    }
}

Tower.prototype.add = function(pointer) {
  if(canAddTower) {
    if(towerSelected == 'plasmaTower'){
      if(cash >= 500) {

      }
    }
    else if(towerSelected == 'cannonTower'){
      towerCash = (clickedTower.towerCost);
    }
    else if(towerSelected == 'frostTower'){
      towerCash = (clickedTower.towerCost);
    }
    else if(towerSelected == 'flameTower'){
      towerCash = (clickedTower.towerCost);
    }
    else if(towerSelected == 'archerTower'){
      towerCash = (clickedTower.towerCost);
    }
      Tower.prototype.posit(pointer)
      canAddTower = false;
    }
  }
}

Tower.prototype.levelTwo = function(tower) {
  console.log(tower);
   tower.animations.play('levelTwo');
}

Tower.prototype.levelThree = function(tower) {
   increment.visible = false;
   tower.animations.play('levelThree');
}

Tower.prototype.upgradeTower = function(clickedTower) {
  console.log(clickedTower)
  // if(towerSelected == 'plasmaTower'){
  //   towerCash = (clickedTower.towerCost);
  // }
  // else if(towerSelected == 'cannonTower'){
  //   towerCash = (clickedTower.towerCost);
  // }
  // else if(towerSelected == 'frostTower'){
  //   towerCash = (clickedTower.towerCost);
  // }
  // else if(towerSelected == 'flameTower'){
  //   towerCash = (clickedTower.towerCost);<commit_msg>towers cant be purchased without enough money<commit_after>var type;
var level;

var Tower = function(worldX, worldY, tileX, tileY, tile) {
    var index = (tileX + "-" + tileY);

    if ($.inArray(index, tileForbiden) == -1) {
      this.tower = game.add.sprite(worldX, worldY, tile);
      this.tower.worldX = worldX;
      this.tower.worldY = worldY;
      this.tower.tileX = tileX;
      this.tower.tileY = tileY;
      this.tower.tile = tile;
      tileForbiden.push(index);

      if(towerSelected === "cannonTower") {
        this.tower.towerCost = 75;
        this.tower.animations.add("levelOne", [0,1,2,3,4], 5, true);
        this.tower.animations.add("levelTwo", [6,7,8,9,10,11], 5, true);
        this.tower.animations.add("levelThree", [13,14,15,16,17,18], 5, true);
        this.tower.fireTime = 500;
        this.tower.radius = 100;
        this.tower.level = 1;
        this.tower.type = "cannonTower";
        cash -= this.tower.towerCost;
        this.tower.ammunition = "cannon";
        this.tower.bulletDamage = 3;
        towers.add(this.tower);
        this.tower.animations.play("levelOne");
      }
      else if(towerSelected === 'frostTower') {
        this.tower.animations.add("levelOne", [0,1], 5, true);
        this.tower.animations.add("levelTwo", [2,3], 5, true);
        this.tower.animations.add("levelThree", [4,5], 5, true);
        this.tower.animations.play('levelOne');
        this.tower.towerCost = 150;
        this.tower.fireTime = 10;
        this.tower.radius = 100;
        this.tower.level = 1;
        this.tower.type = "frostTower";
        cash -= this.tower.towerCost;
        this.tower.ammunition = "frost";
        this.tower.bulletDamage = 0;
        towers.add(this.tower);
      } else if(towerSelected === 'plasmaTower'){
        this.tower.towerCost = 500;
        this.tower.animations.add("levelOne", [0], 10, true);
        this.tower.animations.add("levelTwo", [1], 10, true);
        this.tower.animations.add("levelThree", [2], 10, true);
        this.tower.fireTime = 10;
        this.tower.radius = 200;
        cash -= this.tower.towerCost;
        this.tower.level = 1;
        this.tower.type = "plasmaTower";
        this.tower.ammunition = "plasma";
        this.tower.bulletDamage = .02;
        towers.add(this.tower);
      } else if(towerSelected === 'flameTower'){
        this.tower.towerCost = 300;
        this.tower.animations.add("levelOne", [0,1,2], 10, true);
        this.tower.animations.add("levelTwo", [3,4,5], 10, true);
        this.tower.animations.add("levelThree", [6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21], 10, true);
        this.tower.animations.play("levelOne")
        this.tower.animations
        this.tower.fireTime = 100;
        this.tower.radius = 200;
        cash -= this.tower.towerCost;
        this.tower.level = 1;
        this.tower.type = "flameTower";
        this.tower.ammunition = "flame";
        this.tower.bulletDamage = .005;
        towers.add(this.tower);
      } else if(towerSelected === 'archerTower'){
        this.tower.towerCost = 50;
        this.tower.animations.add("levelOne", [0], 10, true);
        this.tower.animations.add("levelTwo", [1], 10, true);
        this.tower.animations.add("levelThree", [2], 10, true);
        this.tower.fireTime = 500;
        this.tower.radius = 200;
        cash -= this.tower.towerCost;
        this.tower.level = 1;
        this.tower.type = "archerTower";
        this.tower.ammunition = "arrow";
        this.tower.bulletDamage = .75;
        towers.add(this.tower);
      }
      this.tower.killZone = [];
      this.tower.fireLastTime = game.time.now + this.tower.fireTime;
    }
}

Tower.prototype.add = function(pointer) {
  if(canAddTower) {
    if(towerSelected == 'plasmaTower'){
      if(cash >= 500) {
        Tower.prototype.posit(pointer)
        canAddTower = false;
      }
    } else if(towerSelected == 'cannonTower'){
      if(cash >= 75) {
        Tower.prototype.posit(pointer)
        canAddTower = false;
      }
    } else if(towerSelected == 'frostTower'){
      if(cash >= 150) {
        Tower.prototype.posit(pointer)
        canAddTower = false;
      }
    } else if(towerSelected == 'flameTower'){
      if(cash >= 300) {
        Tower.prototype.posit(pointer)
        canAddTower = false;
      }
    } else if(towerSelected == 'archerTower'){
      if(cash >= 50) {
        Tower.prototype.posit(pointer)
        canAddTower = false;
      }
    }
    }
  }
}

Tower.prototype.levelTwo = function(tower) {
  console.log(tower);
   tower.animations.play('levelTwo');
}

Tower.prototype.levelThree = function(tower) {
   increment.visible = false;
   tower.animations.play('levelThree');
}

Tower.prototype.upgradeTower = function(clickedTower) {
  console.log(clickedTower)
  // if(towerSelected == 'plasmaTower'){
  //   towerCash = (clickedTower.towerCost);
  // }
  // else if(towerSelected == 'cannonTower'){
  //   towerCash = (clickedTower.towerCost);
  // }
  // else if(towerSelected == 'frostTower'){
  //   towerCash = (clickedTower.towerCost);
  // }
  // else if(towerSelected == 'flameTower'){
  //   towerCash = (clickedTower.towerCost);
{'fraction_non_alphanumeric': 0.16115907512156397, 'fraction_numerical': 0.03155701101518309, 'mean_word_length': 2.5090529247910864, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7345274', 'n_tokens_mistral': 3906, 'n_tokens_neox': 3697, 'n_words': 541}