Skip to content

Instantly share code, notes, and snippets.

@niieq
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save niieq/c31bcae8ba20dd75181b to your computer and use it in GitHub Desktop.

Select an option

Save niieq/c31bcae8ba20dd75181b to your computer and use it in GitHub Desktop.

Disappointed Elixir Guesser Game Developer

So as part of my journey learning elixir, i decided to write a small guessing game in elixir.

Decided to do this to understand and experiment with elixir because the book seems long for me.

But i kept making simple mistakes and complex ones. I got my head around the simple ones when i go back to the book and do a little reading but this complex ones still keep hitting me strong in the head.

It has been two weeks since i decided to write a blog post concerning a working guexxir(Name of my elixir guesser game).

Ok so now i am actually writing the post but my game is still not working. So this is my code structure. Help me fix it.

defmodule GuesElixir do
	def welcome_player do
		IO.puts String.duplicate("*", 80)
		IO.puts "Howdy! Let's GUEZZ A NAME"
		IO.puts String.duplicate("*", 80)
	end

	def checkguess(""), do: "Massa Massa! i beg enter something"

	def checkguess(n) do
		guesses = ["abigail","ade", "nii", "equity","cecilia"]
		if n in guesses do
			IO.puts "HAAY!!! you guessed right. i really like #{n} o "
		else
			IO.puts "Sorry u know nothing about my life"
		end
	end

	def enter_game_loop do
		welcome_player()
		urguess = IO.gets("What will be the name of my next best friend? ")
		better_guess = String.lstrip(urguess, ?\n)
		IO.puts "Ok so u guessed #{better_guess} , well lets see ......"
		checkguess(urguess)
	end

end
@niieq
Copy link
Author

niieq commented Feb 8, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment