<commit_before>import { Injectable } from '@angular/core';

import { ChartStoreService } from '../chart-store/chart-store.service';

const indentedString = (string) => `    ${string}\n`;

const songString = (key, value) => indentedString(`${key} = ${value}`);
const noteString = (time, number) => indentedString(`${time} = N ${number} 0`);

@Injectable()
export class ChartBuilderService {

  constructor(private chartStore: ChartStoreService) {
  }

  buildChartString(): string {
    const song = this.buildSong();
    const syncTrack = this.buildSyncTrack();
    const events = this.buildEvents();
    const expertSingle = this.buildExpertSingle();
    return `[Song]\n{\n${song}}\n[SyncTrack]\n{\n${syncTrack}}\n[Events]\n{\n${events}}\n[ExpertSingle]\n{\n${expertSingle}}`;
  }

  private buildSong(): string {
    return songString('Name', 'Tower Of Heaven')
         + songString('Artist', 'Feint')
         + songString('Charter', 'DujekR')
         + songString('Resolution', '192')
  }

  private buildSyncTrack(): string {
    return indentedString(`0 = TS 4`)
         + indentedString(`0 = B ${this.chartStore.bpm * 1000}`);
  }

  private buildEvents(): string {
    return '';
  }

  private buildExpertSingle(): string {
    const noteStrings = [].concat(...this.chartStore.sortedNotes()
      .map((note) => {
        const time = note.time * 1000 / (60000 / (this.chartStore.bpm * 192));
        const timeString = `${time}`.split('.')[0].slice(0, 4);
        if (note.color.length === 0) {
          return [noteString(timeString, 7)]
        }
        return note.color.map((color) => noteString(timeString, color));
      }));
    return noteStrings.join('');
  }
}<commit_msg>fix: Fix bug where notes after 10 seconds had the wrong time<commit_after>import { Injectable } from '@angular/core';

import { ChartStoreService } from '../chart-store/chart-store.service';

const indentedString = (string) => `    ${string}\n`;

const songString = (key, value) => indentedString(`${key} = ${value}`);
const noteString = (time, number) => indentedString(`${time} = N ${number} 0`);

@Injectable()
export class ChartBuilderService {

  constructor(private chartStore: ChartStoreService) {
  }

  buildChartString(): string {
    const song = this.buildSong();
    const syncTrack = this.buildSyncTrack();
    const events = this.buildEvents();
    const expertSingle = this.buildExpertSingle();
    return `[Song]\n{\n${song}}\n[SyncTrack]\n{\n${syncTrack}}\n[Events]\n{\n${events}}\n[ExpertSingle]\n{\n${expertSingle}}`;
  }

  private buildSong(): string {
    return songString('Name', 'Tower Of Heaven')
         + songString('Artist', 'Feint')
         + songString('Charter', 'DujekR')
         + songString('Resolution', '192')
  }

  private buildSyncTrack(): string {
    return indentedString(`0 = TS 4`)
         + indentedString(`0 = B ${this.chartStore.bpm * 1000}`);
  }

  private buildEvents(): string {
    return '';
  }

  private buildExpertSingle(): string {
    const noteStrings = [].concat(...this.chartStore.sortedNotes()
      .map((note) => {
        const time = note.time * 1000 / (60000 / (this.chartStore.bpm * 192));
        const timeString = `${time}`.split('.')[0];
        if (note.color.length === 0) {
          return [noteString(timeString, 7)]
        }
        return note.color.map((color) => noteString(timeString, color));
      }));
    return noteStrings.join('');
  }
}
{'fraction_non_alphanumeric': 0.1774992713494608, 'fraction_numerical': 0.01632177207811134, 'mean_word_length': 3.4455958549222796, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '6638515', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1061, 'n_words': 226}