<commit_before>
-- This module holds the core functions for the explorers guild.
-- The questIDs start at 130 and go to 150.
-- Written by Martin
require("base.common")

module("quest.explorersguild", package.seeall)

function CheckStone(Char,StoneNumber)
    retVal=false;
    StoneBase=130+math.floor((StoneNumber-1)/32);  -- Stone 0 to 31 -> 0, 32-.. ->2 etc.
    StoneBaseOffset=math.mod(StoneNumber-1,32);  -- StoneNr inside range
    HasStones=Char:getQuestProgress(StoneBase);
    GotStone=LuaAnd(2^(StoneNumber),HasStones);
    if GotStone>0 then
        retVal=true;
    end
    return retVal;
end

function CountStones(Char)
    nrStones=0;
    StoneBase=130;
    StoneEnd=149;
    for i=StoneBase,StoneEnd do
        stones=Char:getQuestProgress(i);
        while stones~=0 do
            nrStones=nrStones+math.mod(stones,2);
            stones=math.floor(stones/2);
        end
    end
    return nrStones
end

function WriteStone(Char,StoneNumber)
    StoneBase=130+math.floor(StoneNumber/32);  -- Stone 0 to 31 -> 0, 32-.. ->2 etc.
    StoneBaseOffset=math.mod(StoneNumber,32);  -- StoneNr inside range
    --Char:inform("Base offset: " .. StoneBase .. " Stone Nr "..StoneBaseOffset .. " for stone "..StoneNumber);
    currentStones=Char:getQuestProgress(StoneBase);
    Char:setQuestProgress(StoneBase,LuaOr(2^StoneBaseOffset,currentStones));
end

-- reward[x] = {y,z} - x = stones to have collected, y = item id , z= amount of y
reward = {}
reward[1] = {{3077, 2}}; -- 2 silver coins (3077)
reward[5] = {{3077, 10},{49,1},{841,1},{463,1},{27,1}}; -- items worth 10 silver coins
reward[10] = {{3077, 20},{455, 10},{21,20},{325,1},{230,1}} -- items worth 20 silver coins
reward[20] = {{3077, 30},{322,50},{1,1},{9,1},{2922,1}} -- items worth 30 silver coins
reward[50] = {{3077, 60},{1062, 6},{353,3},{811,1},{297,1}} -- items worth 60 silver coins
reward[100] = {{61, 1},{2390,1},{2647,5},{557,4},{2675,1}} -- items worth 1 gold coin
reward[200] = {{61,2},{2369,1},{164,30},{2718,1},{547,1}} -- items worth 2 gold coins
reward[350] = {{61,3},{193,1},{2685,1},{559,7},{2360,1}} -- items worth 3 gold coins
reward[500] = {{61,5},{2551,10},{2552,10},{2553,10},{2554,10}} -- items worth 5 gold coins
reward[750] = {{61,8},{2367,1},{2693,1},{2662,1},{559,10}} -- items worth 8 gold coins

function getReward(Char)
	local nrStones = CountStones(Char)
	if reward[nrStones] ~= nil then
		if table.getn(reward[nrStones]) == 1 then
			Char:createItem(reward[nrStones][1][1],reward[nrStones][1][2],333,nil);
			Char:inform("Du hast 2 Silberstücke erhalten, da du den ersten Markierungsstein entdeckt hast. Weiter so!", "You received 2 silver coins for discovering the first marker stone. Keep it up!");
		else
			rewardDialog(Char, nrStones)
		end
	end
end

function rewardDialog(Char, nrStones)
	local title = base.common.GetNLS(Char,"Entdeckergilde Belohnung","Explorerguild reward")
	local text = base.common.GetNLS(Char,"Du hast "..nrStones.." Markierungssteine entdeckt, daher kannst du dir nun eine Belohnung aussuchen.", "You discovered "..nrStones.." marker stones, therefor you can pick a reward.")
	
	local callback = function(dialog) 
		local success = dialog:getSuccess() 
		if success then
			selected = dialog:getSelectedIndex() 
			Char:createItem(reward[nrStones][selected][1],reward[nrStones][selected][2], 800, nil);	
		end
	end

	local dialog = SelectionDialog(title, text, callback);
	
	local itemName;
	local language = Char:getPlayerLanguage();
	for i=1, #(table.getn(reward[nrStones])) do
		itemName = world:getItemName(reward[nrStones][i][1],language);
		dialog:addOption(reward[nrStones][i][1], reward[nrStones][i][2].." "..itemName);
	end

	User:requestSelectionDialog(dialog);
end<commit_msg>encoding changed<commit_after>
-- This module holds the core functions for the explorers guild.
-- The questIDs start at 130 and go to 150.
-- Written by Martin
require("base.common")

module("quest.explorersguild", package.seeall)

function CheckStone(Char,StoneNumber)
    retVal=false;
    StoneBase=130+math.floor((StoneNumber-1)/32);  -- Stone 0 to 31 -> 0, 32-.. ->2 etc.
    StoneBaseOffset=math.mod(StoneNumber-1,32);  -- StoneNr inside range
    HasStones=Char:getQuestProgress(StoneBase);
    GotStone=LuaAnd(2^(StoneNumber),HasStones);
    if GotStone>0 then
        retVal=true;
    end
    return retVal;
end

function CountStones(Char)
    nrStones=0;
    StoneBase=130;
    StoneEnd=149;
    for i=StoneBase,StoneEnd do
        stones=Char:getQuestProgress(i);
        while stones~=0 do
            nrStones=nrStones+math.mod(stones,2);
            stones=math.floor(stones/2);
        end
    end
    return nrStones
end

function WriteStone(Char,StoneNumber)
    StoneBase=130+math.floor(StoneNumber/32);  -- Stone 0 to 31 -> 0, 32-.. ->2 etc.
    StoneBaseOffset=math.mod(StoneNumber,32);  -- StoneNr inside range
    --Char:inform("Base offset: " .. StoneBase .. " Stone Nr "..StoneBaseOffset .. " for stone "..StoneNumber);
    currentStones=Char:getQuestProgress(StoneBase);
    Char:setQuestProgress(StoneBase,LuaOr(2^StoneBaseOffset,currentStones));
end

-- reward[x] = {y,z} - x = stones to have collected, y = item id , z= amount of y
reward = {}
reward[1] = {{3077, 2}}; -- 2 silver coins (3077)
reward[5] = {{3077, 10},{49,1},{841,1},{463,1},{27,1}}; -- items worth 10 silver coins
reward[10] = {{3077, 20},{455, 10},{21,20},{325,1},{230,1}} -- items worth 20 silver coins
reward[20] = {{3077, 30},{322,50},{1,1},{9,1},{2922,1}} -- items worth 30 silver coins
reward[50] = {{3077, 60},{1062, 6},{353,3},{811,1},{297,1}} -- items worth 60 silver coins
reward[100] = {{61, 1},{2390,1},{2647,5},{557,4},{2675,1}} -- items worth 1 gold coin
reward[200] = {{61,2},{2369,1},{164,30},{2718,1},{547,1}} -- items worth 2 gold coins
reward[350] = {{61,3},{193,1},{2685,1},{559,7},{2360,1}} -- items worth 3 gold coins
reward[500] = {{61,5},{2551,10},{2552,10},{2553,10},{2554,10}} -- items worth 5 gold coins
reward[750] = {{61,8},{2367,1},{2693,1},{2662,1},{559,10}} -- items worth 8 gold coins

function getReward(Char)
	local nrStones = CountStones(Char)
	if reward[nrStones] ~= nil then
		if table.getn(reward[nrStones]) == 1 then
			Char:createItem(reward[nrStones][1][1],reward[nrStones][1][2],333,nil);
			Char:inform("Du hast 2 Silberstcke erhalten, da du den ersten Markierungsstein entdeckt hast. Weiter so!", "You received 2 silver coins for discovering the first marker stone. Keep it up!");
		else
			rewardDialog(Char, nrStones)
		end
	end
end

function rewardDialog(Char, nrStones)
	local title = base.common.GetNLS(Char,"Entdeckergilde Belohnung","Explorerguild reward")
	local text = base.common.GetNLS(Char,"Du hast "..nrStones.." Markierungssteine entdeckt, daher kannst du dir nun eine Belohnung aussuchen.", "You discovered "..nrStones.." marker stones, therefor you can pick a reward.")
	
	local callback = function(dialog) 
		local success = dialog:getSuccess() 
		if success then
			selected = dialog:getSelectedIndex() 
			Char:createItem(reward[nrStones][selected][1],reward[nrStones][selected][2], 800, nil);	
		end
	end

	local dialog = SelectionDialog(title, text, callback);
	
	local itemName;
	local language = Char:getPlayerLanguage();
	for i=1, #(table.getn(reward[nrStones])) do
		itemName = world:getItemName(reward[nrStones][i][1],language);
		dialog:addOption(reward[nrStones][i][1], reward[nrStones][i][2].." "..itemName);
	end

	User:requestSelectionDialog(dialog);
end
{'fraction_non_alphanumeric': 0.16644295302013423, 'fraction_numerical': 0.08456375838926175, 'mean_word_length': 4.6446969696969695, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '4193536', 'n_tokens_mistral': 3047, 'n_tokens_neox': 2602, 'n_words': 620}