----------------------------------------------------------------------
 * This file is part of Freedroid
 *
 * Freedroid is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Freedroid 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Freedroid; see the file COPYING. If not, write to the 
 * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
 * MA 02111-1307 USA
----------------------------------------------------------------------


If you have questions concerning FreedroidRPG, please send an email to:

freedroid-discussion@lists.sourceforge.net


Beginning of new chat dialog for character="XXXXX"
----------------------------------------------------------------------

<FirstTime LuaCode>
	show(0, 3)
</LuaCode>

<EveryTime LuaCode>
	if (has_cookie("Tania-at-Bar")) and
	   (not has_cookie("Tania-at-Bar_Ewald")) then
		add_cookie("Tania-at-Bar_Ewald")
		npc_says(_"Your lady friend just told me the epic story of how you rescued her.")
		npc_says(_"That was really something.")
		npc_says(_"I'd give you a drink on the house, but unfortunately I'm still out.")
	end

	if has_cookie("drank_all_ewald_had") then show(14) end

	if has_cookie("ewald_gambling") then show(30) end

	show(99)
</LuaCode>
----------------------------------------------------------------------

Nr=0 Text=_"Hi. You look really happy."
<LuaCode>
	npc_says(_"Hey! I'm Ewald. I'm a bartender.")
	npc_says(_"I used to do a lot of drugs, and I destroyed my brain.")
	npc_says(_"I'm not too smart now, but I'm very happy all the time!")
	npc_says(_"Want something to drink?")
	set_bot_name(_"Ewald -- Barkeeper")
	hide(0) show(1, 2, 13)
</LuaCode>
----------------------------------------------------------------------

Nr=1 Text=_"How is your business doing?"
<LuaCode>
	if (has_cookie("guard_follow_tux")) then
		npc_says(_"Can't complain at the moment...")
	else
		npc_says(_"Nah, No darn good at all.")
		npc_says(_"The bots ruined it for me. Now the supplies are very low and I had to make the prices high.")
		npc_says(_"No one wants to pay 499 circs for bottom shelf swill that even Bender would not drink...")
		npc_says(_"The tax is quite brutal as well. And the Red Guard always demands discounts too.")
		npc_says(_"Life is tough. I am still happy though.")
		hide(1)
	end
</LuaCode>
----------------------------------------------------------------------

Nr=2 Text=_"Are you selling something other than drinks?"
<LuaCode>
	npc_says(_"Yeah, I have some junk here... Want to see?")
	trade_with("Ewald")
</LuaCode>
----------------------------------------------------------------------

Nr=3 Text=_"I could use a drink. What is there to be had?"
<LuaCode>
	npc_says(_"Well... We are a bit short on supplies right now... Erm... AH! I know!")
	npc_says(_"I have WATER!")
	if (has_item_backpack("Mug") == 0) and
	   (has_item_backpack("Cup") == 0) then
		npc_says(_"But you'll need a mug or a cup for me to put it in.")
	else
		hide(3) show(4, 5, 6)
	end
</LuaCode>
----------------------------------------------------------------------

Nr=4 Text=_"I want double water on the rocks. Stirred, not shaken."
<LuaCode>
	npc_says(_"Here you go. That one is on the house. And if the water is not enough, just ask me for more.")
	heat_tux(-20)
	hide(4, 5, 6) show(9)
</LuaCode>
----------------------------------------------------------------------

Nr=5 Text=_"Long Island iced water please."
<LuaCode>
	npc_says(_"Here you go.")
	heat_tux(-30)
	hide(4, 5, 6) show(8)
</LuaCode>
----------------------------------------------------------------------

Nr=6 Text=_"I want something cheap... Give me some fortified water."
<LuaCode>
	npc_says(_"Eh... Sure, as you wish. Here you go.")
	heat_tux(-50)
	hide(4, 5, 6) show(7)
</LuaCode>
----------------------------------------------------------------------

Nr=7 Text=_"Ugh... Ahh... I like it. Give me some more of that."
<LuaCode>
	npc_says(_"Uh... Sure...")
	heat_tux(-1000);
	hide(7) show(10)
</LuaCode>
----------------------------------------------------------------------

Nr=8 Text=_"Ahh... Fresh water! Give me some more of that."
<LuaCode>
	npc_says(_"Yeah, I thought you would like it. Here is more.")
	heat_tux(-1000);
	hide(8) show(10)
</LuaCode>
----------------------------------------------------------------------

Nr=9 Text=_"Hmm... Lots of ice. Give me one more double water, but now without any ice."
<LuaCode>
	npc_says(_"One double water coming up.")
	heat_tux(-1000);
	hide(9) show(10)
</LuaCode>
----------------------------------------------------------------------

Nr=10 Text=_"MORE! I want more water!"
<LuaCode>
	npc_says(_"Erm... Ok... Here, have some of my special, water colada.")
	heat_tux(-1000);
	hide(10) show(11)
</LuaCode>
----------------------------------------------------------------------

Nr=11 Text=_"I am really thirsty! I want water."
<LuaCode>
	npc_says(_"Well, you drank all my water, so you cannot have any more. There is none left.")
	npc_says(_"I heard Linarians can drink a lot of water, but seven liters...")
	hide(11) show(12)
</LuaCode>
----------------------------------------------------------------------

Nr=12 Text=_"MORE! MORE! MORE! I WANT MORE WATER. NOW!"
<LuaCode>
	npc_says(_"Eh... I think you've had enough... Maybe you should just go for a walk for now?")
	npc_says(_"You have had everything that I had.")
	add_cookie("drank_all_ewald_had")
	hide(12)
</LuaCode>
----------------------------------------------------------------------

Nr=13 Text=_"Any idea where I can find some entertainment here?"
<LuaCode>
	if (has_cookie("tux_has_joined_guard")) then
		npc_says(_"I thought that shooting bots with those big guns was fun...?")
		npc_says(_"*sigh*")
		npc_says(_"I wish I could once use such a gun.")
		npc_says(_"You are a Guard member, right?")
		if ((has_item("Barrett M82 Sniper Rifle") > 0) or
		   (has_item("Exterminator") > 0)) then
			tux_says(_"Yes, I am a Guard member. No, it is not allowed to give guns to people who are high.")
			npc_says(_"Pleeeeaaaase.")
			tux_says(_"No exceptions. I apologize. Please think responsibly; there is a good reason for this rule.")
			npc_says(_"Hmm. You're right, I better ask again later.")
			npc_says(_"Well, since you won't let me play with your big guns, we could always try a gambling game or two.")	
		else
			tux_says(_"The fact that I am a Red Guard member does not necessarily mean that I have a big gun with me.")
			npc_says(_"Really?")
			npc_says(_"Stop kidding me. I know you have big a gun somewhere.")
			npc_says(_"Every Guard has one.")
			tux_says(_"Look at me! Do you see any gun here at my belt or in my hands?")
			npc_says(_"Hmm... You are right. No gun, indeed.")
			npc_says(_"Sorry.")
			npc_says(_"Since there are no big guns to shoot, how about shooting some dice? Would you like to gamble?")
		end
	else
		npc_says(_"Well... Erm... No.")
		npc_says(_"What the bots did not smash, the Red Guard taxed.")
		npc_says(_"Fun is kinda dead right now.")
		npc_says(_"Well, unless you are in the Red Guard itself, of course. They have those big guns that can destroy a dozen bots with one shot...")
		npc_says(_"Now THAT'S fun, if you ask me.")
		npc_says(_"If you are really bored, you can try gambling with me.")
	end
	hide(13) show(30)
</LuaCode>
----------------------------------------------------------------------

Nr=14 Text=_"Hey, I could use a refreshing drink!"
<LuaCode>
	npc_says(_"Here, have a Watery Mary.")
	heat_tux(-1000)
	hide(14)
</LuaCode>
-----------------------------------------------------------------------

Nr=30 Text=_"Sure, I'll gamble with you. What do you play?"
<LuaCode>
	if (not has_cookie("ewald_gambling")) then add_cookie("ewald_gambling") end
	npc_says(_"I play a dice game and a coin-flipping game.")
	-- Initialize some variables here
	bet = 0
	tux1, tux2, tux3 = 0, 0, 0
	ewd1, ewd2, ewd3 = 0, 0, 0, 0, 0 
	-- Ewald forces you to gamble semi-responsibly ;-)
	max = get_gold() * 0.8
	if (max > 30) then show(33)
		if (max > 300) then show(34)
		if (max > 600) then show(35)
	end end else
	npc_says(_"You should come back when you have more to gamble with.")
	end
	hide(30) show(31, 32)
</LuaCode>
-----------------------------------------------------------------------

Nr=31 Text=_"Tell me the rules for your 'dice game'."
<LuaCode>
	npc_says(_"It is simple. We both get three six sided dice.")
	npc_says(_"You bet. Then you throw one die.")
	npc_says(_"Then you decide on a betting multiplier, up to 3x.")
	npc_says(_"Then you throw two dice and I throw three dice. If sum of your three dice are better than my three dice, you win twice your bet, minus a tax for the Red Guard.")
	npc_says(_"Remember: the odds are slightly against you, so don't gamble anything you can't afford to lose.") 
	hide(31)
	------------------------------------------------
	-- Assuming optimal playing then
	-- Expected payout: 105.96% (easy), 97.11% (normal), 92.69% (hard)
</LuaCode>
-----------------------------------------------------------------------

Nr=32 Text=_"Tell me the rules for your 'coin-flip game'."
<LuaCode>
	npc_says(_"It is simple. Five coin flips.")
	npc_says(_"You bet. Then you tell me if I will flip more 'heads' or 'tails'.")
	npc_says(_"I flip one coin.")
	npc_says(_"Then you tell me if there will be an 'odd' or 'even' number of flips for what you chose.")
	if (difficulty() == "easy") then
		npc_says(_"I flip the other four coins. If you were completely right, I give you three times what your bet, if wrong, you get nothing.")
	elseif (difficulty() == "normal") then
		npc_says(_"I flip the other four coins. If you were completely right, I give you twice what your bet, if completely wrong, you get 3/4 of your bet back.")
	else
		npc_says(_"I flip the other four coins. If you were completely right, I give you twice what your bet, if completely wrong, you get half of your bet back.")
	end
	npc_says(_"But if you are only partially wrong... well, then you get nothing.")
	npc_says(_"Remember: the odds are slightly against you, so don't gamble anything you can't afford to lose.") 
	hide(32)
	------------------------------------------------
	-- Assuming optimal playing: 
	-- Winning both: 11/32 expected payout: 132/128 (easy), 88/128 (normal/hard)
	-- Losing both: 11/32 expected payout: 0/128 (easy), 33/128 (normal), 22/128 (hard)
	-- Intermediate: 10/32 expected payout: 0/128
	-- Expected payout: 132/128 (easy), 121/128 (normal), 110/128 (hard)
</LuaCode>
-----------------------------------------------------------------------

Nr=33 Text=_"How about a bet of 10 circuits"
<LuaCode>
	bet=10
	hide(30, 31, 32, 33, 34, 35) next(36)
</LuaCode>
-----------------------------------------------------------------------

Nr=34 Text=_"I'm feeling I'll start with a bet of 100 circuits"
<LuaCode>
	bet = 100
	hide(30, 31, 32, 33, 34, 35) next(36)
</LuaCode>
-----------------------------------------------------------------------

Nr=35 Text=_"I want to bet 200 circuits"
<LuaCode>
	bet = 200
	hide(30, 31, 32, 33, 34, 35) next(36)
</LuaCode>
-----------------------------------------------------------------------

Nr=36 Text="BUG, REPORT ME! ewald node36 -- Name Game"
NO_TEXT
<LuaCode>
	npc_says(_"Name your game.")
	show(37, 38)
</LuaCode>
-----------------------------------------------------------------------

Nr=37 Text=_"Dice"
<LuaCode>
	hide(37, 38) next(39)
</LuaCode>
-----------------------------------------------------------------------

Nr=38 Text=_"Coin-flipping"
<LuaCode>
	hide(37, 38) next(50)
</LuaCode>
-----------------------------------------------------------------------

Nr=39 Text="BUG, REPORT ME! ewald node39 -- Dice - Initial roll"
NO_TEXT
<LuaCode>
	npc_says(_"Dice it is. Roll your first die.")
	tux1=math.random(1,6)
	tux_says(_"I rolled a ".. tux1 ..".")
	npc_says(_"What multiplier are you going to bet?")
	show(40, 41, 42)
</LuaCode>
-----------------------------------------------------------------------

Nr=40 Text="1x"
<LuaCode>
	next(43)
</LuaCode> 
-----------------------------------------------------------------------

Nr=41 Text="2x"
<LuaCode>
	bet=bet*2
	next(43)
</LuaCode>
-----------------------------------------------------------------------

Nr=42 Text="3x" 
<LuaCode>
	bet=bet*3
	next(43)
</LuaCode>
-----------------------------------------------------------------------

Nr=43 Text="BUG, REPORT ME! ewald node43 -- Dice - finish game" -- finish game here
NO_TEXT
<LuaCode>
	npc_says(_"You've bet ".. bet .._" valuable circuits.")
	ewd1=math.random(1,6)
	npc_says(_"My first roll is a ".. ewd1 ..".")
	tux2=math.random(1,6)
	tux_says(_"I rolled a ".. tux2 ..".")
	ewd2=math.random(1,6)
	npc_says(_"My second roll is a ".. ewd2 ..".")
	tux3=math.random(1,6)
	tux_says(_"I rolled a ".. tux3 ..".")
	ewd3=math.random(1,6)
	npc_says(_"My third roll is a ".. ewd3 ..".")

	npc_says(_"It looks like I scored ".. ewd1+ewd2+ewd3 .._" and you scored "..tux1+tux2+tux3..".")

	if ((ewd1+ewd2+ewd3) < (tux1+tux2+tux3)) then --Tux wins!
		npc_says_random(_"You won! Good job.", _"You won! Man you are lucky!", _"You won!")
		if (difficulty() == "easy") then
			bet=bet*0.95
		elseif (difficulty() == "normal") then
			bet=bet*0.85
		else
			bet=bet*0.8
		end
		add_gold(bet)
		display_console_message(_"You won ".. math.floor(bet) .._" valuable circuits by gambling dice with Ewald.")
	else -- House Wins!
		npc_says_random(_"You lost. Bad luck.", _"You lost. Better luck next time.", _"You lost, try again?", _"You lost. Maybe you might like coin-flipping better?")
		del_gold(bet)
		display_console_message(_"You lost ".. bet .._" valuable circuits by gambling dice with Ewald.")
	end
	hide(40, 41, 42) show(30)
</LuaCode>
-----------------------------------------------------------------------

Nr=50 Text="BUG, REPORT ME! ewald node50 -- Coin-flipping game"
NO_TEXT
<LuaCode>
	npc_says(_"Coin flipping it is.")
	npc_says(_"So. What do you think? Heads or tails?")
	show(51, 52)
</LuaCode>
-----------------------------------------------------------------------

Nr=51 Text=_"Heads"
<LuaCode>
	npc_says_random(_"Heads, eh? I always like heads.", _"Heads? Sometimes I pick heads... when I don't pick tails.", _"When I think too much about it, I end up picking heads.", _"Just the other day I found out that 'obverse' was the fancy name for 'heads'. Trippy.", _"I think I would have picked tails this time.")
	tux1 = 0
	hide(51, 52) next(53)
</LuaCode>
-----------------------------------------------------------------------

Nr=52 Text=_"Tails"
<LuaCode>
	npc_says_random(_"Tails? Fits, since you've got one.", _"Tails? I always liked that game... good times.", _"Tails. When I don't pick heads, I always pick tails.", _"Just the other day I found out that 'reverse' was the fancy name for 'tails'. Trippy.", _"I think I would have picked heads this time.")
	tux1 = 1
	hide(51, 52) next(53)
</LuaCode>
-----------------------------------------------------------------------

Nr=53 Text="BUG, REPORT ME! ewald node53 -- Coin-flipping game - first flip"
NO_TEXT
<LuaCode>
	npc_says(_"Here goes nothing.")
	ewd1=math.random(0,1)
	if (ewd1 == 1) then
		npc_says(_"Looks like it is 'tails'.")
	else
		npc_says(_"Looks like it is 'heads'.")
	end

	if (tux1 == 1) then
		npc_says(_"So do you think there will be an even or odd number of 'tails' flips?")
	else
		npc_says(_"So do you think there will be an even or odd number of 'heads' flips?")
	end
	show(54, 55)
</LuaCode>
-----------------------------------------------------------------------

Nr=54 Text=_"Even number"
<LuaCode>
	tux2 = 0 -- Set to 'even'
	random_var = math.random()
 	if (random_var > 0.8) then
		npc_says(_"Even, eh? I always like even. It is so symmetric.")
	elseif (random_var > 0.6) then
		npc_says(_"Even? Sometimes I pick even... when I don't pick odd.")
	elseif (random_var > 0.4) then
		npc_says(_"When I think too much about it, I end up picking even.")
	elseif (random_var > 0.2) then
		if (ewd1 ~= tux1) then
			npc_says(_"Hoping to guess them all wrong, eh?")
		else
			npc_says(_"Bucking the statistics. I like that.")
		end
	else
		npc_says(_"I think I would have picked even this time.")
	end
	hide(54, 55) next(56)
</LuaCode>
-----------------------------------------------------------------------

Nr=55 Text=_"Odd number"
<LuaCode>
	tux2 = 1 -- Set to 'odd'
	random_var = math.random()
 	if (random_var > 0.8) then
		npc_says(_"Odd? Fits, since you're pretty odd yourself.")
	elseif (random_var > 0.6) then
		npc_says(_"Odd? Well that is odd... I was thinking of odd.")
	elseif (random_var > 0.4) then
		npc_says(_"Odd. When I don't pick even, I always pick odd too.")
	elseif (random_var > 0.2) then
		if (ewd1 == tux1 ) then
			npc_says(_"Honing up on your math, eh?")
		else
			npc_says(_"Betting against the game. I like that.")
		end
	else
		npc_says(_"I think I would have picked odd this time.")
	end
	hide(54, 55) next(56)
</LuaCode>
-----------------------------------------------------------------------

Nr=56 Text="BUG, REPORT ME! ewald node56 -- Coin-flipping game - last four flips"
NO_TEXT
<LuaCode>
	npc_says(_"The last four coin flips:")
	ewd2=math.random(0,1)
	if (ewd2 == 1) then
		npc_says(_"Tails.")
	else
		npc_says(_"Heads.")
	end
	ewd3=math.random(0,1)
	if (ewd3 == 1) then
		npc_says(_"Tails.")
	else
		npc_says(_"Heads.")
	end
	ewd4=math.random(0,1)
	if (ewd4 == 1) then
		npc_says(_"Tails.")
	else
		npc_says(_"Heads.")
	end
	tux_says(_"Last flip. I hope it is the one I want!")
	ewd5=math.random(0,1)
	if (ewd5 == 1) then
		npc_says(_"Tails.")
	else
		npc_says(_"Heads.")
	end
	ewald_sum = ewd1 + ewd2 + ewd3 + ewd4 + ewd5
	npc_says(_"Looks like that is ".. ewald_sum .._" tails, and ".. 5-ewald_sum.._" heads.")

	win=0 --find if tux won...
	if (ewald_sum > 2) then
		npc_says(_"Tails won...")
		if (tux1 == 1) then win = 0.5 end
	else
		npc_says(_"Heads won...")
		if (tux1 == 0) then win = 0.5 end
	end


	if (math.fmod(ewald_sum,2) == 0) then
		if (tux1 == 1) then
			npc_says(_"...and there was an even number of tails.")
			if (tux2 == 0) then win = win + 0.5 end
		else
			npc_says(_"...and there was an odd number of heads.")
			if (tux2 == 1) then win = win + 0.5 end
		end
	else
		if (tux1 == 1) then
			npc_says(_"...and there was an odd number of tails.")
			if (tux2 == 1) then win = win + 0.5 end
		else
			npc_says(_"...and there was an even number of heads.")
			if (tux2 == 0) then win = win + 0.5 end
		end
	end


	if (win == 1) then -- WIN
		npc_says_random(_"Looks like another winning combination! Good job!", _"You have the best luck! You won!", _"Too many of these and I'll go out of business. You won!", _"You will have to tell me how you did it. You Won!", _"Let me be even with you: I can't make heads or tails of how you won this odd game. Good Job!")
		if (difficulty() == "easy") then bet = bet*3
		else bet = bet*2
		end
		add_gold(bet)
		display_console_message(_"You won ".. bet .._" valuable circuits in the coin-flip game with Ewald.")
	elseif (win == 0) then --LOSS
		if (difficulty() == "easy") then--easy: 0% back
			npc_says_random(_"Looks like you got everything wrong.", _"Well, close, but exactly wrong.", _"Close, but no cigar.", _"Close only counts in hand grenades and horseshoes.")
			del_gold(bet)
		else
			npc_says_random(_"Looks like you got everything wrong... here is some of your bet back.", _"Well, close, but exactly wrong. Here is some of your bet back.", _"You need to do exactly opposite of what you did here. Here is part of your bet back.", _"Close, but no cigar. Here is some of your money back.", _"Next time pick the opposite of what you did this time... or something.")
			if (difficulty() == "normal") then --normal: 75% back
				bet = bet*0.25
			else --hard: 50% back
				bet = bet*0.5
			end
			del_gold(bet)
		end
		display_console_message(_"You lost ".. math.floor(bet) .._" valuable circuits in the coin-flip game with Ewald.")
	elseif (win == 0.5) then -- COMPLETE LOSS (0% back)
		npc_says_random(_"You lost. You were half right, but half wrong. Pick one and stay with it.", _"You lost. You were all messed up. Better luck next time.", _"You lost. Maybe you should try something else for a while?", _"You lost.", _"You lost. You might try the dice game next time.")
		del_gold(bet)
		display_console_message(_"You lost ".. bet .._" valuable circuits in the coin-flip game with Ewald.")
	else -- ERROR:
		npc_says(_"THIS IS AN ERROR! REPORT IT PLEASE! E-MAIL: freedroid-discussion@lists.sourceforge.net")
	end

	show(30)
</LuaCode>
-----------------------------------------------------------------------

Nr=99 Text=_"See you later."
<LuaCode>
	npc_says_random(_"Goodbye and remember: My bar is always open.", _"Come back soon!", _"You are welcome to unwind with old Ewald any time. Come back soon.", _"Remember, you can always come back here to relax and kick back.")
	hide(32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 50, 51, 52, 53, 54, 55, 56) --end any partial gambling
	end_dialog()
</LuaCode>
----------------------------------------------------------------------

End of chat dialog for character="XXXXX"
