@@ -52,27 +52,27 @@ ( The array contains offset information; set the guess string ) : update-guessed ( $ offsets len - ) - for 2dup @ + this-char @ swap ! 1+ next 2drop ; + for 2dup @ + @this-char swap ! 1+ next 2drop ; : toGuess ( guessed target c - ) dup this-char ! offsets ( guessed offsets length ) 2dup 2push update-guessed 2pop unarray ; -: guessChar ( c- ) guessed @ target @ rot toGuess ; +: guessChar ( c- ) @guessed @target rot toGuess ; ( --[ Printing ]---------------------------------------------- ) -: .target ( - ) target @ print ; -: .guessed ( - ) guessed @ print ; -: .input ( - ) "Tries: ( " print lifeline @ . "): " print ; -: .fouls ( - ) "Fouls: " print foul-addr print ; +: .target ( - ) @target puts ; +: .guessed ( - ) @guessed puts ; +: .input ( - ) "Tries: (" puts lifeline @ putn "): " puts ; +: .fouls ( - ) "Fouls: " puts foul-addr puts ; : .prompt ( - ) 0 0 at-xy .guessed cr .fouls cr .input ; -: .already ( - ) space "[already guessed]" print ; -: .correct ( - ) space "[correct guess] " print ; +: .already ( - ) space "[already guessed]" puts ; +: .correct ( - ) space "[correct guess] " puts ; : .graphic ( - ) lives lifeline @ - 1- graphics + @ do ; -: .wrong ( - ) space "[not present] " print .graphic ; +: .wrong ( - ) space "[not present] " puts .graphic ; ( --[ Guessing ]---------------------------------------------- ) : 0<> ( x-f ) 0 = not ; @@ -101,19 +101,19 @@ : remaining ( -f ) guessed @ '_ has ; : alive ( -f ) remaining lifeline @ 0<> and ; : dead ( -f ) alive not ; : foot ( - ) 0 20 at-xy ; -: .lose ( - ) foot "You LOSE; the word was: " print .target ; -: .win ( - ) foot .target cr "You WIN!" print ; +: .lose ( - ) foot "You LOSE; the word was: " puts .target ; +: .win ( - ) foot .target cr "You WIN!" puts ; : endgame ( - ) lifeline @ if .win else .lose then ; : (hangman) ( - ) clear repeat dead if endgame ;then guess again ; : hangman ( $- ) >target revive (hangman) ; ( --[ Main Game ]--------------------------------------------- ) : y-or-n ( -f ) key dup 'y = swap 'Y = or ; -: .again? ( -f ) cr cr "Play again? [Y/N] " print y-or-n ; +: .again? ( -f ) cr cr "Play again? [Y/N] " puts y-or-n ; : play ( - ) initialise dict @ 0; drop repeat get-word hangman .again? 0 =if close-dict bye then again ; ( ============================================================ ) play