<commit_before>module SpaceTac.View {
    "use strict";

    // Utility functions for sounds
    export class Audio {

        private game: Phaser.Game;

        private music: Phaser.Sound;

        constructor(game: Phaser.Game) {
            this.game = game;
            this.music = null;
        }

        // Check if the sound system is up and running
        isActive(): boolean {
            return this.game.sound.context ? true : false;
        }

        // Play a ponctual sound
        playOnce(key: string): void {
            if (this.isActive()) {
                this.game.sound.play(key);
            }
        }

        // Start a background music
        startMusic(key: string): void {
            if (this.isActive()) {
                if (this.music && this.music.key !== key) {
                    this.stopMusic();
                }
                if (!this.music) {
                    this.music = this.game.sound.play("music-" + key, 1, true);
                }
            }
        }

        // Stop currently playing background music
        stopMusic(): void {
            if (this.isActive()) {
                if (this.music) {
                    this.music.stop();
                    this.music = null;
                }
            }
        }

        // Toggle the mute status of the sound system
        toggleMute(): void {
            if (this.isActive()) {
                if (this.game.sound.volume > 0) {
                    this.game.sound.volume = 0;
                } else {<commit_msg>Fixed music restarting on startMusic, even when the same key was used<commit_after>module SpaceTac.View {
    "use strict";

    // Utility functions for sounds
    export class Audio {

        private game: Phaser.Game;

        private music: Phaser.Sound;

        constructor(game: Phaser.Game) {
            this.game = game;
            this.music = null;
        }

        // Check if the sound system is up and running
        isActive(): boolean {
            return this.game.sound.context ? true : false;
        }

        // Play a ponctual sound
        playOnce(key: string): void {
            if (this.isActive()) {
                this.game.sound.play(key);
            }
        }

        // Start a background music
        startMusic(key: string): void {
            key = "music-" + key;
            if (this.isActive()) {
                if (this.music && this.music.key !== key) {
                    this.stopMusic();
                }
                if (!this.music) {
                    this.music = this.game.sound.play(key, 1, true);
                }
            }
        }

        // Stop currently playing background music
        stopMusic(): void {
            if (this.isActive()) {
                if (this.music) {
                    this.music.stop();
                    this.music = null;
                }
            }
        }

        // Toggle the mute status of the sound system
        toggleMute(): void {
            if (this.isActive()) {
                if (this.game.sound.volume > 0) {
                    this.game.sound.volume = 0;
                } else {
{'fraction_non_alphanumeric': 0.10661183169882948, 'fraction_numerical': 0.0018981335020563112, 'mean_word_length': 1.1466395112016294, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1436490', 'n_tokens_mistral': 872, 'n_tokens_neox': 795, 'n_words': 215}