<commit_before>require("base.class")
require("npc.base.consequence.consequence")

module("npc.base.consequence.skill", package.seeall)

skill = base.class.class(npc.base.consequence.consequence.consequence,
function(self, group, name, mode, value)
    npc.base.consequence.consequence.consequence:init(self);
    self["value"], self["valuetype"] = npc.base.talk._set_value(value);
    self["group"] = group;
    self["name"] = name;
    if (mode == "=") then
        self["perform"] = _skill_helper_set;
    elseif (mode == "+") then
        self["perform"] = _skill_helper_add;
    elseif (mode == "-") then
        self["perform"] = _skill_helper_sub;
    else
        -- unkonwn comparator
    end;
end);

function _skill_helper_set(self, npcChar, player)
    local value = npc.base.talk._get_value(self.npc, self.value, self.valuetype);
    local currSkill = player:getSkill(self.name);
    local modSkill = value - currSkill;
    player:increaseSkill(self.group, self.name, modSkill);
end;

function _skill_helper_add(self, npcChar, player)
    local value = npc.base.talk._get_value(self.npc, self.value, self.valuetype);
    player:increaseSkill(self.group, self.name, value);
end;

function _skill_helper_sub(self, npcChar, player)
    local value = npc.base.talk._get_value(self.npc, self.value, self.valuetype);
    player:increaseSkill(self.group, self.name, -value);
end;<commit_msg>Changed easyNPC framework for new skills<commit_after>require("base.class")
require("npc.base.consequence.consequence")

module("npc.base.consequence.skill", package.seeall)

skill = base.class.class(npc.base.consequence.consequence.consequence,
function(self, name, mode, value)
    npc.base.consequence.consequence.consequence:init(self);
    self["value"], self["valuetype"] = npc.base.talk._set_value(value);
    self["name"] = name;
    if (mode == "=") then
        self["perform"] = _skill_helper_set;
    elseif (mode == "+") then
        self["perform"] = _skill_helper_add;
    elseif (mode == "-") then
        self["perform"] = _skill_helper_sub;
    else
        -- unkonwn comparator
    end;
end);

function _skill_helper_set(self, npcChar, player)
    local value = npc.base.talk._get_value(self.npc, self.value, self.valuetype);
    local currSkill = player:getSkill(self.name);
    local modSkill = value - currSkill;
    player:increaseSkill(self.name, modSkill);
end;

function _skill_helper_add(self, npcChar, player)
    local value = npc.base.talk._get_value(self.npc, self.value, self.valuetype);
    player:increaseSkill(self.name, value);
end;

function _skill_helper_sub(self, npcChar, player)
    local value = npc.base.talk._get_value(self.npc, self.value, self.valuetype);
    player:increaseSkill(self.name, -value);
end;
{'fraction_non_alphanumeric': 0.1437932289770659, 'fraction_numerical': 0.0, 'mean_word_length': 4.3671875, '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': '1053673', 'n_tokens_mistral': 963, 'n_tokens_neox': 969, 'n_words': 168}