<commit_before>--[[
Illarion Server

This program is free software: you can redistribute it and/or modify it under
the terms of the GNU Affero General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
details.

You should have received a copy of the GNU Affero General Public License along
with this program.  If not, see <http://www.gnu.org/licenses/>.
]]
-- analysis

local alchemy = require("alchemy.base.alchemy")
local licence = require("base.licence")
local common = require("base.common")
local redBottle = require("alchemy.item.id_59_red_bottle")
local granorsHut = require("content.granorsHut")

local M = {}

local chargeText = {}
chargeText[1] = {[Player.german] = " Der Stein droht zu zerbrechen. berall sind Sprnge im berzug und dem Stein zu sehen. Teilweise sind schon sachen rausgebrochen.", [Player.english] = " The gem might be ready to burst. There are cracks covering the whole film and gem. Some parts are already broken off."}
chargeText[2] = {[Player.german] = " Der berzug und der Stein sind vollkommen von Sprngen berzogen.", [Player.english] = " The film and the gem are completely covered in cracks."}
chargeText[3] = {[Player.german] = " Der berzug ist komplett von Sprngen bedeckt. Auch der Stein hat viele Risse.", [Player.english] = " The film is completely covered with cracks. The gem itself has also a lot of cracks"}
chargeText[4] = {[Player.german] = " Der berzug ist komplett von Sprngen bedeckt. Auch der Stein hat ein paar Risse.", [Player.english] = " The film is completely covered with cracks. The gem itself has also some cracks."}
chargeText[5] = {[Player.german] = " Der berzug ist komplett von Sprngen bedeckt. Auch der Stein selber scheint einen Riss zu haben.", [Player.english] = " The film is completely covered with cracks. The gem itself seems also to have one."}
chargeText[6] = {[Player.german] = " Der berzug hat sehr viele Sprnge.", [Player.english] = " The film has a lot of crack in it."}
chargeText[7] = {[Player.german] = " Ein paar Sprnge befinden sich im berzug." , [Player.english] = " The film has several cracks."}
chargeText[8] = {[Player.german] = " Ein kleiner Sprung befindet sich im berzug.", [Player.english] = " The film has a small crack."}
chargeText[9] = {[Player.german] = "", [Player.english] = ""}

local function CharacterAnalysis(User,theGem)

    if not alchemy.CheckIfAlchemist(User) then
        return
    end

    local targetCharacter = common.GetFrontCharacter(User)
    if not targetCharacter then
        User:inform("Du siehst nur unklare Formen, als du durch den Edelstein blickst.","Looking through the gem, you see only unclear forms.")
        return
    end

    User:talk(Character.say,"#me blickt durch einen Rubin auf die Person vor sich.","#me looks through a ruby at the person infront of " .. common.GetGenderText(User, "him", "her") .. ".")

    local analysisResult
    local foundAttributeEffect, attributeEffect = targetCharacter.effects:find(59)
    if not foundAttributeEffect then
        analysisResult = common.GetNLS(User, "Die Gestalt der Person scheint sich im Edelstein aufzulsen und du erkennst, dass sie scheinbar keinen Strkungstrank intus hat.", "The figure seems to dissolve within the ruby and you recognize that the person haven't drunk a strengthening potion")
    else
        analysisResult = common.GetNLS(User, "Die Gestalt der Person scheint sich im Edelstein aufzulsen und du erkennst, dass sie einen Strkungstrank intus hat:\n", "The figure seems to dissolve within the ruby and you recognize that the person has drunk a strengthening potion:\n")
        for i=1,#redBottle.attribList do
            local findAttribute, attributeChanger = attributeEffect:findValue(redBottle.attribList[i])
            if findAttribute and attributeChanger ~= 5 then
                local increaseOrDecrease
                if attributeChanger < 5 then
                    increaseOrDecrease = common.GetNLS(User, "gesenkte", "decreased")
                else
                    increaseOrDecrease = common.GetNLS(User, "gehobene", "increased")
                end
                analysisResult = analysisResult .. common.GetNLS(User, "\n" .. redBottle.intensityListDe[attributeChanger] .. " " .. increaseOrDecrease .. " " .. redBottle.attribListDe[i], "\n" .. redBottle.intensityListEn[attributeChanger] .. " " .. increaseOrDecrease .. " " .. redBottle.attribList[i])
            end
        end
    end

    local callback = function(dialog) end
    local dialog = MessageDialog(common.GetNLS(User, "Analyseergebnisse", "Results of the analysis"), analysisResult, callback)
    User:requestMessageDialog(dialog)

    local newCharge = tonumber(theGem:getData("analysingCharges")) - 1
    if newCharge < 1 then
        world:erase(theGem,1)
        User:inform("Der Rubin zerspringt in Einzelteile.","The ruby brusts into pieces.",Player.highPriority)
    else
        local descriptionDe = "Ein fester, gelblicher berzug bedeckt den Rubin." .. chargeText[newCharge][Player.german]
        local descriptionEn = "A hard, yellowish film covers the ruby." .. chargeText[newCharge][Player.english]
        if theGem.number == 1 then
            theGem:setData("descriptionDe",descriptionDe)
            theGem:setData("descriptionEn",descriptionEn)
            theGem:setData("analysingCharges",newCharge)
            world:changeItem(theGem)
        else
            world:erase(theGem, 1)
            common.CreateItem(User, 46, 1, 333, {descriptionDe = descriptionDe, descriptionEn = descriptionEn})
        end
        User:inform("Ein Sprung bildet sich im Edelstein.","A crack appears in the gem.",Player.highPriority)
    end
end

local function IsCharacterAnalysingGem(gem)
    if gem:getData("analysingCharges") ~= "" then
        return true
    end
    return false
end

local function StockAnalysis(User, gem, brew, ltstate)
    local analysisResultDE = "Substanz:\nKrutersud\n\nWirkstoffkonzentrationen:\n"
    local analysisResultEN = "Substanz:\nHerbal Stock\n\nActive substance concentrations:\n"
    for i=1,8 do -- loop to get the concentration of the eight active substances
        local wirkstoff = alchemy.wirkstoff
        local myCon = tonumber(brew:getData(""..wirkstoff[i].."Concentration"))
        if myCon == nil then
            myCon = 5
        end
        local conListDE = alchemy.wirkung_de
        local conListEN = alchemy.wirkung_en<commit_msg>Fix typo reported by player<commit_after>--[[
Illarion Server

This program is free software: you can redistribute it and/or modify it under
the terms of the GNU Affero General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
details.

You should have received a copy of the GNU Affero General Public License along
with this program.  If not, see <http://www.gnu.org/licenses/>.
]]
-- analysis

local alchemy = require("alchemy.base.alchemy")
local licence = require("base.licence")
local common = require("base.common")
local redBottle = require("alchemy.item.id_59_red_bottle")
local granorsHut = require("content.granorsHut")

local M = {}

local chargeText = {}
chargeText[1] = {[Player.german] = " Der Stein droht zu zerbrechen. berall sind Sprnge im berzug und dem Stein zu sehen. Teilweise sind schon sachen rausgebrochen.", [Player.english] = " The gem might be ready to burst. There are cracks covering the whole film and gem. Some parts are already broken off."}
chargeText[2] = {[Player.german] = " Der berzug und der Stein sind vollkommen von Sprngen berzogen.", [Player.english] = " The film and the gem are completely covered in cracks."}
chargeText[3] = {[Player.german] = " Der berzug ist komplett von Sprngen bedeckt. Auch der Stein hat viele Risse.", [Player.english] = " The film is completely covered with cracks. The gem itself has also a lot of cracks"}
chargeText[4] = {[Player.german] = " Der berzug ist komplett von Sprngen bedeckt. Auch der Stein hat ein paar Risse.", [Player.english] = " The film is completely covered with cracks. The gem itself has also some cracks."}
chargeText[5] = {[Player.german] = " Der berzug ist komplett von Sprngen bedeckt. Auch der Stein selber scheint einen Riss zu haben.", [Player.english] = " The film is completely covered with cracks. The gem itself seems also to have one."}
chargeText[6] = {[Player.german] = " Der berzug hat sehr viele Sprnge.", [Player.english] = " The film has a lot of crack in it."}
chargeText[7] = {[Player.german] = " Ein paar Sprnge befinden sich im berzug." , [Player.english] = " The film has several cracks."}
chargeText[8] = {[Player.german] = " Ein kleiner Sprung befindet sich im berzug.", [Player.english] = " The film has a small crack."}
chargeText[9] = {[Player.german] = "", [Player.english] = ""}

local function CharacterAnalysis(User,theGem)

    if not alchemy.CheckIfAlchemist(User) then
        return
    end

    local targetCharacter = common.GetFrontCharacter(User)
    if not targetCharacter then
        User:inform("Du siehst nur unklare Formen, als du durch den Edelstein blickst.","Looking through the gem, you see only unclear forms.")
        return
    end

    User:talk(Character.say,"#me blickt durch einen Rubin auf die Person vor sich.","#me looks through a ruby at the person infront of " .. common.GetGenderText(User, "him", "her") .. ".")

    local analysisResult
    local foundAttributeEffect, attributeEffect = targetCharacter.effects:find(59)
    if not foundAttributeEffect then
        analysisResult = common.GetNLS(User, "Die Gestalt der Person scheint sich im Edelstein aufzulsen und du erkennst, dass sie scheinbar keinen Strkungstrank intus hat.", "The figure seems to dissolve within the ruby and you recognize that the person haven't drunk a strengthening potion")
    else
        analysisResult = common.GetNLS(User, "Die Gestalt der Person scheint sich im Edelstein aufzulsen und du erkennst, dass sie einen Strkungstrank intus hat:\n", "The figure seems to dissolve within the ruby and you recognize that the person has drunk a strengthening potion:\n")
        for i=1,#redBottle.attribList do
            local findAttribute, attributeChanger = attributeEffect:findValue(redBottle.attribList[i])
            if findAttribute and attributeChanger ~= 5 then
                local increaseOrDecrease
                if attributeChanger < 5 then
                    increaseOrDecrease = common.GetNLS(User, "gesenkte", "decreased")
                else
                    increaseOrDecrease = common.GetNLS(User, "gehobene", "increased")
                end
                analysisResult = analysisResult .. common.GetNLS(User, "\n" .. redBottle.intensityListDe[attributeChanger] .. " " .. increaseOrDecrease .. " " .. redBottle.attribListDe[i], "\n" .. redBottle.intensityListEn[attributeChanger] .. " " .. increaseOrDecrease .. " " .. redBottle.attribList[i])
            end
        end
    end

    local callback = function(dialog) end
    local dialog = MessageDialog(common.GetNLS(User, "Analyseergebnisse", "Results of the analysis"), analysisResult, callback)
    User:requestMessageDialog(dialog)

    local newCharge = tonumber(theGem:getData("analysingCharges")) - 1
    if newCharge < 1 then
        world:erase(theGem,1)
        User:inform("Der Rubin zerspringt in Einzelteile.","The ruby brusts into pieces.",Player.highPriority)
    else
        local descriptionDe = "Ein fester, gelblicher berzug bedeckt den Rubin." .. chargeText[newCharge][Player.german]
        local descriptionEn = "A hard, yellowish film covers the ruby." .. chargeText[newCharge][Player.english]
        if theGem.number == 1 then
            theGem:setData("descriptionDe",descriptionDe)
            theGem:setData("descriptionEn",descriptionEn)
            theGem:setData("analysingCharges",newCharge)
            world:changeItem(theGem)
        else
            world:erase(theGem, 1)
            common.CreateItem(User, 46, 1, 333, {descriptionDe = descriptionDe, descriptionEn = descriptionEn})
        end
        User:inform("Ein Sprung bildet sich im Edelstein.","A crack appears in the gem.",Player.highPriority)
    end
end

local function IsCharacterAnalysingGem(gem)
    if gem:getData("analysingCharges") ~= "" then
        return true
    end
    return false
end

local function StockAnalysis(User, gem, brew, ltstate)
    local analysisResultDE = "Substanz:\nKrutersud\n\nWirkstoffkonzentrationen:\n"
    local analysisResultEN = "Substance:\nHerbal Stock\n\nActive substance concentrations:\n"
    for i=1,8 do -- loop to get the concentration of the eight active substances
        local wirkstoff = alchemy.wirkstoff
        local myCon = tonumber(brew:getData(""..wirkstoff[i].."Concentration"))
        if myCon == nil then
            myCon = 5
        end
        local conListDE = alchemy.wirkung_de
        local conListEN = alchemy.wirkung_en
{'fraction_non_alphanumeric': 0.09199851135094901, 'fraction_numerical': 0.004614812058057313, 'mean_word_length': 3.553032870213487, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2194690', 'n_tokens_mistral': 4047, 'n_tokens_neox': 3922, 'n_words': 1363}