/*	Hangman

		A game of Hangman.

		Digita ARexx Script for Wordworth 7
		Copyright 1998, Digita International Ltd.
		
		Created: 31 May 1996
		Author:  MJ
*/


OPTIONS RESULTS


/* The Text */
NumLines = 29

line0  = "Patriot Games"
line0b = "Film"
line0c = "Stars Harrison Ford"

Line1  = "Manhattan Murder Mystery"
Line1b = "Film"
Line1c = "Directed by Woody Allen"

Line2  = "Play It Again Sam"
Line2b = "Film" 
Line2c = "Directed by Woody Allen"

Line3  = "Roman Holiday"
Line3b = "Film"
Line3c = "Starring Audrey Hepburn"

line4  = "Blazing Saddles"
line4b = "Film"
line4c = "Directed by & starring Mel Brookes"

line5  = "A Night at the Opera"
line5b = "Film"
line5c = "Starring the Marx Brothers"

line6  = "Duck Soup"
line6b = "Film"
line6c = "Starring the Marx Brothers"

line7  = "Modern Times"
line7b = "Film"
line7c = "Starring Charlie Chaplin"

line8  = "Dead Ringers"
line8b = "Film"
line8c = "A David Cronenburg horror"

line9  = "Naked Lunch"
line9b = "Film"
line9c = "Based on the book by William Burroughs"

line10  = "Star Wars"
line10b = "Film"
line10c = "First in a space trilogy by George Lucas"

line11  = "Beetlejuice"
line11b = "Film"
line11c = "Don't say his name three times!!!"

line12  = "2010"
line12b = "Film"
line12c = "Follow up to 2001!!"

line13  = "1984"
line13b = "Film"
line13c = "George Orwell's vision, starring John Hurt"

line14  = "A Clockwork Orange"
line14b = "Film"
line14c = "Banned in the UK by its director"

line15  = "The Piano"
line15b = "Film"
line15c = "88 keys"

line16  = "Gone with the Wind"
line16b = "Film"
line16c = "Frankly, m'dear, I don't give a damn!"

line17  = "Taxi Driver"
line17b = "Film"
line17c = "Stars Robert de Niro"

line18  = "Breakfast at Tiffanys"
line18b = "Film"
line18c = "Features Holly Golightly singing Moon River"

line19  = "Terminator"
line19b = "Film"
line19c = "He'll be back!"

line20  = "Jurassic Park"
line20b = "Film"
line20c = "The Dinosaurs are back!"

line21  = "Golden Eye"
line21b = "Film"
line21c = "The first Bond film starring Pierce Brosnan"

line22  = "Braveheart"
line22b = "Film"
line22c = "Directed by Mel Gibson, and starring him as a Scotsman!"

line23  = "Schindler's List"
line23b = "Film"
line23c = "Won Stephen Spielberg his first Oscar as director"

line24  = "Jaws"
line24b = "Film"
line24c = "A fishy tale from Stephen Spielberg"

line25  = "The Godfather"
line25b = "Film"
line25c = "First in a trilogy from Francis Ford Coppola"

line26  = "Wayne's World"
line26b = "Film"
line26c = "Starring Mike Myers and Dana Carvey"

line27  = "Reservoir Dogs"
line27b = "Film"
line27c = "Violent film about some colourful people, by Quentin Tarantino"

line28  = "Top Gun"
line28b = "Film"
line28c = "Tom Cruise flies some planes"

line29  = "Naked Gun"
line29b = "Film"
line29c = "Stars Leslie Nielsen"



/* Main Program */


New
Address Value Result

Num = Randu(Time('S'))
Num = Num * NumLines
Num = Num % 1
RandomLine = "Line" || Num

TheText = Value(RandomLine)

TextLength = Length(TheText)

Font NAME "Shannon Book" SIZE "20pt"

Gottext = ''
NumLetters = 0

Do Num = 1 to TextLength
	Letter = SubStr(TheText, Num, 1)
	IF Letter = ' ' THEN
		GotText = GotText || ' '
	ELSE DO
		GotText = GotText || 'X'
		NumLetters = NumLetters + 1
	END
END

Text GotText

NewParagraph
NewParagraph
Font SIZE "10pt"
Text 'Guessed letters: '

GotRight = 0
GotWrong = 0

GET_LETTER:
WizardReq TITLE "Hangman" LABEL "It's a" Value(RandomLine || b) LABEL "Enter a letter:" Textbox 1 "_Letter" BUTTON 1 "_OK" BUTTON 2 "_Guess phrase..." BUTTON 3 "_Clue..." BUTTON "-1" "_Give up"
buttonpressed = Result
IF buttonpressed = -1 THEN
	SIGNAL DEAD

IF buttonpressed = 3 THEN DO
	GotWrong = GotWrong + 1
	RequestNotify PROMPT Value(RandomLine || c)
END

IF buttonpressed = 2 THEN DO
	WizardReq TITLE "Hangman" LABEL "Enter the phrase:" Textbox 1 "_Phrase" BUTTON 1 "_OK" BUTTON "-1" "_Cancel"
	IF Result = -1 THEN
		SIGNAL GET_LETTER

	Wizard_GetTextBox 1
	GuessedPhrase = Result
	GuessedPhrase = Upper(GuessedPhrase)
	Temp = Upper(TheText)

	IF GuessedPhrase ~= Temp THEN
		SIGNAL DEAD
	ELSE DO
		RequestNotify "Well done! only" GotWrong "wrong guesses!"
		Close FORCE
		Exit
	END
END

IF buttonpressed = 1 THEN DO
Wizard_GetTextBox 1
Guess = Result

IF (Length(Guess)) > 1 THEN DO
	RequestNotify PROMPT "One letter at a time, stupid!"
	SIGNAL GET_LETTER
END

IF Guess = "" THEN DO
	RequestNotify PROMPT "Type a letter, thicky!"
	SIGNAL GET_LETTER
END

Position EOF

Font SIZE "10pt"
TempText = Guess || " "
Text TempText

Position SOF

Font SIZE "20pt"
RightThisGo = 0
Do Num = 1 to TextLength
	Letter = SubStr(TheText, Num, 1)
	ULetter = Upper(Letter)
	UGuess = Upper(Guess)
	If ULetter = UGuess THEN DO
		Delete
		Text Letter
		GotRight = GotRight + 1
		RightThisGo = 1
	END
	ELSE
		Cursor Right
END

IF RightThisGo = 0 THEN
	GotWrong = GotWrong + 1

IF GotRight = NumLetters THEN DO
	RequestNotify "Well done! only" GotWrong "wrong guesses!"
	Close FORCE
	Exit
END

END

IF GotWrong = 1 THEN
	DrawLine 1 "6.3in" "2.14in" "7.49in" "2.14in" "2pt"
ELSE IF GotWrong = 2 THEN
	DrawLine 1 "6.86in" "2.12in" "6.86in" "0.91in" "2pt"
ELSE IF GotWrong = 3 THEN
	DrawLine 1 "6.87in" "0.92in" "7.46in" "0.92in" "2pt"
ELSE IF GotWrong = 4 THEN
	DrawLine 1 "6.86in" "1.2in" "7.12in" "0.94in" "2pt"
ELSE IF GotWrong = 5 THEN
	DrawLine 1 "7.46in" "0.91in" "7.46in" "1.12in" "2pt"
ELSE IF GotWrong = 6 THEN
	DrawCircle 1 "7.32in" "1.07in" "0.26in" "Bright Red" "2pt"
ELSE IF GotWrong = 7 THEN
	DrawLine 1 "7.43in" "1.37in" "7.43in" "1.6in" "2pt"
ELSE IF GotWrong = 8 THEN
	DrawLine 1 "7.4in" "1.41in" "7.24in" "1.51in" "2pt"
ELSE IF GotWrong = 9 THEN
	DrawLine 1 "7.44in" "1.43in" "7.61in" "1.51in" "2pt"
ELSE IF GotWrong = 10 THEN
	DrawLine 1 "7.4in" "1.61in" "7.27in" "1.72in" "2pt"
ELSE IF GotWrong = 11 THEN DO
	DrawLine 1 "7.43in" "1.6in" "7.58in" "1.74in" "2pt"
DEAD:
	RequestNotify "You're dead!, it was '"TheText"'"
	Close FORCE
	Exit
END

SIGNAL GET_LETTER
