<commit_before>/**
 * Created by petermares on 14/03/2016.
 */

module.exports = AutoClickPowerup;

// TODO: Implement time based expiry on auto clicking

function AutoClickPowerup(config) {
    this.clicks_per_second = config.clicks_per_second;
    this.expiresAfter = config.expiresAfter;
    this.buyOnce = config.buyOnce;
    this.expired = false;
    this.lastTime = Date.now();
    this.expiryTimestamp;

    if ( this.expiresAfter ) {
        this.expireTimestamp = Date.now() + this.expiresAfter;
    }

    this.onTick = function(clickEngine) {
        var now = Date.now();

        if ( now <= this.expiryTimestamp || !this.expiryTimestamp ) {
            if ( now - this.lastTime > 1000 / this.clicks_per_second ) {
                clickEngine.click({x: 200, y: 200}, false);
                this.lastTime = Date.now();
            }
        } else {
            this.expired = true;
        }
    }
}

<commit_msg>Fixed the bug in auto-click expiry<commit_after>/**
 * Created by petermares on 14/03/2016.
 */

module.exports = AutoClickPowerup;

function AutoClickPowerup(config) {
    this.clicks_per_second = config.clicks_per_second;
    this.expiresAfter = config.expiresAfter;
    this.buyOnce = config.buyOnce;
    this.expired = false;
    this.lastTime = Date.now();
    this.expiryTimestamp;

    if ( this.expiresAfter ) {
        this.expiryTimestamp = Date.now() + this.expiresAfter;
    }

    this.onTick = function(clickEngine) {
        var now = Date.now();

        if ( now <= this.expiryTimestamp || !this.expiryTimestamp ) {
            if ( now - this.lastTime > 1000 / this.clicks_per_second ) {
                clickEngine.click({x: 200, y: 200}, false);
                this.lastTime = Date.now();
            }
        } else {
            this.expired = true;
        }
    }
}


{'fraction_non_alphanumeric': 0.11978021978021978, 'fraction_numerical': 0.01978021978021978, 'mean_word_length': 2.2003514938488578, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5755561', 'n_tokens_mistral': 627, 'n_tokens_neox': 569, 'n_words': 113}