<commit_before>import Event from '../../../tools/event/Event';
import {decodes} from './drawCounterDecodes';

const enum Count {
    renderCounterOffset = -5
}

export default class Player {

    constructor(private _collisionMask: number) {
        this.reset();
    }

    reset(): void {
        this.color = 0xFFFFFFFF;
        this.collision = 0;
        this._hmmClocks = 0;
        this._counter = 0;
        this._moving = false;
        this._width = 8;
        this._rendering = false;
        this._renderCounter = Count.renderCounterOffset;
        this._decodes = decodes[0];
        this._originalPattern = 0;
        this._pattern = 0;
        this._reflected = false;
        this._delaying = false;
    }

    grp(pattern: number) {
        if (this._delaying) {
            this._originalPatternPending = pattern;
        } else {
            this._originalPattern = pattern;
            this._updatePattern();
        }

        this.patternChange.dispatch(undefined);
    }

    nusiz(value: number): void {
        const masked = value & 0x07,
            oldWidth = this._width;

        if (masked === 5) {
            this._width = 16;
        } else if (masked === 7) {
            this._width = 32;
        } else {
            this._width = 8;
        }

        this._decodes = decodes[value & 0x07];

        if (this._rendering && this._renderCounter >= this._width) {
            this._rendering = false;
        }

        if (oldWidth !== this._width) {
            this._updatePattern();
        }
    }

    hmp(value: number): void {
        // Shift and flip the highest bit --- this gives us the necessary movement to the right
        this._hmmClocks = (value >>> 4) ^ 0x8;
    }

    resp(): void {
        this._counter = 0;
    }

    refp(value: number): void {
        this._reflected = (value & 0x08) > 0;
    }

    vdelp(value: number): void {
        if ((value & 0x01) > 0) {
            this._delaying = true;
        } else {
            if (this._delaying) {
                this.shufflePatterns();
            }

            this._delaying = false;
        }
    }<commit_msg>Rebuild player pattern after toggling refp.<commit_after>import Event from '../../../tools/event/Event';
import {decodes} from './drawCounterDecodes';

const enum Count {
    renderCounterOffset = -5
}

export default class Player {

    constructor(private _collisionMask: number) {
        this.reset();
    }

    reset(): void {
        this.color = 0xFFFFFFFF;
        this.collision = 0;
        this._hmmClocks = 0;
        this._counter = 0;
        this._moving = false;
        this._width = 8;
        this._rendering = false;
        this._renderCounter = Count.renderCounterOffset;
        this._decodes = decodes[0];
        this._originalPattern = 0;
        this._pattern = 0;
        this._reflected = false;
        this._delaying = false;
    }

    grp(pattern: number) {
        if (this._delaying) {
            this._originalPatternPending = pattern;
        } else {
            this._originalPattern = pattern;
            this._updatePattern();
        }

        this.patternChange.dispatch(undefined);
    }

    nusiz(value: number): void {
        const masked = value & 0x07,
            oldWidth = this._width;

        if (masked === 5) {
            this._width = 16;
        } else if (masked === 7) {
            this._width = 32;
        } else {
            this._width = 8;
        }

        this._decodes = decodes[value & 0x07];

        if (this._rendering && this._renderCounter >= this._width) {
            this._rendering = false;
        }

        if (oldWidth !== this._width) {
            this._updatePattern();
        }
    }

    hmp(value: number): void {
        // Shift and flip the highest bit --- this gives us the necessary movement to the right
        this._hmmClocks = (value >>> 4) ^ 0x8;
    }

    resp(): void {
        this._counter = 0;
    }

    refp(value: number): void {
        const oldReflected = this._reflected;

        this._reflected = (value & 0x08) > 0;

        if (this._reflected !== oldReflected) {
            this._updatePattern();
        }
    }

    vdelp(value: number): void {
        if ((value & 0x01) > 0) {
            this._delaying = true;
        } else {
            if (this._delaying) {
                this.shufflePatterns();
            }

            this._delaying = false;
        }
    }
{'fraction_non_alphanumeric': 0.1178595619778731, 'fraction_numerical': 0.01535335290133213, 'mean_word_length': 1.610489098408957, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '500706', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1268, 'n_words': 300}