1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
3 if (!globals.contains("irc")) {
23 function str2arr(str) {
26 for (i in range(str.len())) {
27 arr.add(str.substr(i, 1))
36 h_arr = str2arr(h_word)
42 for (x in range(a_arr.len())) {
43 a_arr[x] = (h_arr[x] == " ")
47 function print_progress() {
50 for (x in range(a_arr.len())) {
61 hangman_output(errors + "/" + (max_errors + 1) + " errors made: " + misses)
64 function create_hint() {
65 var r = Math.floor(Math.random() * a_arr.len())
68 for (x in range(h_arr.len())) {
69 if (h_arr[x] == h_arr[r]) {
74 if (a_arr.contains(false)) {
81 if (!a_arr.contains(false)) {
96 hangman_output("Congratulations, you are a winner in " + guesses + " guesses.")
103 hangman_output("Please set a word with hm.init(\"word\")")
110 hangman_output("NEIN!")
115 for (x in range(h_arr.len())) {
131 if (!a_arr.contains(false)) {
136 if (errors > max_errors) {
137 hangman_output("You died...")
138 hangman_output(" ________")
139 hangman_output(" |/ |")
140 hangman_output(" | (_)")
141 hangman_output(" | \\|/")
142 hangman_output(" | |")
143 hangman_output(" | / \\")
145 hangman_output("_|___")
152 var n = Dictionary.prototype.clone.call(this)
155 n.h_arr = h_arr.clone()
159 n.a_arr = a_arr.clone()