<commit_before>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ScoreManager : MonoBehaviour
{

	public class Score {
		public int maxCombo;
		public int enemiesKilled;
		public float dist;
	}

	public static int MAX_N = 10;

	public int combo;
	public int maxCombo;
	public int enemiesKilled;
	public float distance;

	public void Start() {
		combo = 0;
		maxCombo = 0;
		enemiesKilled = 0;
		distance = 0;
	}

	public void Hit() {
		enemiesKilled++;
		combo++;
	}

	public void EndCombo() {
		// TODO add score
		combo = 0;
		if (combo > maxCombo)
			SetMaxCombo (combo);
	}

	public void SetMaxCombo(int cmb) {
		maxCombo = cmb;
	}

	public void AddScore() {
		Score s = new Score ();
		Score[] scores;

		s.dist = distance;
		s.enemiesKilled = enemiesKilled;
		s.maxCombo = maxCombo;

		if (PlayerPrefs.HasKey ("n")) {
			int n = PlayerPrefs.GetInt("n");
			Score[] oldScores = GetHighScores (n);

			if (n < MAX_N)
				n++;
			scores = new Score[n];

			// Sorted insert
			int i = n;
			while (i >= 0 && scores [i].dist < s.dist)
				i--;
			if (i < n - 1)
				scores [i + 1] = s;
		} else {
			scores = new Score[] { s };
		}

		SetScores (scores);
	}<commit_msg>Fix ordered insertion<commit_after>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ScoreManager : MonoBehaviour
{

	public class Score {
		public int maxCombo;
		public int enemiesKilled;
		public float dist;
	}

	public static int MAX_N = 10;

	public int combo;
	public int maxCombo;
	public int enemiesKilled;
	public float distance;

	public void Start() {
		combo = 0;
		maxCombo = 0;
		enemiesKilled = 0;
		distance = 0;
	}

	public void Hit() {
		enemiesKilled++;
		combo++;
	}

	public void EndCombo() {
		// TODO add score
		combo = 0;
		if (combo > maxCombo)
			SetMaxCombo (combo);
	}

	public void SetMaxCombo(int cmb) {
		maxCombo = cmb;
	}

	public void AddScore() {
		Score s = new Score ();
		Score[] scores;

		s.dist = distance;
		s.enemiesKilled = enemiesKilled;
		s.maxCombo = maxCombo;

		if (PlayerPrefs.HasKey ("n")) {
			int n = PlayerPrefs.GetInt("n");
			Score[] oldScores = GetHighScores (n);

			if (n < MAX_N)
				n++;
			scores = new Score[n];

			// Sorted insert
			int i = n-1;
			while (i >= 0 && scores [i].dist < s.dist) {
				scores [i + 1] = scores [i];
				i--;
			}
			if (i < n - 1)
				scores [i + 1] = s;
		} else {
			scores = new Score[] { s };
		}

		SetScores (scores);
	}
{'fraction_non_alphanumeric': 0.12903225806451613, 'fraction_numerical': 0.008870967741935484, 'mean_word_length': 2.8287037037037037, 'pattern_counts': {'":': 0, '<': 9, '<?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': '1758095', 'n_tokens_mistral': 1078, 'n_tokens_neox': 918, 'n_words': 273}