<commit_before>import React, {Component, PropTypes} from 'react';
import {observer} from 'mobx-react';
import Matter from 'matter-js';

import {
    AudioPlayer,
    Body,
    Sprite,
} from '../../src';

@observer
export default class Character extends Component {

    static propTypes = {
        keys: PropTypes.object,
        onEnterBuilding: PropTypes.func,
        onShoot: PropTypes.func,
        onReload: PropTypes.func,
        store: PropTypes.object,
    };

    static contextTypes = {
        engine: PropTypes.object,
        scale: PropTypes.number,
    };

    handlePlayStateChanged = (state) => {
        this.setState({
            spritePlaying: state ? true : false
        });
    };

    getContextLoop = (contextLoop) => {
        this.setState({
            contextLoop: contextLoop
        });
    };

    move = (body, x) => {
        this.lastDirection = (x < 0 && Math.abs(x) > 2) ? 1 : 0;
        Matter.Body.setVelocity(body, {x, y: 0});
    };

    jump = (body) => {
        this.jumpNoise.play();
        this.isJumping = true;
        Matter.Body.applyForce(
            body,
            {x: 0, y: 0},
            {x: 0, y: -0.3},
        );
        Matter.Body.set(body, 'friction', 0.0001);
    };

    shoot = () => {
        this.isShooting = true;
        let direction = this.lastDirection > 0?-1:1;
        if(this.props.ammo > 0) {
            this.props.onShoot();
            this.setState({
                characterState: 3,
                direction,
                repeat: true
            });
        }
        else {
            this.reload();
        }
    };

    reload = () => {
        if(!this.state.reloadTimeStamp) {
            this.setState({
                ticksPerFrame:15,
                reloadTimeStamp:this.state.contextLoop
            });
        }
        let direction = this.lastDirection > 0?-1:1;
        this.setState({
            characterState: 4,
            direction,
            repeat: false
        });

        if(this.state.reloadTimeStamp) {
            if(this.state.contextLoop>this.state.reloadTimeStamp+30) {
                this.props.onReload();
                this.setState({
                    ticksPerFrame:5,
                    reloadTimeStamp:0
                });
            }
        }
    };

    punch = () => {
        this.isPunching = true;
        this.setState({
            characterState: 99,
            repeat: false,
        });
    };

    getDoorIndex = (body) => {
        let doorIndex = null;

        const doorPositions = [...Array(6).keys()].map((a) => {
            return [(512 * a) + 208, (512 * a) + 272];
        });

        doorPositions.forEach((dp, di) => {
            if (body.position.x + 64 > dp[0] && body.position.x + 64 < dp[1]) {
                doorIndex = di;
            }
        });

        return doorIndex;
    }

    enterBuilding = (body) => {
        const doorIndex = this.getDoorIndex(body);

        if (doorIndex !== null) {
            this.setState({
                characterState: 3,
            });
            this.isLeaving = true;<commit_msg>disable punch<commit_after>import React, {Component, PropTypes} from 'react';
import {observer} from 'mobx-react';
import Matter from 'matter-js';

import {
    AudioPlayer,
    Body,
    Sprite,
} from '../../src';

@observer
export default class Character extends Component {

    static propTypes = {
        keys: PropTypes.object,
        onEnterBuilding: PropTypes.func,
        onShoot: PropTypes.func,
        onReload: PropTypes.func,
        store: PropTypes.object,
    };

    static contextTypes = {
        engine: PropTypes.object,
        scale: PropTypes.number,
    };

    handlePlayStateChanged = (state) => {
        this.setState({
            spritePlaying: state ? true : false
        });
    };

    getContextLoop = (contextLoop) => {
        this.setState({
            contextLoop: contextLoop
        });
    };

    move = (body, x) => {
        this.lastDirection = (x < 0 && Math.abs(x) > 2) ? 1 : 0;
        Matter.Body.setVelocity(body, {x, y: 0});
    };

    jump = (body) => {
        this.jumpNoise.play();
        this.isJumping = true;
        Matter.Body.applyForce(
            body,
            {x: 0, y: 0},
            {x: 0, y: -0.3},
        );
        Matter.Body.set(body, 'friction', 0.0001);
    };

    shoot = () => {
        this.isShooting = true;
        let direction = this.lastDirection > 0?-1:1;
        if(this.props.ammo > 0) {
            this.props.onShoot();
            this.setState({
                characterState: 3,
                direction,
                repeat: true
            });
        }
        else {
            this.reload();
        }
    };

    reload = () => {
        if(!this.state.reloadTimeStamp) {
            this.setState({
                reloadTimeStamp:this.state.contextLoop
            });
        }
        let direction = this.lastDirection > 0?-1:1;
        this.setState({
            characterState: 4,
            direction,
            ticksPerFrame:15,
            repeat: false
        });

        if(this.state.reloadTimeStamp) {
            if(this.state.contextLoop>this.state.reloadTimeStamp+30) {
                this.props.onReload();
                this.setState({
                    ticksPerFrame:5,
                    reloadTimeStamp:null
                });
            }
        }
    };

    punch = () => {
        // this.reload();
    };

    getDoorIndex = (body) => {
        let doorIndex = null;

        const doorPositions = [...Array(6).keys()].map((a) => {
            return [(512 * a) + 208, (512 * a) + 272];
        });

        doorPositions.forEach((dp, di) => {
            if (body.position.x + 64 > dp[0] && body.position.x + 64 < dp[1]) {
                doorIndex = di;
            }
        });

        return doorIndex;
    }

    enterBuilding = (body) => {
        const doorIndex = this.getDoorIndex(body);

        if (doorIndex !== null) {
            this.setState({
                characterState: 3,
            });
            this.isLeaving = true;
{'fraction_non_alphanumeric': 0.13541326363933356, 'fraction_numerical': 0.016497876510944136, 'mean_word_length': 1.4144321766561514, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 37, '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': '4000395', 'n_tokens_mistral': 1913, 'n_tokens_neox': 1795, 'n_words': 348}