<commit_before>require("base.class")
require("base.factions")
require("npc.base.condition.condition")

module("npc.base.condition.rank", package.seeall)

rank = base.class.class(npc.base.condition.condition.condition,
function(self, comp, value)
    npc.base.condition.condition.condition:init(self);
    self["value"], self["valuetype"] = npc.base.talk._set_value(value);
    if (comp == ">=" or comp == "=>") then
        self["check"] = _rank_helper_greaterequal;
    elseif (comp == ">") then
        self["check"] = _rank_helper_greater;
    elseif (comp == "<") then
        self["check"] = _rank_helper_lesser;
    else
        -- unkonwn comparator
    end;
end);

function _rank_helper_greaterequal(self, npcChar, texttype, player)
    local value = npc.base.talk._get_value(self.npc, self.value, self.valuetype);
    return base.factions.getRankAsNumber(player) >= value;
end;

function _rank_helper_greater(self, npcChar, texttype, player)
    local value = npc.base.talk._get_value(self.npc, self.value, self.valuetype);
    return base.factions.getRankAsNumber(player) > value;
end;

function _rank_helper_lesser(self, npcChar, texttype, player)
    local value = npc.base.talk._get_value(self.npc, self.value, self.valuetype);
    return base.factions.getRankAsNumber(player) < value;
end;<commit_msg>Implement all comparison operators for rank condition<commit_after>require("base.class")
require("base.factions")
require("npc.base.condition.condition")

module("npc.base.condition.rank", package.seeall)

rank = base.class.class(npc.base.condition.condition.condition,
function(self, comp, value)
    npc.base.condition.condition.condition:init(self);
    self["value"], self["valuetype"] = npc.base.talk._set_value(value);
    
    if (comp == "=") then
        self["check"] = _rank_helper_equal;
    elseif (comp == "<>" or comp == "!=" or comp == "~=") then
        self["check"] = _rank_helper_notequal;
    elseif (comp == "<=" or comp == "=<") then
        self["check"] = _rank_helper_lesserequal;
    elseif (comp == ">=" or comp == "=>") then
        self["check"] = _rank_helper_greaterequal;
    elseif (comp == ">") then
        self["check"] = _rank_helper_greater;
    elseif (comp == "<") then
        self["check"] = _rank_helper_lesser;
    else
        -- unkonwn comparator
    end;
end);

function _rank_helper_equal(self, npcChar, texttype, player)
    local value = npc.base.talk._get_value(self.npc, self.value, self.valuetype);
    return base.factions.getRankAsNumber(player) == value;
end;

function _rank_helper_notequal(self, npcChar, texttype, player)
    local value = npc.base.talk._get_value(self.npc, self.value, self.valuetype);
    return base.factions.getRankAsNumber(player) ~= value;
end;

function _rank_helper_lesserequal(self, npcChar, texttype, player)
    local value = npc.base.talk._get_value(self.npc, self.value, self.valuetype);
    return base.factions.getRankAsNumber(player) <= value;
end;

function _rank_helper_greaterequal(self, npcChar, texttype, player)
    local value = npc.base.talk._get_value(self.npc, self.value, self.valuetype);
    return base.factions.getRankAsNumber(player) >= value;
end;

function _rank_helper_greater(self, npcChar, texttype, player)
    local value = npc.base.talk._get_value(self.npc, self.value, self.valuetype);
    return base.factions.getRankAsNumber(player) > value;
end;

function _rank_helper_lesser(self, npcChar, texttype, player)
    local value = npc.base.talk._get_value(self.npc, self.value, self.valuetype);
    return base.factions.getRankAsNumber(player) < value;
end;
{'fraction_non_alphanumeric': 0.1432153803287824, 'fraction_numerical': 0.0, 'mean_word_length': 4.514592933947773, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 14, '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': '2257576', 'n_tokens_mistral': 1231, 'n_tokens_neox': 1220, 'n_words': 224}