<commit_before>--ds_059_rote_flasche
--Druidensystem in Arbeit
--Falk
--Delay added by Blay09
--rework by Merung

require("base.common")
require("alchemy.base.alchemy")

module("alchemy.item.id_59_red_bottle",package.seeall)

-- UPDATE common SET com_script='alchemy.item.id_59_red_bottle' WHERE com_itemid = 59;

taste = {}
attribList   ={"strength","intelligence","dexterity"       ,"perception"  ,"constitution","essence","agility"      ,"willpower"}
attribListDe ={"Strke"  ,"Intelligenz" ,"Geschicklichkeit","Wahrnehmung" ,"Ausdauer"    ,"Essenz" ,"Schnelligkeit","Willenskraft"}
taste[0]     ={"fruchtig","herb"        ,"bitter"          ,"faulig"      ,"sauer"       ,"salzig" ,"scharf"       ,"s"}
taste[1]     ={"fruity"  ,"tartly"      ,"bitter"          ,"putrefactive","acidly"      ,"salt"   ,"hot"          ,"sweet"}

intensityListDe = {"stark"   ,"merkbar"  ,"leicht"  ,"kaum merklich"   ,"","kaum merklich"   ,"leicht"  ,"merkbar"  ,"stark"}
intensityListEn = {"strongly","noticably","slightly","barely noticably","","barely noticable","slightly","noticably","strongly"}

function DrinkPotion(User,SourceItem)
    User:inform(SourceItem:getData("potionEffectId"))
	local potionEffectId = tonumber(SourceItem:getData("potionEffectId"))
	User:inform(""..potionEffectId)
	if potionEffectId == 0 or potionEffectId == nil  then -- no effect	
	    base.common.InformNLS(User, "Du hast nicht das Gefhl, dass etwas passiert.", 
		"You don't have the feeling that something happens.")
	    return
	
	elseif potionEffectId >= 11111111 and potionEffectId <= 99999999 then -- it's an attribute changer  
		  -- there is already an effect, we remove it
		local foundEffect, myEffect = User.effects:find(59);
		if foundEffect then
			local effectRemoved = User.effects:removeEffect(59)
		    base.common.InformNLS(User, "Du sprst, dass der alte Strkungstrank seine Wirkung verliert und wie der neue zu wirken einsetzt.", 
		    "You feel that the old strengthening potion looses its effect and how the new one takes effect.")
		end
		local myEffectDuration = SourceItem.quality*600*4 -- quality 1 = 4 minutes duration, quality 9 = 36 minutes duration
		local myEffect=LongTimeEffect(59,myEffectDuration) -- new effect
		
		local dataZList = alchemy.base.alchemy.SplitData(User,potionEffectId)
		alchemy.base.alchemy.generateTasteMessage(User,dataZList) -- potion taste
	    GenerateEffectMessage(User,dataZList) -- inform about the effects
		
		local attribValue, bottomBorder
		for i=1,8 do
			
			attribValue = User:increaseAttrib(attribList[i],0);

			bottomBorder = 1
			
			if (attribValue + dataZList[i] - 5) < bottomBorder then
				dataZList[i] = (bottomBorder - attribValue) + 5;
			end

			if dataZList[i] ~= 5 then
				User:increaseAttrib(attribList[i],dataZList[i]-5);
				myEffect:addValue(""..attribList[i],dataZList[i]);
			end
			
		end
		
		local foundEffect, checkedEffect = User.effects:find(59) -- security check, there shouldn't be an effect at this point anymore
		if not foundEffect then
		   User.effects:addEffect( myEffect )
		end
    else
	    -- something else
	end	
end

function GenerateEffectMessage(User,dataZList)
    local effectMessagesDe = ""
    local effectMessagesEn = ""
	local anyEffect = false
	
	local attribEn, attribDe, nPTagEn, nPTagDe, attribIntensityEn, attribIntensityDe
	for i=1,8 do
	    if dataZList[i] ~= 5 then
		    
			attribEn = attribList[i] -- attribute
			attribDe = attribListDe[i]
			if dataZList[i] > 5 then
			    nPTagEn = "in" -- increasing 
				nPTagDe = "zu"
			else
                nPTagEn = "de" -- decreasing
                nPTagDe = "ab"				
		    end
	        attribIntensityEn = intensityListEn[dataZList[i]] -- how strong it is in/decreased
			attribIntensityDe = intensityListDe[dataZList[i]]
            anyEffect = true
			-- we put everything together
			effectMessagesDe = effectMessagesDe.."Deine "..attribDe.." nimmt".." "..attribIntensityDe.." "..nPTagDe..". "
			effectMessagesEn = effectMessagesEn.."Your "..attribEn..nPTagEn.."creases "..attribIntensityEn..". "
		end
    end		
    if anyEffect == false then -- no effect
	    base.common.InformNLS(User,"Du sprst keine Wirkung.","You don't feel any effect.")
	else
	    base.common.InformNLS(User,effectMessagesDe,effectMessagesEn)
    end
end

function UseItem(User,SourceItem,TargetItem,Counter,Param,ltstate)
 User:inform(SourceItem:getData("filledWith"));  
	if not ((SourceItem:getData("filledWith")=="potion") or (SourceItem:getData("filledWith") =="essenceBrew")) then
		return -- no potion, no essencebrew, something else
	end
	
	local cauldron = alchemy.base.alchemy.GetCauldronInfront(User)
	if cauldron then -- infront of a cauldron?
	    alchemy.base.alchemy.FillIntoCauldron(User,SourceItem,cauldron,Counter,Param,ltstate)
	
	else -- not infront of a cauldron, therefore drink!
        if User.attackmode then
		   base.common.InformNLS(User, "Du kannst das Gebru nicht nutzen, whrend du kmpfst.", "You cannot use the potion while fighting.")
		else
			User:talkLanguage(Character.say, Player.german, "#me trinkt eine rote Flssigkeit.");
			User:talkLanguage(Character.say, Player.english, "#me drinks a red liquid.");
			User.movepoints=User.movepoints - 20
			DrinkPotion(User,SourceItem) -- call effect
			alchemy.base.alchemy.EmptyBottle(User,SourceItem)
	    end
	end  
end

function LookAtItem(User,Item)
    world:itemInform(User, Item, base.lookat.GenerateLookAt(User, Item, 0))
end<commit_msg>remove debug infos<commit_after>--ds_059_rote_flasche
--Druidensystem in Arbeit
--Falk
--Delay added by Blay09
--rework by Merung

require("base.common")
require("alchemy.base.alchemy")

module("alchemy.item.id_59_red_bottle",package.seeall)

-- UPDATE common SET com_script='alchemy.item.id_59_red_bottle' WHERE com_itemid = 59;

taste = {}
attribList   ={"strength","intelligence","dexterity"       ,"perception"  ,"constitution","essence","agility"      ,"willpower"}
attribListDe ={"Strke"  ,"Intelligenz" ,"Geschicklichkeit","Wahrnehmung" ,"Ausdauer"    ,"Essenz" ,"Schnelligkeit","Willenskraft"}
taste[0]     ={"fruchtig","herb"        ,"bitter"          ,"faulig"      ,"sauer"       ,"salzig" ,"scharf"       ,"s"}
taste[1]     ={"fruity"  ,"tartly"      ,"bitter"          ,"putrefactive","acidly"      ,"salt"   ,"hot"          ,"sweet"}

intensityListDe = {"stark"   ,"merkbar"  ,"leicht"  ,"kaum merklich"   ,"","kaum merklich"   ,"leicht"  ,"merkbar"  ,"stark"}
intensityListEn = {"strongly","noticably","slightly","barely noticably","","barely noticable","slightly","noticably","strongly"}

function DrinkPotion(User,SourceItem)
    local potionEffectId = tonumber(SourceItem:getData("potionEffectId"))
	
	if potionEffectId == 0 or potionEffectId == nil  then -- no effect	
	    base.common.InformNLS(User, "Du hast nicht das Gefhl, dass etwas passiert.", 
		"You don't have the feeling that something happens.")
	    return
	
	elseif potionEffectId >= 11111111 and potionEffectId <= 99999999 then -- it's an attribute changer  
		  -- there is already an effect, we remove it
		local foundEffect, myEffect = User.effects:find(59);
		if foundEffect then
			local effectRemoved = User.effects:removeEffect(59)
		    base.common.InformNLS(User, "Du sprst, dass der alte Strkungstrank seine Wirkung verliert und wie der neue zu wirken einsetzt.", 
		    "You feel that the old strengthening potion looses its effect and how the new one takes effect.")
		end
		local myEffectDuration = SourceItem.quality*600*4 -- quality 1 = 4 minutes duration, quality 9 = 36 minutes duration
		local myEffect=LongTimeEffect(59,myEffectDuration) -- new effect
		
		local dataZList = alchemy.base.alchemy.SplitData(User,potionEffectId)
		alchemy.base.alchemy.generateTasteMessage(User,dataZList) -- potion taste
	    GenerateEffectMessage(User,dataZList) -- inform about the effects
		
		local attribValue, bottomBorder
		for i=1,8 do
			
			attribValue = User:increaseAttrib(attribList[i],0);

			bottomBorder = 1
			
			if (attribValue + dataZList[i] - 5) < bottomBorder then
				dataZList[i] = (bottomBorder - attribValue) + 5;
			end

			if dataZList[i] ~= 5 then
				User:increaseAttrib(attribList[i],dataZList[i]-5);
				myEffect:addValue(""..attribList[i],dataZList[i]);
			end
			
		end
		
		local foundEffect, checkedEffect = User.effects:find(59) -- security check, there shouldn't be an effect at this point anymore
		if not foundEffect then
		   User.effects:addEffect( myEffect )
		end
    else
	    -- something else
	end	
end

function GenerateEffectMessage(User,dataZList)
    local effectMessagesDe = ""
    local effectMessagesEn = ""
	local anyEffect = false
	
	local attribEn, attribDe, nPTagEn, nPTagDe, attribIntensityEn, attribIntensityDe
	for i=1,8 do
	    if dataZList[i] ~= 5 then
		    
			attribEn = attribList[i] -- attribute
			attribDe = attribListDe[i]
			if dataZList[i] > 5 then
			    nPTagEn = "in" -- increasing 
				nPTagDe = "zu"
			else
                nPTagEn = "de" -- decreasing
                nPTagDe = "ab"				
		    end
	        attribIntensityEn = intensityListEn[dataZList[i]] -- how strong it is in/decreased
			attribIntensityDe = intensityListDe[dataZList[i]]
            anyEffect = true
			-- we put everything together
			effectMessagesDe = effectMessagesDe.."Deine "..attribDe.." nimmt".." "..attribIntensityDe.." "..nPTagDe..". "
			effectMessagesEn = effectMessagesEn.."Your "..attribEn..nPTagEn.."creases "..attribIntensityEn..". "
		end
    end		
    if anyEffect == false then -- no effect
	    base.common.InformNLS(User,"Du sprst keine Wirkung.","You don't feel any effect.")
	else
	    base.common.InformNLS(User,effectMessagesDe,effectMessagesEn)
    end
end

function UseItem(User,SourceItem,TargetItem,Counter,Param,ltstate)
    if not ((SourceItem:getData("filledWith")=="potion") or (SourceItem:getData("filledWith") =="essenceBrew")) then
		return -- no potion, no essencebrew, something else
	end
	
	local cauldron = alchemy.base.alchemy.GetCauldronInfront(User)
	if cauldron then -- infront of a cauldron?
	    alchemy.base.alchemy.FillIntoCauldron(User,SourceItem,cauldron,Counter,Param,ltstate)
	
	else -- not infront of a cauldron, therefore drink!
        if User.attackmode then
		   base.common.InformNLS(User, "Du kannst das Gebru nicht nutzen, whrend du kmpfst.", "You cannot use the potion while fighting.")
		else
			User:talkLanguage(Character.say, Player.german, "#me trinkt eine rote Flssigkeit.");
			User:talkLanguage(Character.say, Player.english, "#me drinks a red liquid.");
			User.movepoints=User.movepoints - 20
			DrinkPotion(User,SourceItem) -- call effect
			alchemy.base.alchemy.EmptyBottle(User,SourceItem)
	    end
	end  
end

function LookAtItem(User,Item)
    world:itemInform(User, Item, base.lookat.GenerateLookAt(User, Item, 0))
end
{'fraction_non_alphanumeric': 0.1211053412462908, 'fraction_numerical': 0.011498516320474777, 'mean_word_length': 3.8668772563176894, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, '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': '5386239', 'n_tokens_mistral': 3986, 'n_tokens_neox': 3550, 'n_words': 852}