<commit_before>var app = angular.module("site");

app.service("DisciplineService", ['ClanService', 'CharCreatorService',
 function(ClanService, CharCreatorService){

  this.setClan = setClan;
  this.setClanDisciplines = setClanDisciplines;
  this.selectDisciplinePt = selectDisciplinePt;
  this.selectedClan = ClanService.selectedClan;
  this.disciplinePts = 3;

  this.getFreebieMode = getFreebieMode;

  function getFreebieMode(){
    return CharCreatorService.freebieMode;
  }

  function selectDisciplinePt(discipline, index){

    var pointDiff = 0;

    //Different operations if using Freebie points.
    if(CharCreatorService.freebieMode){
      var disciplineFree = CharCreatorService.getFreebiePts();

      if(index < discipline.pointCount - 1)
        pointDiff = (discipline.pointCount * 7) - (index + 1 * 7);
      if((index == discipline.pointCount-1)){
        pointDiff = (discipline.pointCount * 7) - (index * 7);
        index -= 1;
      }
      else if(index > discipline.pointCount-1)
        pointDiff = ((discipline.pointCount-1) * 7) + (-7 * index);

      if(disciplineFree + pointDiff < 0)
        return null;

      CharCreatorService.changeFreebiePts(pointDiff);
      discipline.pointCount = (index+1);
      discipline.select(index);
      return;
    }
    else
       pointDiff = discipline.pointCount - (index+1);

    //Do math to make sure they can't spend points they don't have, even when
    //priorityPts isn't equal to 0.
    //Case example: increase 3 pts when pts = 2.
    if((this.disciplinePts + pointDiff < 0))
      return null;

    if(index == 0 && discipline.pointCount == 1){
      discipline.pointCount = 0;
      pointDiff = 1;
      index = -1;
    }
    else{
      //Change the point count in the discipline.
      discipline.pointCount = (index+1);
    }

    this.disciplinePts += pointDiff;
    //Fill in the dots!
    discipline.select(index);
  };

  function setClan(clan){
    this.selectedClan = clan;
    var newDisciplines = setClanDisciplines(clan.name);
    if(newDisciplines.length < this.selectedClanDisciplines.length){
      var diff = newDisciplines.length - this.selectedClanDisciplines.length;
      this.selectedClanDisciplines.splice(0, newDisciplines.length);
    }
    angular.extend(this.selectedClanDisciplines, newDisciplines);
  };

  class Discipline {
    constructor(name){
      this.name = name;
      this.pointCount = 0;
      this.points = [{id: 0, img: "./empty.png", type:""},
                     {id: 1, img: "./empty.png", type:""},
                     {id: 2, img: "./empty.png", type:""},
                     {id: 3, img: "./empty.png", type:""},
                     {id: 4, img: "./empty.png", type:""}];

      this.reset = function(){
        this.points.forEach(function(discipline){
          discipline.img = './empty.png';
        });
        this.pointCount = 0;
      };

      this.select = function(index){
        if(index == -1){
          this.reset();
          return;
        }
       if(this.points[index].img=="./full.png")
       {
         this.points.forEach(function(point){
           if(point.id <= index){
             return;
           }
           else{
             point.img = "./empty.png";
           }
         });
       }
       if(this.points[index].img=="./empty.png")
       {
         this.points.forEach(function(point){
           if(point.id > index){
             return;
           }
           else{
             point.img = "./full.png";
           }
         });
       }
      };
    }
  };

  var service = this;
  this.selectedClanDisciplines = setClanDisciplines();
  function setClanDisciplines(clan){
    var clanDisciplines = [];
    if(clan == "Children of Osiris"){
      clanDisciplines = [new Discipline("Bardo"), new Discipline(""), new Discipline("")];
    }<commit_msg>Some more work on point types<commit_after>var app = angular.module("site");

app.service("DisciplineService", ['ClanService', 'CharCreatorService',
 function(ClanService, CharCreatorService){

  this.setClan = setClan;
  this.setClanDisciplines = setClanDisciplines;
  this.selectDisciplinePt = selectDisciplinePt;
  this.selectedClan = ClanService.selectedClan;
  this.disciplinePts = 3;

  this.getFreebieMode = getFreebieMode;

  function getFreebieMode(){
    return CharCreatorService.freebieMode;
  }

  function selectDisciplinePt(discipline, index){

    var pointDiff = 0;

    //Different operations if using Freebie points.
    if(CharCreatorService.freebieMode){
      var disciplineFree = CharCreatorService.getFreebiePts();

      if(index < discipline.pointCount - 1)
        pointDiff = (discipline.pointCount * 7) - (index + 1 * 7);
      if((index == discipline.pointCount-1)){
        pointDiff = (discipline.pointCount * 7) - (index * 7);
        index -= 1;
      }
      else if(index > discipline.pointCount-1)
        pointDiff = ((discipline.pointCount-1) * 7) + (-7 * index);

      if(disciplineFree + pointDiff < 0)
        return null;

      CharCreatorService.changeFreebiePts(pointDiff);
      discipline.pointCount = (index+1);
      discipline.select(index, "freebie");
      return;
    }
    else
       pointDiff = discipline.pointCount - (index+1);

    //Do math to make sure they can't spend points they don't have, even when
    //priorityPts isn't equal to 0.
    //Case example: increase 3 pts when pts = 2.
    if((this.disciplinePts + pointDiff < 0))
      return null;

    if(index == 0 && discipline.pointCount == 1){
      discipline.pointCount = 0;
      pointDiff = 1;
      index = -1;
      discipline.points[0].type = "";
    }
    else{
      //Change the point count in the discipline.
      discipline.pointCount = (index+1);
    }

    this.disciplinePts += pointDiff;
    //Fill in the dots!
    discipline.select(index, "original");
  };

  function setClan(clan){
    this.selectedClan = clan;
    var newDisciplines = setClanDisciplines(clan.name);
    if(newDisciplines.length < this.selectedClanDisciplines.length){
      var diff = newDisciplines.length - this.selectedClanDisciplines.length;
      this.selectedClanDisciplines.splice(0, newDisciplines.length);
    }
    angular.extend(this.selectedClanDisciplines, newDisciplines);
  };

  class Discipline {
    constructor(name){
      this.name = name;
      this.pointCount = 0;
      this.points = [{id: 0, img: "./empty.png", type:""},
                     {id: 1, img: "./empty.png", type:""},
                     {id: 2, img: "./empty.png", type:""},
                     {id: 3, img: "./empty.png", type:""},
                     {id: 4, img: "./empty.png", type:""}];

      this.reset = function(){
        this.points.forEach(function(discipline){
          discipline.img = './empty.png';
        });
        this.pointCount = 0;
      };

      this.select = function(index, type){
        if(index == -1){
          this.reset();
          return;
        }
       if(this.points[index].img=="./full.png")
       {
         this.points.forEach(function(point){
           if(point.id <= index){
             return;
           }
           else{
             point.img = "./empty.png";
             point.type = "";
           }
         });
       }
       if(this.points[index].img=="./empty.png")
       {
         this.points.forEach(function(point){
           if(point.id > index){
             return;
           }
           else{
             if(!(point.img == "./full.png")){
               point.type = type;
             }
               point.img = "./full.png";
           }
         });
       }
      };
    }
  };

  var service = this;
  this.selectedClanDisciplines = setClanDisciplines();
  function setClanDisciplines(clan){
    var clanDisciplines = [];
    if(clan == "Children of Osiris"){
      clanDisciplines = [new Discipline("Bardo"), new Discipline(""), new Discipline("")];
    }
{'fraction_non_alphanumeric': 0.1371080360543354, 'fraction_numerical': 0.009267487622191189, 'mean_word_length': 2.1946472019464722, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 7, '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': '3288284', 'n_tokens_mistral': 2535, 'n_tokens_neox': 2398, 'n_words': 490}