printLine=function()
print "==================================================="
end function
printEmpty = function()
print ""
end function
dG=function(p)
lines = [" +--+"," | |"," |"," |"," |"," |","====="]
if p > 0 then lines[2] = " O |"
if p > 1 then lines[3] = " | |"
if p > 2 then lines[3] = "/| |"
if p > 3 then lines[3] = "/|\ |"
if p > 4 then lines[4] = "/ |"
if p > 5 then lines[4] = "/ \ |"
for line in lines
print line
end for
end function
wordl=["APFEL","AFFE","KUCHEN","KREUZ","LOEFFEL","KLOPAPIER","TANZEN"]
choice=floor(rnd*wordl.len)
word=wordl[choice]
gu=""
wrong=[]
for i in range(0,word.len-1)
gu=gu + "*"
end for
gameOver=false
gP=0
message="Welcome to german hangman"
lL=word.len
printState=function()
printLine
dG gP
print "GERMAN hangman"
print word.len + " letter word"
print gu
wS= ""
if wrong.len > 0 then
for j in range(0,wrong.len-1)
wS=wS+wrong[j]+", "
end for
end if
print "Wrong guesses: " + wS
print "Guess a letter"
printEmpty
print message
end function
while not gameOver
printState
guess=input.upper
if guess.len == 1 and guess.code >= 65 and guess.code <= 90 then
hit = false
for i in range(0,word.len-1)
if guess.code == word.values[i].code then
gu=gu[0:i]+guess+gu[i+1:gu.len]
lL=lL-1
hit=true
end if
end for
if not hit then
gP=gP + 1
wrong.push guess
end if
if gP > 5 or lL <= 0 then
gameOver=true
if gP > 5 then
message="You lost!"
else
message="Congratulations, you won!"
end if
end if
else
message="Only 1 letter (umlauts are AE, UE, or OE), ß is SS"
end if
end while
printState
print ""