1 /******************************************************************************
3 * Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com/) *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License *
7 * as published by the Free Software Foundation; either version 2 *
8 * of the License, or (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software Foundation *
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ******************************************************************************/
21 globals.irc = globals.log
40 function str2arr(str) {
43 for (i in range(str.len())) {
44 arr.add(str.substr(i, 1))
53 h_arr = str2arr(h_word)
59 for (x in range(a_arr.len())) {
60 a_arr[x] = (h_arr[x] == " ")
64 function print_progress() {
67 for (x in range(a_arr.len())) {
78 hangman_output(errors + "/" + (max_errors + 1) + " errors made: " + misses)
81 function create_hint() {
82 var r = Math.floor(Math.random() * a_arr.len())
85 for (x in range(h_arr.len())) {
86 if (h_arr[x] == h_arr[r]) {
91 if (a_arr.contains(false)) {
98 if (!a_arr.contains(false)) {
104 for (x in range(i)) {
113 hangman_output("Congratulations, you are a winner in " + guesses + " guesses.")
120 hangman_output("Please set a word with hm.init(\"word\")")
127 hangman_output("NEIN!")
132 for (x in range(h_arr.len())) {
148 if (!a_arr.contains(false)) {
153 if (errors > max_errors) {
154 hangman_output("You died...")
155 hangman_output(" ________")
156 hangman_output(" |/ |")
157 hangman_output(" | (_)")
158 hangman_output(" | \\|/")
159 hangman_output(" | |")
160 hangman_output(" | / \\")
162 hangman_output("_|___")
169 var n = Dictionary.prototype.clone.call(this)
172 n.h_arr = h_arr.clone()
176 n.a_arr = a_arr.clone()