Fix the easter egg

fixes #12617
This commit is contained in:
Gunnar Beutner 2016-09-01 15:28:56 +02:00
parent 02442ff36f
commit 1f9d54b6a2
1 changed files with 20 additions and 14 deletions

View File

@ -31,6 +31,12 @@ hm = {
a_arr = null a_arr = null
misses = "" misses = ""
if (irc) {
hangman_output = irc
} else {
hangman_output = log
}
function str2arr(str) { function str2arr(str) {
var arr = [] var arr = []
@ -68,8 +74,8 @@ hm = {
ir += " " ir += " "
} }
irc(ir) hangman_output(ir)
irc(errors + "/" + (max_errors + 1) + " errors made: " + misses) hangman_output(errors + "/" + (max_errors + 1) + " errors made: " + misses)
} }
function create_hint() { function create_hint() {
@ -104,21 +110,21 @@ hm = {
function winner() { function winner() {
if (h_word) { if (h_word) {
irc("Congratulations, you are a winner in " + guesses + " guesses.") hangman_output("Congratulations, you are a winner in " + guesses + " guesses.")
h_word = null h_word = null
} }
} }
function guess(s) { function guess(s) {
if (!h_word) { if (!h_word) {
irc("Please set a word with hm.init(\"word\")") hangman_output("Please set a word with hm.init(\"word\")")
return return
} }
s = s.upper() s = s.upper()
if (s.len() != 1) { if (s.len() != 1) {
irc("NEIN!") hangman_output("NEIN!")
return return
} }
@ -145,15 +151,15 @@ hm = {
} }
if (errors > max_errors) { if (errors > max_errors) {
irc("You died...") hangman_output("You died...")
irc(" ________") hangman_output(" ________")
irc(" |/ |") hangman_output(" |/ |")
irc(" | (_)") hangman_output(" | (_)")
irc(" | \\|/") hangman_output(" | \\|/")
irc(" | |") hangman_output(" | |")
irc(" | / \\") hangman_output(" | / \\")
irc(" |") hangman_output(" |")
irc("_|___") hangman_output("_|___")
remove("h_word") remove("h_word")
return return
} }