<commit_before>import * as util from '../../utils'
import Keyboard from '../Keyboard'
import Phaser from 'phaser'

// sizing and positioning constants
const WIDTH = 100
const HEIGHT = 100
const MARGIN = 4
const STROKE = 2
const TEXT_OFFSET = 20
const IMAGE_OFFSET = 28

export default class extends Phaser.Group {
    /**
     * Constructor
     *
     * @param game         Game object
     * @param x            Horizontal position
     * @param y            Vertical position
     * @param keys         Key bindings
     * @param keysPosition Where to display the key bindings: left or right
     */
    constructor (game, x, y, keys, keysPosition) {
        super(game)
        this.x = x
        this.y = y
        this.keys = keys
        this.keysPosition = keysPosition

        this._initialize()
        this._addKeyInfo()
        this._addSelector()
        this._addPlayers()
        this._updateSelectorPosition()
    }

    /**
     * Select the previous player from the list
     */
    previous() {
        if (this.confirmed)
            return

        let current = this.selection
        this.selection = Math.max(this.selection - 1, 0)

        if (current != this.selection) {
            this._updateSelectorPosition()
            this.changeSelectionSound.play()
        }
    }

    /**
     * Select the next player from the list
     */
    next() {
        if (this.confirmed)
            return

        let current = this.selection
        this.selection = Math.min(this.selection + 1, this.types.length - 1)

        if (current != this.selection) {
            this.playerSprites[current].animations.stop()
            this._updateSelectorPosition()
            this.changeSelectionSound.play()
        }
    }

    /**
     * Confirm the current player selection<commit_msg>fix for player selector (animations not stopping when selecting the previous player)<commit_after>import * as util from '../../utils'
import Keyboard from '../Keyboard'
import Phaser from 'phaser'

// sizing and positioning constants
const WIDTH = 100
const HEIGHT = 100
const MARGIN = 4
const STROKE = 2
const TEXT_OFFSET = 20
const IMAGE_OFFSET = 28

export default class extends Phaser.Group {
    /**
     * Constructor
     *
     * @param game         Game object
     * @param x            Horizontal position
     * @param y            Vertical position
     * @param keys         Key bindings
     * @param keysPosition Where to display the key bindings: left or right
     */
    constructor (game, x, y, keys, keysPosition) {
        super(game)
        this.x = x
        this.y = y
        this.keys = keys
        this.keysPosition = keysPosition

        this._initialize()
        this._addKeyInfo()
        this._addSelector()
        this._addPlayers()
        this._updateSelectorPosition()
    }

    /**
     * Select the previous player from the list
     */
    previous() {
        if (this.confirmed)
            return

        let current = this.selection
        this.selection = Math.max(this.selection - 1, 0)

        if (current != this.selection) {
            this.playerSprites[current].animations.stop()
            this._updateSelectorPosition()
            this.changeSelectionSound.play()
        }
    }

    /**
     * Select the next player from the list
     */
    next() {
        if (this.confirmed)
            return

        let current = this.selection
        this.selection = Math.min(this.selection + 1, this.types.length - 1)

        if (current != this.selection) {
            this.playerSprites[current].animations.stop()
            this._updateSelectorPosition()
            this.changeSelectionSound.play()
        }
    }

    /**
     * Confirm the current player selection
{'fraction_non_alphanumeric': 0.09217205450173657, 'fraction_numerical': 0.008549292011755277, 'mean_word_length': 1.8667687595712097, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3812055', 'n_tokens_mistral': 1039, 'n_tokens_neox': 970, 'n_words': 293}