<commit_before>var reducer = require('../core/reducer')
var _ = require('underscore')

module.exports = {
    name: 'corruption',
    title: 'Corruption',
    punchline: 'Here\'s your money',
    description: "",
    steps: {
            '1': "Draw the next event card {%; draw_card() %}. Using the symbols shown \
            on the ORIGINAL Event card ({{ event.expr }}) \
            , add up the values in the symbols on \
            the newly drawn card. The total value that this creates \
            determines your amount of {% corruption = card_value(event.expr) %}\
            ({{ corruption }}).",
            '2': "Reduce City AVs throughout your Empire equal to \
            the amount of Corruption ({{ corruption }}). You may choose which \
            Cities to reduce. Any City Reduced to 0 AV is \
            Decimated. {%; reduceCities() %}",
            '3': "Decimate all Gold you currently have.\
            {% change({'gold': '0'}, null) %}",
    },
    reduceCities: function() {
        var ctx = this;
        var opts = {
            map: this.engine.map.areas,
            initial: _.extend(_.clone(this.engine.map.areas), {'gold': this.engine.gold }),
            amount: corruption,
            name: 'corruption',
            shows: ['city'],
            edits: ['city'],
            reduce: function(key, chg) {
                this.amount -= this.initial[key].city - chg.city;
                return { 'city': chg.city };
            },
            current: function(chg, key, val) {
                if (!key)
                {
                    this.current = {};
                    _.each(this.initial, function(i, ik) {
                        if (i.city > 0)
                            this.current[ik] = i;
                    },this);
                }
            },
            check: function() {
                if (this._defaultCheck())
                    return true;
                var noCities = true;
                _.each(this.initial, function(i, ik) {
                    var trg = i.city;
                    if (this.targets[ik])
                        trg = this.targets[ik].city;
                    if (trg > 0)
                    {
                        noCities = false;
                    }
                },this);
                return noCities;
            }
        };
        var rdc = new reducer.Reducer(opts);
        ctx.engine.reducer(rdc, function(chg) {
            ctx.changes = chg;
            ctx.done && ctx.done();
        });
    }
}<commit_msg>Corruption use template reducer<commit_after>var reducer = require('../core/reducer')
var _ = require('underscore')

module.exports = {
    name: 'corruption',
    title: 'Corruption',
    punchline: 'Here\'s your money',
    description: "",
    steps: {
            '1': "Draw the next event card {%; draw_card() %}. Using the symbols shown \
            on the ORIGINAL Event card ({{ event.expr }}) \
            , add up the values in the symbols on \
            the newly drawn card. The total value that this creates \
            determines your amount of {% corruption = card_value(event.expr) %}\
            ({{ corruption }}).",
            '2': "Reduce City AVs throughout your Empire equal to \
            the amount of Corruption ({{ corruption }}). You may choose which \
            Cities to reduce. Any City Reduced to 0 AV is \
            Decimated. {%; reduceCities() %}",
            '3': "Decimate all Gold you currently have.\
            {% change({'gold': '0'}, null) %}",
    },
    reduceCities: function() {
        var ctx = this;
        var opts = reducer.Templates.basic(ctx, ['city']);
        opts.amount = corruption;
        var rdc = new reducer.Reducer(opts);
        ctx.engine.reducer(rdc, function(chg) {
            ctx.changes = chg;
            ctx.done && ctx.done();
        });
    }
}
{'fraction_non_alphanumeric': 0.12893243940175347, 'fraction_numerical': 0.0030943785456420837, 'mean_word_length': 1.444234404536862, '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': '2726437', 'n_tokens_mistral': 1066, 'n_tokens_neox': 1037, 'n_words': 303}