/**************************************************************************\
|*                                                                        *|
|* The Wheel of Fortune, v6.0b; ASCII MODULE, by DOTORAN of Frontiers BBS *|
|*                                                                        *|
\**************************************************************************/
options results ; signal on SYNTAX ; signal on ERROR ; signal on IOERR
tr=transmit ; se=sendstring ; gc=getchar ; gu=getuser ; qu=query
bf=bufferflush ; changewhere 'WOF, v6.0 ASC!' ; oldwh=result
bbsidentify name ; bbsname=result ; bbsidentify sysop ; sysop=result
seed=random(0,1000,time('s')) ; call READCONFIG

BEGIN: /* Entry Point if Winner Chooses to RePlay the Game. */
    logs=0 ; log.='' ; wh=1 ; gu 1 ; handle=result ; action='Visited '
    gu 6 ; street=result ; gu 9 ; voice=result ; gu 10 ; data=result ; freespins=0 ; lo=0
    gu 41 ; sid=result ; date=date('s') ; gu 7 ; t=result ; timeleft=t%10||'.'||right(t,1)
    dateL=date('m',date,'s')||' '||strip(right(date,2),'l','0')||', '||left(date,4)
    gu 15 ; access=result ; gu 17 ; maintA=result ; spa=copies(' ',78)
    wheel='15 10 4 5 3 1 8 6 5 12 3 1 13 2 7 14 6 4 3  2 6 9 4 5' ; sp=0
    cons='BCDFGHJKLMNPQRSTVWXYZ' ; vows='AEIOU' ; wheal=overlay('11',wheel,42)

    if ~exists(dfile||'GameData') then call SETUP

    call READPLAYERS ; if player=0 then do ; players=players+1
        player=players ; player.player=handle||'|0|0|0|0|0|0|0|0|x' ; end
    parse var player.player handle'|'puzwon'|'monwon'|'puznum'|'moncur'|',
                            played'|'percent'|'bonwins'|'boncash'|'junk
    key1='n1'||center(k1,78+(m1*3)) ; key2='n1'||center(k2,78+(m2*3))
    call READDATA ; call READSTATS ; call READWINNER ; call READWINNERS
    call READBWINNERS ; call READLASTPLAYER

START:
    tr 'f1c7' ; a=sysop||' Broadcasting Presents:n1'
    tr center(a,81) ; call TITLE
    tr center('Brought to you by: '||bbsname||' TV!n1',81)
    tr center('There are '||total||' Known Puzzles!',78)
    tr key1 ; call MENU

MAIN:
    se 'n1['timeleft' Min.Left] Menu: >>>--H,Y,A,P,L,B,O,N,I,Q,?=Menu--> '
MAIN1:
    gc ; a=index('HALBYPONIQCE!?/M',result) ; call CHECK ; bf ; if a=0 then signal MAIN1
    if a=16 then do ; tr 'Maintenance#0'||dfile||'Maint}c7' ; changewhere 'WOF, v6.0 ASC!'
        if ~exists(dfile||'GameData') | ~exists(dfile||'Players') then exit ; else signal MAIN ; end
    if a=1 then do ; tr 'Hall of Fame' ; call HOFAME     ; signal MAIN ; end
    if a=2 then do ; tr 'All Scores'   ; call ALLSCORES  ; signal MAIN ; end
    if a=3 then do ; tr 'Last Puzzles' ; call LASTPUZS   ; signal MAIN ; end
    if a=4 then do ; tr 'Bonus Puzzles'; call BONUSPUZS  ; signal MAIN ; end
    if a=5 then do ; tr 'Your Stats'   ; call YOURSTATS  ; signal MAIN ; end
    if a=6 then do ; tr 'Play Game'    ; signal PLAYGAME ; end
    if a=7 then do ; tr 'OLD Game Log' ; tr '*0'||dfile||'Log.OLD.ASC}c7'key1
        call WL("ca"||handle||" c6veiwed the cfOLD cbGame Logc6.") ; signal MAIN ; end
    if a=8 then do ; tr 'NEW Game Log' ; tr '*0'||dfile||'Log.NEW.ASC}c7'key1
        call WL("ca"||handle||" c6veiwed the ceNEW cbGame Logc6.") ; signal MAIN ; end
    if a=9 then do ; tr 'Instructions' ; call DOCS ; signal MAIN ; end
    if a=10 then do ; tr 'Quit Game'    ; call QUIT ; signal MAIN ; end
    if a=11 & Mflag=1 then do ; tr 'Cancel Game' ; signal CANCELGAME ; end
    if a=12 & Mflag=1 then do ; tr 'Error Log List' ; a=exists(dfile||'wof.errors')
        if a=0 then do ; tr 'n1No Errors Loggedn1'key1 ; signal MAIN ; end
        se '*0'||dfile||'wof.errors}n1Delete Log Now? [No]: ' ; gc ; a=result
        if a~='Y' then do ; tr 'No.' ; signal MAIN ; end
        tr 'Yes!$odelete '||dfile||'wof.errors}' ; signal MAIN ; end
    if a=13 & Mflag=1 then do ; call open(f1,dfile||'LastPlayer','w')
        call writeln(f1,'0|No One|No Where|0|0|x') ; call close(f1)
        call READLASTPLAYER ; tr 'Play Game' ; signal PLAYGAME ; end
    if a>13 then do ; tr 'Main Menu' ; call MENU ; signal MAIN ; end
  signal MAIN1

PLAYGAME:
    if LHan='No One' & play=0 & handle=winhan then do
        call WL("ca"||handle||" c6tried to play first, but was the cbLast Winnerc6!")
        se 'f1n1Pat comes up to you and whispers in your ear, "Sorry, 'handle
        se ', but 'sysop' Broadcasting doesn''t allow recent winners to be '
        se 'the FIRST player in a NEW Game. You''ll have to wait until another '
        tr 'contestant has played the game."n1'
        se 'On your way out of the studio, Vanna hands you a slip of paper. '
        tr 'Reading it, you discover the new puzzle.n1' ; call SHOWPUZZLE
        tr key2 ; signal QUIT2 ; end

    if handle=author then do
        call WL("ca"||handle||" c6tried to play, but is the cbAuthorc6!")
        se 'f1n1Vanna and Pat approach you from the wings.  Vanna gives '
        se 'you a playful slap on the butt. Pat says, "Naughty. You wrote '
        tr 'the puzzle and must wait until someone wins."n1'
        se 'After a moment, Pat continues, "However, we will show you how '
        tr 'your puzzle is doing before you leave."n1' ; call SHOWPUZZLE
        tr key2 ; signal QUIT2 ; end

    if newplay=0 & (sid=0 | access=0) then do
        call WL("ca"||handle||" c6tried to play, but was a cbGuestc6/cbNew Userc6!")
        se 'f1n1Pat looks at you quizically, "You''re NEW around here, aren''t '
        se 'you?  We do not currently allow NEW Users & GUESTS to Play The Wheel of '
        tr 'Fortune, sorry"n1'
        se '"We will, however, show you how the current puzzle is doing, in case '
        tr 'you''d like to play after you''ve been validated.", Pat says.n1'
        call SHOWPUZZLE ; tr key2 ; signal QUIT2 ; end

    if Lflag=1 then do
        call WL("ca"||handle||" c6tried to play, but is the cdLast Playerc6!")
        se 'f1n1Pat laughs in your face and signals for a bouncer to '
        se 'throw you out of the studio. You were the last player and '
        tr 'must wait for someone else to play.n1'
    if chance=1 then do ; a=random(1,9) ; b=random(1,9) ; if a=b then do
            se 'n1As the bouncer approaches you, you kick him in the groin '
            se 'and run onto the studio set. Pat has no choice, but to let '
            tr 'you play again!n1'key1 ; Lhan='Bouncer in Agony!'
            call WL("ca"||handle||" c6beat up the cbBouncer c6to play again!")
            signal PLAYGAME2 ; end ; end
        se 'From over the bouncers shoulder, you get a glimpse of how '
        tr 'the current puzzle is doing...n1' ; call SHOWPUZZLE
        tr key2 ; signal QUIT2 ; end
PLAYGAME2:
    if puznum~=puzplay then do ; puznum=puzplay ; moncur=0
        if handle~=winhan then do ; played=played+1
            call WL("ca"||handle||" c6just ceentered c6this cbGamec6!")
            percent=((puzwon/played)*100)%1 ; end ; end

    if vanna=1 then do ; se 'f1n1Pat Sayjack welcomes you to the show, "How are you '||handle
    se '? Glad to have you on the show. Hey Vanna, lets see some cleavage, '
    tr 'errr, I mean, lets see the puzzle!"n1'
    tr left(spa,22)'o----------o  /   ////\\\ \      '
    tr left(spa,22)'|    /\    |  \   \|n | n|\\     '
    tr left(spa,22)'|   /--\   |   \   |  v  |\ \    '
    tr left(spa,22)'|  /    \  |    \   \_=_/\_\\\   '
    tr left(spa,22)'o----------o     \         \ \   '
    tr left(spa,22)'                  \/  /     \\   '
    tr left(spa,22)'  \  /            /\_/\_ \   \   '
    tr left(spa,22)'   \/ anna        \__\__\/\   \  '
    tr left(spa,22)'                     |     \   \ '
    tr left(spa,22)'                      \    /   / '
    tr key1 ; end

PLAY:
    if consonants=0 & vowels=0 then do ; solve=answer ; signal GUESSPUZZLE0 ; end
    if lo=0 then do ; lo=1
        if OLog=1 then tr 'f1Previous Game Log:n1*0'||dfile||'Log.OLD.ASC}c7n1'key1
        if NLog=1 then tr 'f1Current Game Log:n1*0'||dfile||'Log.NEW.ASC}c7n1'key1 ; end
    a=length(space(answer,0)) ; b=a-(consonants+vowels)
    if b/a>.50 & wh=1 then do ; tr 'n1Pat says, "We will now add $1000 to the Wheel!"'
        tr key1 ; wheel=wheal ; wh=2 ; end
    tr 'f1*==========================================================================*'
    tr '|>X<>X<>X<><><><>< >< >< >< > WHEEL OF FORTUNE < >< >< >< ><><><><>X<>X<>X<|'
    tr '*==========================================================================*'
    tr '                           Wheel Spots / Odds                               '
    if wh=1 then tr '      1-$750, 1-$600, 1-$500, 1-$450, 3-$400, 3-$300, 3-$250, 3-$200,'
    if wh=2 then tr '  1-$1000, 1-$750, 1-$600, 1-$500, 1-$450, 3-$400, 3-$300, 3-$250, 2-$200,'
    tr '      2-$150, 2-$100, 1-Free Spin, 1-Lose Turn, 1-Bankrupt, 1-Surprisen1'
    tr 'Current Puzzle Number: '||left(puznum,20)||'Last Player: '||Lhan
    tr 'Current Puzzle Author: '||left(author,20)||'Last Winner: '||winhan||'n1'
    se 'PLAYER: 'left(handle,16)' WINNINGS: $' ; call CNUM(moncur)
    se left(a,9)' PREVIOUS WINNINGS: $' ; call CNUM(monwon) ; tr a'n1'
    tr left(spa,20)'[S]pin the Wheel     [B]uy a Vowel'
    tr left(spa,20)'[G]uess the Puzzle   [Q]uit Playn1'
    call SHOWPUZZLE ; tr left(spa,33)'Free Spins: 'freespins'n1'
    if consonants>0 & vowels>0 then tr center('Good Luck!n1',81)
    if consonants=0 then tr center('There are ONLY Vowels left in this Puzzle!n1',81)
    if vowels=0 then tr center('There are NO MORE Vowels left in this Puzzle!n1',81)
    se '[Play] >>>--S,B,G,Q--> '
PLAY1:
    gc ; a=result ; call CHECK
    if index('SBGQ',a)=0 then do ; bf ; signal PLAY1 ; end
    if a='S' then do ; tr 'Spin Wheel'   ; signal SPINWHEEL   ; end
    if a='B' then do ; tr 'Buy Vowel'    ; signal BUYVOWEL    ; end
    if a='G' then do ; tr 'Guess Puzzle' ; signal GUESSPUZZLE ; end
    if a='Q' then do ; tr 'Quit Play'    ; signal MAIN        ; end

SPINWHEEL:
    if consonants=0 then do ; se 'n1Pat reminds you, "'||handle||', '
        tr 'remember, there are ONLY VOWELS left in this puzzle."'
        call WL("ca"||handle||" c6tried to cfSPIN c6with ceONLY VOWELS c6left!")
        tr key1 ; signal PLAY ; end
    a=random(25,60) ; sp=sp+a
    do until sp<30 ; sp=sp-25 ; end ; b=random(2,4)
    a=sp-b ; b=sp ; if a<1 then a=1 ; action='Played '
    do i=a to b ; ii=i ; if i>24 then ii=i-24 ; spot=word(wheel,ii)
        call D0 ; end i
    if c=12 then signal FREESPIN ; if c=13 then signal SURPRISE
    if c=14 then signal LOSETURN ; if c=15 then signal BANKRUPT
    a='100 150 200 250 300 400 450 500 600 750 1000' ; money=word(a,c)
    tr 'n1There is $'||money||' showing on the Wheel!n1'
SURPRISE0B:
    call SHOWPUZZLE ; se 'Type Your Guess: '
SPINWHEEL1:
    gc ; guess=result ; call CHECK ; bf ; se guess ; call CNUM(money)
    if index(cons,guess)=0 then do ; signal SPINWHEEL1 ; end
    log="c6With c2$ca"||a||" c6on cfThe Wheelc6, ca"||handle
    log=log||" c6guesses c9"||guess||"c6..." ; call WL(log)
    if index(guessed,guess)>0 then do
        call WL("c6Which was c9ALREADY cbGuessedc6!")
        se '  Consonant Already Guessed!!w1hfhf'
        signal SPINWHEEL1 ; end
    if index(answer,guess)>0 then do ; tr '  >>>---> GOOD GUESS!n1'
        g=guessed ; if g='' then g=guess ; else g=g||'-'||guess
        guessed=g ; call COUNT ; consonants=consonants-tot
        call UNCOVER ; Lhan=handle
        if tot=1 then call WL("c6There was ce1 c9"||guess||"c6 in the puzzle: "||puzzle)
        if tot>1 then call WL("c6There were ce"||tot||" c9"||guess||"c6's in the puzzle: "||puzzle)
        if index(cons,guess)>0 then moncur=moncur+(money*tot)
        if tot=1 then se left(spa,20)'There is 1 "'||guess||'" '
            else se left(spa,20)'There are '||tot||' "'||guess||'"''s '
        tr 'in the puzzle.n1'||key1 ; signal PLAY ; end
    if index(answer,guess)=0 then do ; tr '  >>>---> WRONG!!n1'
        g=guessed ; if g='' then g=guess ; else g=g||'-'||guess
        guessed=g ; Lhan=handle
        call WL("c6But there were cbNO c9"||guess||"c6's in the puzzle: "||guessed)
        if freespins=0 then do ; tr 'Awwww... Better Luck next time.'
            call WL("ca"||handle||" c6is cffinished c6for this turn.")
            call SAVEPLAYERS ; call SAVEDATA ; signal QUIT2 ; end
        tr 'But not to worry, You have a Free Spin!'
        call WL("c6However, ca"||handle||" c6has a cbFree Spinc6!")
        freespins=freespins-1 ; tr key1 ; signal PLAY ; end
FREESPIN:
    call WL("ca"||handle||" c6just landed on cbFREE SPINc6!")
    se 'n1Pat says, "Congratulations '||handle||', you now have a Free '
    tr 'Spin!"' ; freespins=freespins+1 ; tr key1
  signal PLAY
LOSETURN:
    call WL("ca"||handle||" c6just landed on cdLOSE A TURNc6!")
    se 'n1Frowning, Pat tells you, "Uh Oh '||handle||', looks like you '
    tr 'Lose a Turn."n1' ; if freespins>0 then do
        se '"That''s alright, however, because you still have a Free '
        tr 'Spin!", Pat says consolingly.' ; freespins=freespins-1
        call WL("c6However, ca"||handle||" c6has a cbFree Spinc6!")
        tr key1 ; signal PLAY ; end
    se '"That''s too bad, you weren''t doing all that bad. Well, you '
    tr 'can try again next call", Pat mumbles.' ; Lhan=handle
    call WL("ca"||handle||" c6is cffinished c6for this turn.")
    call SAVEPLAYERS ; call SAVEDATA ; signal QUIT2
BANKRUPT:
    call WL("ca"||handle||" c6just landed on c9BANKRUPTc6!") ; call CNUM(moncur)
    call WL("ca"||handle||" c6loses c2$ca"||a||" c6bucks!")
    se 'n1"BANKRUPT! Only one on the whole wheel, and '||handle||', you '
    tr 'just found it", Pat informs you.n1' ; moncur=0
    if freespins>0 then do
        tr '"Luckily you still have a Free Spin!", Pat praises.'
        call WL("c6However, ca"||handle||" c6has a cbFree Spinc6!")
        freespins=freespins-1 ; tr key1 ; signal PLAY ; end
    tr '"Hopefully you''ll do better next call!", Pat explains.'
    call WL("ca"||handle||" c6is cffinished c6for this turn.")
    Lhan=handle ; call SAVEPLAYERS ; call SAVEDATA ; signal QUIT2
SURPRISE:
    call WL("ca"||handle||" c6just landed on cfSURPRISEc6!")
    tr 'n1"Wow, SURPRISE!", Pat exclaims!'
    a=random(1,3) ; a='SURPRISE'||a ; signal (a)
SURPRISE1:
    call WL("ca"||handle||"c6's cfSURPRISE c6is a cbFREE SPINc6!")
    se 'n1"Well, '||handle||' your Surprise is a FREE SPIN!", Pat informs '
    tr 'you.' ; freespins=freespins+1 ; tr key1 ; signal PLAY
SURPRISE2:
    if vowels=0 then signal SURPRISE3
    call WL("ca"||handle||"c6's cfSURPRISE c6is a ceFREE VOWELc6!")
    se 'n1"Hey '||handle||', Congratulations, your SURPRISE is to '
    tr 'BUY a VOWEL for FREE!", Pat states.n1'
    moncur=moncur+250 ; signal SURPRISE0A
SURPRISE3:
    c=random(1000,1500) ; money=c ; call CNUM(money)
    call WL("ca"||handle||"c6's cfSURPRISE c6is c2$ca"||a||" c6on cfThe Wheelc6!")
    se 'n1Pulling out a white envelope, Pat opens it and says, "'||handle
    tr ', this next guess will be worth $'||a||' bucks! Good Luck!"n1'
  signal SURPRISE0B

BUYVOWEL:
    if vowels=0 then do ; se 'n1Pat reminds you, "'||handle||', '
        tr 'remember, there are ONLY CONSONANTS left in this puzzle."'
        call WL("ca"||handle||" c6tried to cfBUY A VOWEL c6with ceONLY CONSONANTS c6left!")
        tr key1 ; signal PLAY ; end
    if moncur<300 then do
        call WL("ca"||handle||" c6tried to ceBUY c6a cbVowel c6with only c2$ca"||moncur||"c6!")
        se 'n1Pat informs you Vowels Cost $250, and that you''ll '
        tr 'need at least $300 to buy one!n1'||key1 ; signal PLAY ; end
    se 'f1n4Turning towards you, Pat says, "'||handle||', enter the '
    tr 'VOWEL you wish to Guess. Remember, this will cost you $250!"n1'
SURPRISE0A:
    call SHOWPUZZLE ; action='Played ' ; se 'Type Your Guess: '
BUYVOWEL1:
    gc ; guess=result ; call CHECK ; bf ; se guess
    if index(vows,guess)=0 then do ; signal BUYVOWEL1 ; end
    call WL("ca"||handle||" ceBUYS c6the cbVowel c9"||guess||"c6...")
    if index(guessed,guess)>0 then do
        call WL("c6But that cbVowel c6was c9Already c6guessed!")
        se '  Vowel Already Guessed!!w1hfhb'
        signal BUYVOWEL1 ; end
    if index(answer,guess)>0 then do ; tr '  >>>---> GOOD GUESS!n1'
        g=guessed ; if g='' then g=guess ; else g=g||'-'||guess
        guessed=g ; call COUNT ; vowels=vowels-tot
        call UNCOVER ; moncur=moncur-250
        if tot=1 then call WL("c6There was ce1 c9"||guess||"c6 in the puzzle: "||puzzle)
        if tot>1 then call WL("c6There were ce"||tot||" c9"||guess||"c6's in the puzzle: "||puzzle)
        if tot=1 then se left(spa,20)'There is 1 "'||guess||'" '
            else se left(spa,20)'There are '||tot||' "'||guess||'"''s '
        tr 'in the puzzle.n1'||key1 ; signal PLAY ; end
    if index(answer,guess)=0 then do ; tr '  >>>---> WRONG!!n1'
        g=guessed ; if g='' then g=guess ; else g=g||'-'||guess
        guessed=g ; Lhan=handle ; moncur=moncur-250
        call WL("c6But there were cbNO c9"||guess||"c6's in the puzzle: "||guessed)
        if freespins=0 then do ; tr 'Awwww... Better luck next time.n1'
        call WL("ca"||handle||" c6is cffinished c6for this turn.")
            call SAVEPLAYERS ; call SAVEDATA ; signal QUIT2 ; end
        tr 'But not to worry, You have a Free Spin!'
        call WL("c6However, ca"||handle||" c6has a cbFree Spinc6!")
        freespins=freespins-1 ; tr key1 ; signal PLAY ; end

GUESSPUZZLE:
    if zero=0 & moncur<100 then do
        se 'n1Pat wipes his brow, then looks at you, "Sorry, '||handle
        se ', but you need more than $100 before you can attempt to GUESS '
        tr 'this puzzle!"n1'key1 ; signal PLAY ; end
    se 'f1n5Startled, Pat asks, "So, '||handle||', you think you know '
    tr 'this puzzle.  Well, good luck in guessing it!"n1'
    call WL("ca"||handle||" c6will try and cfSOLVE c6the puzzle...")
    call SHOWPUZZLE ; len=length(puzzle)
    tr 'n1Type your Guess below the Current Puzzle:n1'
    tr ' The Puzzle Now: 'translate(puzzle,hide,'@')
    tr 'Your Best Guess: i129 '||len||'}'
    gu 70 ; solve=result ; call CHECK
    if solve~=answer then do
        call WL("c6But, alas, more cbSTUDY c6is needed for this puzzle!")
        se 'n1Shaking his head, Pat tells you, "I''m sorry '||handle
        tr ', but that''s not the correct answer."n1'
        Lhan=handle ; if freespins=0 then do
            tr 'Awwww... Try again when a few more letters are showing.'
            call WL("ca"||handle||" c6is cffinished c6for this turn.")
            call SAVEPLAYERS ; call SAVEDATA ; signal QUIT2 ; end
        tr 'But not to worry, You have a Free Spin!'
        call WL("c6However, ca"||handle||" c6has a cbFree Spinc6!")
        freespins=freespins-1 ; tr key1 ; signal PLAY ; end
GUESSPUZZLE0:
    if solve=answer then do
        call WL("cfCongratulations c6to ca"||handle||" c6who just cbSOLVED c6the puzzle!")
        se 'f1n1Clapping his hands, Pat says, "Congratulations '||handle ; call CNUM(moncur)
        tr ', You''ve just won $'a' in CASH and PRIZES!"'
        if puPR>0 then do ; call CNUM(puVA)
            se 'n1For winning the game, '||sysop||' Broadcasting has decided '
            se 'to give you '||a||' '||pr.puPR||'!  Enjoy them!n1'
            if puPR=1 then addtime (puVA) ; if puPR=2 then addpoints (puVA)
            if puPR=3 then do ; gu 35 ; b=result ; b=b+puVA ; setobject (b) ; putuser 35 ; end
            if puPR=4 then do ; gu 34 ; b=result ; b=b+puVA ; setobject (b) ; putuser 34 ; end
            call WL("ca"||handle||" c6was awarded cf"||a||" c9"||pr.puPR||"c6 for solving this cfPuzzlec6!") ; end
        puzwon=puzwon+1 ; winhan=handle ; windate=date ; wins=puzwon
        winpuz=answer ; played=played+1 ; monwon=monwon+moncur
        winmon=monwon ; percent=((puzwon/played)*100)%1
        winner=winhan'|'winpuz'|'windate'|'winmon'|'wins'|x'
        winners=winners+1 ; winner.winners=winhan'|'winpuz'|'windate'|x'
        l.1='cc'||right('cf'||dateL,78,'=')||'cc===' ; l.2='cf  The Win Datec9: cb'dateL
        l.3='cf    The Puzzlec9: ce'||answer ; l.4='cf   Puzzle Cluec9: ca'||clue ; call CNUM(winmon)
        l.5='cf Puzzle Winnerc9: cd'||handle ; l.6='cfTotal Winningsc9:c2$ca'||a
        do i=1 to 6 ; call WL(l.i) ; end i ; if winners>max1 then do ; winners=max1
            do i=2 to max1+1 ; j=i-1 ; winner.j=winner.i ; end i ; end
        if played>mostplays then do ; se 'n1Pat says, "'||handle
            tr ', you broke the old MOST PLAYS Record!"'
            call WL("ce  A NEW RECORDc9: cfPlayed the caMOST cfTimes!")
            mostplaysH=winhan ; mostplays=played ; end
        if wins>mostpuzs then do ; se 'n1Pat says, "'||handle
            tr ', you broke the old MOST PUZZLES Record!"'
            call WL("ce  A NEW RECORDc9: cfWon the caMOST cfPuzzles!")
            mostpuzsH=winhan ; mostpuzs=wins ; end
        if monwon>mostbank then do ; se 'n1Pat says, "'||handle
            tr ', you broke the old MOST TOTAL WINNINGS Record!"'
            call WL("ce  A NEW RECORDc9: cfWon the caMOST cfBucks cdEVERcf!")
            mostbankH=winhan ; mostbank=monwon ; end
        if moncur>mostcash then do ; se 'n1Pat says, "'||handle
            tr ', you broke the old MOST WINNINGS Record!"'
            call WL("ce  A NEW RECORDc9: cfWon the caMOST cfBucks in cdONE GAMEcf!")
            mostcashH=winhan ; mostcash=moncur ; end
        stats.1=mostplaysH'|'mostplays'|x' ; stats.2=mostpuzsH'|'mostpuzs'|x'
        stats.3=mostbankH'|'mostbank'|x'   ; stats.4=mostcashH'|'mostcash'|x'
        call SAVEWINNERS ; call SAVEWINNER ; call SAVESTATS ; call SAVEPLAYERS
        call WL("c9"||right("ce"||dateL,78,'-')||"c9---") ; call BONUSROUND
        se 'n1Shaking your hand, Pat tells you, "As the newest Wheel of '
        tr 'Fortune Winner, you have to make a choice."n1'
        tr '    1: I want to enter the next puzzle.n1'
        tr '    2: Let '||bbsname||' Generate next puzzle.(DEFAULT)'
        tr '    (You''ll be able to play a GENERATED Puzzle!)n1'
        se 'What''s your choice, '||handle||'? ' ; gc ; a=result
        if a~='1' then signal GENERATE

MAKEPUZZLE:
    tr 'I''ll make it!'
    se '"OK, '||handle||', Please enter your Puzzle:", '
    tr 'Pat asks fervently.'
    tr 'Puzzle:i129 50}' ; gu 70 ; a=result ; a=strip(a,'b')
    if result='###PANIC' | result='' then signal GENERATE
    if length(a)<9 then do
        se 'Whispering in your ear, Vanna tells you that '
        se 'puzzle is too short.n1' ; signal MAKEPUZZLE ; end
    se '"'||a||'"Is this correct '||handle||'? (Y/n): '
    gc ; b=result ; if result='###PANIC' then signal GENERATE
    if b~='N' then do ; tr 'Yes!' ; newpuz=a ; end
    if b='N' then do ; se 'No. Try Againn1' ; signal MAKEPUZZLE ; end
    se '"Now enter a Clue for your Puzzle, '||handle||'", '
    tr 'Pat guides you.'
MAKECLUE:
    tr '  Clue:i129 20}' ; gu 70 ; a=result ; a=strip(a,'b')
    if result='###PANIC' | result='' then signal GENERATE
    if length(a)<3 then do
        se 'Pinching your butt, Vanna gives you the sign that '
        se 'your clue is too short.n1' ; signal MAKECLUE ; end
    se '"'||a||'"Is this correct '||handle||'? (Y/n): '
    gc ; b=result ; if result='###PANIC' then signal GENERATE
    if b~='N' then do ; tr 'Yes!' ; newclue=a ; end
    if b='N' then do ; se 'No. Try Againn1' ; signal MAKECLUE ; end
    author=handle ; a=exists(dfile||'NewPuz')
    if a=0 then call open(f1,dfile||'NewPuz','w')
    if a=1 then call open(f1,dfile||'NewPuz','a')
        z=newpuz'|'newclue'|'author'|x' ; call writeln(f1,z)
    call close(f1) ; call WL("ca"||handle||" c6decided to ceMAKE c6the next puzzle...")
  signal GENERATE2

GENERATE:
    tr 'Generate NEW Puzzle!'
    call open(f1,dfile||'PuzData','r') ; a=strip(readch(f1,5),'t',d2c(0))
        if nextpuznum>a then nextpuznum=1
        ptr=((nextpuznum*90)-90)+5 ; call seek(f1,ptr,'b')
        p=strip(readch(f1,50),'t',d2c(0)) ; c=strip(readch(f1,20),'t',d2c(0))
        a=strip(readch(f1,20),'t',d2c(0)) ; call close(f1) ; nextpuznum=nextpuznum+1
    newpuz=translate(p,reverse(xrange('!','~')),xrange('!','~'))
    newclue=translate(c,reverse(xrange('!','~')),xrange('!','~'))
    author=translate(a,reverse(xrange('!','~')),xrange('!','~'))
    call WL("ca"||handle||" c6decided to let ce"||bbsname||" c6choose the next puzzle...")

GENERATE2:
    puzplay=puzplay+1 ; consonants=0 ; vowels=0 ; guessed=''
    do i=1 to length(newpuz) ; z=substr(newpuz,i,1)
        if index(cons,z)>0 then consonants=consonants+1
        if index(vows,z)>0 then vowels=vowels+1
    end i ; answer=newpuz ; Lhan='No One' ; clue=newclue
    puzzle=translate(answer,,xrange('A','Z'),'@') ; call SAVELOG
    if exists(dfile||'Log.OLD.ASC') then se '$odelete '||dfile||'Log.OLD.ASC}$orename '||dfile||'Log.NEW.ASC '||dfile||'Log.OLD.ASC}'
    if exists(dfile||'Log.OLD.ANS') then se '$odelete '||dfile||'Log.OLD.ANS}$orename '||dfile||'Log.NEW.ANS '||dfile||'Log.OLD.ANS}'
    if exists(dfile||'Log.OLD.IBM') then se '$odelete '||dfile||'Log.OLD.IBM}$orename '||dfile||'Log.NEW.IBM '||dfile||'Log.OLD.IBM}'
    call open(f1,dfile||'LastPlayer','w') ; call writeln(f1,'0|No One|No Where|0|0|x') ; call close(f1)
    log.1='cfNEW cbGame c6Started Onc9: cb'||dateL
    log.2='cf     The NEW Puzzlec9: ce'||puzzle ; log.3='cf    NEW Puzzle Cluec9: ca'||clue
    log.4='cf  NEW Puzzle Authorc9: cd'||author ; log.5='cc'||right('cf'||dateL,78,'=')||'cc==='
    logs=5 ; call SAVELOG ; se 'n1Pat & Vanna would like to Thank You for playing '
    se 'Wheel of Fortune today, and hope to see you as a contestant '
    tr 'again someday!' ; aut=author ; call SAVEDATA
    if play=1 & handle~=aut then do
        se 'n1Pat asks, "Would you like to be the FIRST player of the '
        se 'NEW Game 'handle'?"(y/N): '
        gc ; a=result ; if a='Y' then do ; tr 'Yes!' ; signal BEGIN ; end
        else tr 'No.' ; end
    changewhere oldwh ; if exists(dfile||'Reg.ASC') then tr 'f1*0'||dfile||'Reg.ASC}'
  exit

BONUSROUND:
    call WL("ca"||handle||" c6is eligible to play the cfBONUS Roundc6...")
    se 'n1Would YOU like to Play the Bonus Round? [Yes]: ' ; gc ; a=result
    if a='N' then do ; tr 'No.' ; call WL("c6But ca"||handle||" c9declinesc6 playing! Why?!?") ; tr 'f1' ; return ; end
    tr 'Yes!' ; call WL("cfAlrightc6, ca"||handle||" c6accepts the challenge...") ; changewhere 'WOF, v6.0 BONUS'
    call open(f1,dfile||'PuzData','r') ; a=strip(readch(f1,5),'t',d2c(0))
        if nextbonpuz<1 then nextbonpuz=a ; npn=nextbonpuz
        do until length(p)>=minB ; ptr=((npn*90)-90)+5 ; call seek(f1,ptr,'b')
        p=strip(readch(f1,50),'t',d2c(0)) ; npn=npn-1 ; end
        c=strip(readch(f1,20),'t',d2c(0)) ; a=strip(readch(f1,20),'t',d2c(0))
    call close(f1) ; newpuz=translate(p,reverse(xrange('!','~')),xrange('!','~'))
    newclue=translate(c,reverse(xrange('!','~')),xrange('!','~')) ; answer=newpuz
    author=translate(a,reverse(xrange('!','~')),xrange('!','~')) ; clue=newclue
    puzzle=translate(answer,,xrange('A','Z'),'@') ; len=length(puzzle)
    prize=random(100,500)*100 ; call CNUM(prize) ; let='RSTNLE'
    tr 'f1     o----------------------------------------------------------------o'
    tr '     |>X<>X<>X<>X<>X<>X< Welcome to the Bonus Round >X<>X<>X<>X<>X<>X<|'
    tr '     o----------------------------------------------------------------on1'
    se 'Pat explains the Bonus Round, "You''ll be trying to solve a puzzle in a '
    se 'set amount of time.  We''ll give you the letters R, S, T, N, L, and E.  '
    se 'You will also be asked for two(2) more consonants, and one(1) more vowel. '
    se 'If you can solve the Bonus Puzzle before time runs out, you''ll win '
    tr 'today''s Cash Prize of $'||a||' bucks!"n1'
    tr '    The Bonus Puzzle: 'translate(puzzle,Hide,'@')'n1'
    tr '      The Bonus Clue: 'clue
    do ii=1 to 6 ; guess=substr(let,ii,1) ; call UNCOVER ; end ii
BROUND1:
    se 'n1Enter two(2) more consonants:i129 2}' ; gu 70 ; a=result ; a1=left(a,1) ; a2=right(a,1)
    if smart=1 & index(let,a1)~=0 then tr 'n1The consonant 'a1' was already given to you.'
    if smart=1 & index(let,a2)~=0 then tr 'n1The consonant 'a2' was already given to you.'
    if smart=1 & (index(let,a1)~=0 | index(let,a2)~=0) then signal BROUND1
BROUND2:
    se 'n1Enter one(1) more  vowel now:i129 1}' ; gu 70 ; a3=result
    if smart=1 & index(let,a3)~=0 then do ; tr 'n1The vowel 'a3' was already given to you.' ; signal BROUND2 ; end
    do ii=1 to 3 ; guess=substr(a1||a2||a3,ii,1) ; call UNCOVER ; end ii
    se 'n1Vanna nudges Pat to bring him out of his stupor, "Alright, '||handle||', '
    tr 'press any key when you''re ready to start the Bonus Round!"n1'key1
    tr 'f1    o------------------------------------------------------------------o'
    tr '    |>X<>X<>X<>X<>X<>X< Can You Win the Bonus Round? >X<>X<>X<>X<>X<>X<|'
    tr '    o------------------------------------------------------------------on1'
    se ' The Bonus Prize is: $' ; call CNUM(prize) ; tr a' bucks!n1'
    tr 'Bonus Letters Given: R-S-T-N-L-E-'left(a1,1)'-'right(a1,1)'-'a2'n1'
    tr '  The Bonus Clue is: 'clue'n1'
    tr 'The Bonus Puzzle is: 'translate(puzzle,hide,'@')'n1'
    se 'Your Bonus Guess is: _ ' ; z='' ; zz='' ; t=timer*2
GUESS:
    maygetchar ; a=result ; if t<=0 then do ; bf ; signal OUTOFTIME ; end
    if a='NOCHAR' then do ; t=t-1 ; signal GUESS ; end ; if a=d2c(8) & z='' then signal GUESS
    if a=d2c(8)  & z~='' then do ; z=left(z,length(z)-1) ; se 'h3_ ' ; t=t-1 ; signal GUESS ; end
    if a=d2c(13) & z=answer then signal GOODGUESS ; if a=d2c(13) & z~=answer then signal BADGUESS
    zz=upper(a) ; z=z||zz ; se 'h2'zz'_ ' ; t=t-1 ; signal GUESS

OUTOFTIME:
    call WL("ca"||handle||" c9ran out of time c6in the cfBonus Roundc6!")
    se 'n2Pat looks at Vanna and frowns, "I''m sorry '||handle||', but '
    se 'time has run out.  Hopefully, we''ll see you in another Bonus '
    tr 'Round sometime soon!"n1'key1 ; tr 'f1'
  signal ENDBONUS

GOODGUESS:
    call WL("cfCongratulations c6to ca"||handle||" c6who just cbSOLVED c6the cfBONUS Puzzlec6!")
    se 'n2Jumping up and down, you grab Vanna in a bear hug and she squeals. '
    se 'Pat confronts you, "Calm down '||handle||', great job, you solved '
    se 'today''s Bonus Puzzle, and win $' ; call CNUM(prize) ; tr a' bucks doing it!"n1'key1
    if bpPR>0 then do ; call CNUM(bpVA)
        se 'n1For solving the BONUS Puzzle, '||sysop||' Broadcasting has decided '
        se 'to give you '||a||' '||pr.bpPR||'!  Enjoy them!n1'key1
        if bpPR=1 then addtime (bpVA) ; if bpPR=2 then addpoints (bpVA)
        if bpPR=3 then do ; gu 35 ; b=result ; b=b+bpVA ; setobject (b) ; putuser 35 ; end
        if bpPR=4 then do ; gu 34 ; b=result ; b=b+bpVA ; setobject (b) ; putuser 34 ; end
        call WL("ca"||handle||" c6was awarded cf"||a||" c9"||pr.bpPR||"c6 for solving the ceBonus Puzzlec6!") ; end
    bonwins=bonwins+1 ; boncash=boncash+prize ; tr 'f1'
    if bonwins>mostbwins then do ; se 'n1Pat says, "'||handle
        tr ', you broke the old MOST BONUS WINS Record!"'
        call WL('ce  A NEW RECORDc9: cfWon the caMOST BONUS GAMES cdEVERcf!')
        mostbwinsH=handle ; mostbwins=bonwins ; end
    if boncash>mostbcash then do ; se 'n1Pat says, "'||handle
        tr ', you broke the old MOST BONUS CASH Record!"'
        call WL('ce  A NEW RECORDc9: cfWon the caMOST BONUS CASH cdEVERcf!')
        mostbcashH=handle ; mostbcash=boncash ; end
    stats.5=mostbwinsH'|'mostbwins'|x' ; stats.6=mostbcashH'|'mostbcash'|x'
    bwinner=handle'|'answer'|'date'|'prize'|'bonwins'|x' ; bwinners=bwinners+1
    bwinner.bwinners=handle'|'answer'|'date'|'prize'|x' ; if bwinners>max2 then do
        do i=2 to max2+1 ; j=i-1 ; bwinner.j=bwinner.i ; end i ; bwinners=max2 ; end
    call SAVESTATS ; call SAVEBWINNER ; call SAVEBWINNERS ; call SAVEPLAYERS
  signal ENDBONUS

BADGUESS:
    call WL("ca"||handle||" c9incorrectly guessed c6the cfBonus Puzzlec6!")
    se 'n2Looking at the white card in his hand, Pat walks over to you, "I''m '
    se 'sorry '||handle||', but that''s an incorrect guess of this Bonus '
    tr 'Puzzle. Better luck next time, eh?"n1'key1 ; tr 'f1'
  signal ENDBONUS

ENDBONUS:
    call READDATA ; nextbonpuz=npn-1 ; call SAVEDATA ; changewhere 'WOF, v6.0 ASC!'
  return

CANCELGAME: /* SysOp Command; Cancels & AutoGenerates a NEW Game */
    tr 'n1Pat asks, "You really want to CANCEL this Game?"' ; se '(y/N) >>>---> '
    gc ; a=result ; if a~='Y' then do ; tr 'No!' ; signal MAIN ; end
    call WL("z4cf   "||sysop||" has decided to c9CANCEL cfthis game! (Errors?)  z0n1")
    call WL("cf     The Puzzle Wasc9: ce"||puzzle||"n1")
    call WL("cf     The Answer Wasc9: ca"||answer||"n1")
    tr 'Yes!' ; signal GENERATE

COUNT:
    tot=0 ; len=length(answer)
    do i=1 to len ; a=substr(answer,i,1)
    if guess=a then tot=tot+1 ; end i
  return

UNCOVER:
    do i=1 to len ; z=substr(answer,i,1)
    if guess=z then puzzle=overlay(guess,puzzle,i,1) ; end i
  return

SHOWPUZZLE:
    tr ' Current Puzzle: 'translate(puzzle,Hide,'@')
    tr '    Puzzle Clue: 'clue
    tr 'Guessed Letters: 'guessed
  return

CNUM: /* Comma Number Parser (Place commas inside numbers) */
    parse arg a ; b=length(a) ; if b=4 then a=insert(',',a,1,1)
    if b=5 then a=insert(',',a,2,1) ; if b=6 then a=insert(',',a,3,1)
    if b=7 then do ; a=insert(',',a,1,1) ; a=insert(',',a,5,1) ; end
  return

SAVELASTPLAYER:
    a=sid'|'handle'|'street'|'voice'|'data'|x'
    call open(f1,dfile||'LastPlayer','w') ; call writeln(f1,a) ; call close(f1)
  return

READLASTPLAYER:
    call open(f1,dfile||'LastPlayer','r') ; a=readln(f1) ; call close(f1)
    parse var a Lsid'|'Lhan'|'Lstr'|'Lvoi'|'Ldat'|'j ; Lflag=0 ; Mflag=0
    if sid=Lsid | handle=Lhan | street=Lstr | voice=Lvoi | data=Ldata then Lflag=1
    if maint=1 & sid=1 then Mflag=1 ; if maint=2 & access=23 then Mflag=1
    if maint=3 & access=31 then Mflag=1 ; if maint=4 & maintA>0 then Mflag=1
  return

WL: ; parse arg log ; logs=logs+1 ; log.logs=log ; return

SAVELOG:
    a='ANS IBM ASC' ; se 'n1Updating logs...'
    do i=1 to 3 ; b=subword(a,i,1) ; f='Log.NEW.'||b
        call open(f1,dfile||f,substr('wa',exists(dfile||f)+1,1))
            do j=1 to logs ; if i=1 then call writeln(f1,log.j)
                if i=2 then call writeln(f1,translate(log.j,'ÄÍ','-='))
                if i=3 then do ; do until c=0 ; c=index(log.j,'')
                    if c>0 then log.j=delstr(log.j,c,3) ; end ; call writeln(f1,log.j) ; end
            end j ; call close(f1) ; end i ; tr 'hbed!'
  return

HOFAME:
    call WL("ca"||handle||" c6viewed the cfHALL OF FAMEc6!")
    tr 'f1n1Pat says, "Here are the High Scores '||handle||'!"n1'
    tr right(mostplaysH,16)' played  Most Games EVER; 'mostplays' total!' ; call CNUM(mostbank)
    tr right(mostbankH,16)' won the Most Money EVER; $'a' bucks!'
    tr right(mostpuzsH,16)' won the Most Games EVER; 'mostpuzs' total!' ; call CNUM(mostcash)
    tr right(mostcashH,16)' won the Most Money In 1  Game; $'a' bucks!'
    tr right(mostbwinsH,16)' won the Most BONUS Games EVER; 'mostbwins' total!' ; call CNUM(mostbcash)
    tr right(mostbcashH,16)' won the Most BONUS Cash  EVER; $'a' bucks!'
    tr key1
  return

YOURSTATS:
    call WL("ca"||handle||" c6viewed current cbGAME STATSc6!")
    tr 'f1n1Pat says, "Here are your stats '||handle||'!"n1' ; call CNUM(monwon)
    tr 'You have won '||puzwon||' Games, for a total of $'||a||' bucks!'
    tr 'You are currently playing Puzzle Number '||puznum||'.'
    tr 'You have played Wheel of Fortune 'played' times.'
    tr 'You solved the puzzle 'percent'% of the times you played!'
    tr 'You have won the BONUS Round 'bonwins' times.' ; call CNUM(boncash)
    tr 'You have won $'a' bucks in BONUS Rounds!n1'key1
  return

ALLSCORES:
    call WL("ca"||handle||" c6viewed cdALL PLAYER SCORESc6!")
    tr 'f1n1Pat says, "Here are ALL of the Scores '||handle||'!!"n1'
    tr ' Wheel of Fortune     Total     Money  Play   Money  Max  Win Bonus     Bonus '
    tr ' Player Alias(Handle)  Wins    Earned  Puz#     Now Play    %  Wins  Earnings '
    tr '=============================================================================='
    parse var player.player d1'|'d2'|'d3'|'d4'|'d5'|'d6'|'d7'|'d8'|'d9'|'j
    call CNUM(d3) ; a1=a ; call CNUM(d5) ; a2=a ; call CNUM(d9) ; a3=a
    se '*'||right(d1,20)||'  '||right(d2,4)||'  '||right('$'||a1,8)||'  '||right(d4,4)||' '
    tr right('$'||a2,7)||' '||right(d6,4)||' 'right(d7||'%',4)||'  '||right(d8,4)||'  '||right('$'||a3,8)||' '
    do i=1 to players ; if i=player then z='*' ; else z=' '
        parse var player.i d1'|'d2'|'d3'|'d4'|'d5'|'d6'|'d7'|'d8'|'d9'|'j
        call CNUM(d3) ; a1=a ; call CNUM(d5) ; a2=a ; call CNUM(d9) ; a3=a
        se z||right(d1,20)||'  '||right(d2,4)||'  '||right('$'||a1,8)||'  '
        se right(d4,4)||' '||right('$'||a2,7)||' '||right(d6,4)||' '||right(d7||'%',4)
        tr '  '||right(d8,4)||'  '||right('$'||a3,8)||' ' ; if i//15=0 then do
        se '>>>--Enter-->' ; gc ; a=result ; if a=d2c(13) then se 'hd'
        else do ; tr ' Abort' ; leave i ; end ; end ; end i
    tr '==============================================================================n1'key1
  return

LASTPUZS:
    call WL("ca"||handle||" c6viewed the ceLAST "||max1||" WINNERSc6!")
    tr 'f1n1Pat says, "Here are the Last '||max1||' Winners, '||handle||'!"n1'
    do i=1 to winners ; d1=windate.i
        d=date('m',d1,'s')||' '||strip(right(d1,2),'l','0')||', '||left(d1,4)
        tr winhan.i||' solved '||winpuz.i||' on '||d||'.'
    end i ; tr key1
  return

BONUSPUZS: /* Display Last "max2" Bonus Puzzles */
    call WL("ca"||handle||" c6viewed the ceLAST "||max2||" BONUS WINNERSc6!")
    tr 'f1n1Pat says, "Here are the Last '||max2||' Bonus Puzzle Winners, '||handle||'!"n1'
    do i=1 to bwinners ; d1=bwindate.i ; call CNUM(bwincash.i)
        d=date('m',d1,'s')||' '||strip(right(d1,2),'l','0')||', '||left(d1,4)
        tr bwinhan.i||' solved '||bwinpuz.i||' on '||d||', and won $'||a||' bucks!'
    end i ; tr key1
  return

DOCS:
    call WL("ca"||handle||" c6viewed the ccINSTRUCTIONSc6!")
    tr 'f1*0'||dfile||'Docs.ASC}'
  return

CHECK:
    if result~='###PANIC' then return
    tr 'No Carrier!' ; logentry 'No Carrier in WOF, v6.0!'
    call WL("ca"||handle||" c9Lost Carrier c6during the game!")
  signal QUIT2

QUIT:
    se 'n1You really wish to QUIT? (Y/n): '
    gc ; a=result ; if a='N' then do ; tr 'No.' ; return ; end
    tr 'Yes!' ; call SAVEPLAYERS ; call SAVEDATA
QUIT2:
    call WL("ca"||handle||" cf"||action||"cbWheel of Fortune, v6.0!")
    call WL("c9"||right('ce'||dateL,78,'-')||'c9---')
    logentry action'Wheel of Fortune, v6.0!'
    if exists(dfile||'Reg.ASC') then tr 'f1*0'||dfile||'Reg.ASC}'
    if Lhan=handle then call SAVELASTPLAYER
    call SAVELOG ; bf ; changewhere oldwh
  exit

MENU: /* Main Menu for Wheel of Fortune */
    tr 'f1n1     O-----------------------------------------------------------------O'
    tr '     | Version 6.0b                                  November 30, 1993 |'
    tr '     |                                                                 |'
    a=copies('>X<',10)||' The Wheel Of Fortune Main Menu! '||copies('>X<',10)
    tr '     |'center(a,65)'|'
    tr '     |                                                                 |'
    tr '     |  Completely ReWritten by: Dotoran of Frontiers (716)/823-9892!  |'
    tr '     |                                                                 |'
    a=copies('>X<',10)||' '||bbsname||' '||copies('>X<',10)
    tr '     |'center(a,65)'|'
    tr '     |                                                                 |'
    tr '     |    <H>all of Fame        <P>lay WOF Game      <O>ld Game Log    |'
    tr '     |    <Y>our Game Stats     <L>ast '||left(max1||' Puzzles',10)||'    <N>ew Game Log    |'
    tr '     |    <A>ll Player Stats    <B>onus Puzzles      <I>nstructions    |'
    if Mflag=1 then tr '     |    <C>ancel This Game    <E>rrors Listing     <M>aintenance!    |'
    tr '     |                                                                 |'
    tr '     O-----------------------------------------------------------------On1'
    tr left(spa,25)'<Q>uit Wheel of Fortune Gamen1'
    tr left(spa,25)'The Last Player Was: 'Lhan
  return

READCONFIG: /* Read "ConfigData" File. Holds info on game settings. */
    call open(f1,'pfiles:WoFortune.Config','r')
        do 2 ; j=readln(f1) ; end ; dfile=readln(f1) ; j=readln(f1)
        a1=readln(f1) ; a2=readln(f1) ; do 4 ; j=readln(f1) ; end
        parse var a1 m1'|'k1'|'j ; parse var a2 m2'|'k2'|'j ; a3=readln(f1)
        parse var a3 OLog'|'NLog'|'Play'|'hide'|'j'|'j'|'spin'|'j'|'timer'|',
                     zero'|'max1'|'max2'|'minB'|'vanna'|'maint'|'chance'|',
                     smart'|'newplay'|'sp96'|'sp14'|'puPR'|'puVA'|'bpPR'|',
                     bpVA'|'j
    call close(f1) ; call open(f1,dfile||'PuzData','r')
    total=strip(readch(f1,5),'t',d2c(0)) ; call close(f1)
    pr.1='Extra Minutes' ; pr.2='Game Points' ; pr.3='Byte Credits' ; pr.4='File Credits'
  return

READDATA: /* Read "GameData" File. Holds info on current game. */
    call open(f1,dfile||'GameData','r') ; puzplay=readln(f1)
        puzzle=readln(f1) ; answer=readln(f1) ; guessed=readln(f1)
        clue=readln(f1)   ; data1=readln(f1)  ; data2=readln(f1)
    call close(f1) ; parse var data1 author'|'nextpuznum'|'nextbonpuz'|'j
    parse var data2 consonants'|'vowels'|'j
    puzzle=translate(puzzle,reverse(xrange('!','~')),xrange('!','~'))
    answer=translate(answer,reverse(xrange('!','~')),xrange('!','~'))
    author=translate(author,reverse(xrange('!','~')),xrange('!','~'))
    clue=translate(clue,reverse(xrange('!','~')),xrange('!','~'))
  return

SAVEDATA: /* Save "GameData" File. */
    puzzle=translate(puzzle,reverse(xrange('!','~')),xrange('!','~'))
    answer=translate(answer,reverse(xrange('!','~')),xrange('!','~'))
    author=translate(author,reverse(xrange('!','~')),xrange('!','~'))
    clue=translate(clue,reverse(xrange('!','~')),xrange('!','~'))
    data1=author'|'nextpuznum'|'nextbonpuz'|x' ; data2=consonants'|'vowels'|x'
    call open(f1,dfile||'GameData','w') ; call writeln(f1,puzplay)
        call writeln(f1,puzzle)  ; call writeln(f1,answer)
        call writeln(f1,guessed) ; call writeln(f1,clue)
        call writeln(f1,data1)   ; call writeln(f1,data2)
    call close(f1)
  return

READBWINNERS: /* Read "BWinners" File. The Past 20 Winners. */
    call open(f1,dfile||'BWinners','r')
        do i=1 until eof(f1) ; bwinner.i=readln(f1)
            parse var bwinner.i bwinhan.i'|'bwinpuz.i'|'bwindate.i'|'bwincash.i'|'j
        end i ; bwinners=i-1
    call close(f1)
  return

SAVEBWINNERS: /* Save "BWinners" File. */
    call open(f1,dfile||'BWinners','w')
        do i=1 to bwinners ; call writeln(f1,bwinner.i) ; end i
    call close(f1)
  return

READWINNERS: /* Read "Winners" File. The Past 20 Winners. */
    call open(f1,dfile||'Winners','r')
        do i=1 until eof(f1) ; winner.i=readln(f1)
            parse var winner.i winhan.i'|'winpuz.i'|'windate.i'|'j
        end i ; winners=i-1
    call close(f1)
  return

SAVEWINNERS: /* Save "Winners" File. */
    call open(f1,dfile||'Winners','w')
        do i=1 to winners ; call writeln(f1,winner.i) ; end i
    call close(f1)
  return

SAVEBWINNER: /* Save "BWinner" File. */
    call open(f1,dfile||'BWinner','w')
        call writeln(f1,bwinner)
    call close(f1)
  return

READWINNER: /* Read "Winner" File. Who was the LAST Winner? */
    call open(f1,dfile||'Winner','r')
        winner=readln(f1)
    call close(f1)
    parse var winner winhan'|'winpuz'|'windate'|'winmon'|'wins'|'j
  return

SAVEWINNER: /* Save "Winner" File. */
    call open(f1,dfile||'Winner','w')
        call writeln(f1,winner)
    call close(f1)
  return

READSTATS: /* Read "Stats" File & Initialize These Variables. */
    call open(f1,dfile||'Stats','r')
        do i=1 to 6 ; stats.i=readln(f1) ; end i
    call close(f1)
    parse var stats.1 mostplaysH'|'mostplays'|'j
    parse var stats.2 mostpuzsH'|'mostpuzs'|'j
    parse var stats.3 mostbankH'|'mostbank'|'j
    parse var stats.4 mostcashH'|'mostcash'|'j
    parse var stats.5 mostbwinsH'|'mostbwins'|'j
    parse var stats.6 mostbcashH'|'mostbcash'|'j
  return

SAVESTATS: /* Save "Stats" File. */
    call open(f1,dfile||'Stats','w')
        do i=1 to 6 ; call writeln(f1,stats.i) ; end i
    call close(f1)
  return

READPLAYERS: /* Read "Players" File & Mark Current Player if Exists. */
    call open(f1,dfile||'Players','r') ; player=0
        do i=1 until eof(f1) ; player.i=readln(f1)
            parse var player.i han'|'j
            if han=handle then player=i
        end i ; players=i-1
    call close(f1)
  return

SAVEPLAYERS: /* Save "Players" File. */
    player.player=handle'|'puzwon'|'monwon'|'puznum'|'moncur'|'played'|'percent'|'bonwins'|'boncash'|x'
    call open(f1,dfile||'Players','w')
        do i=1 to players ; call writeln(f1,player.i) ; end i
    call close(f1) ; address command "sort "||dfile||"Players "||dfile||"Players"
  return

SETUP:
    tr '#0'||dfile||'SetUp}c7' ; return

D0: /* Call The Correct Wheel Graphic Location */
    b='D'||spot ; c=spot ; se 'f1' ; signal (b)
D1: /* 100 */
    tr '                   ______o=========================o______'
    tr '                  /            *    ****    ****          \'
    tr '                 ||           **   *    *  *    *         ||'
    tr '                 ||            *   *    *  *    *         ||'
    tr '                 ||            *   * |\ *  *    *         ||'
    tr '                  \_          ***   *|||    ****         _/'
    tr '                    \o===============| \\==============o/'
    tr '                      \_             | ||            _/'
    tr '                        \_           | ||          _/'
    tr '                          \_         | ||        _/'
    tr '                            \_       | ||      _/'
    tr '                              \_     | ||    _/'
    tr '                                \_   | ||  _/'
    tr '                                  \_ | ||_/'
    tr '                                    \|_|/'
  return
D2: /* 150 */
    tr '                   ______o=========================o______'
    tr '                  /            *   ******   ****          \'
    tr '                 ||           **   *       *    *         ||'
    tr '                 ||            *   *****   *    *         ||'
    tr '                 ||            *     |\ *  *    *         ||'
    tr '                  \_          ***  **|||    ****         _/'
    tr '                    \o===============| \\==============o/'
    tr '                      \_             | ||            _/'
    tr '                        \_           | ||          _/'
    tr '                          \_         | ||        _/'
    tr '                            \_       | ||      _/'
    tr '                              \_     | ||    _/'
    tr '                                \_   | ||  _/'
    tr '                                  \_ | ||_/'
    tr '                                    \|_|/'
  return
D3: /* 200 */
    tr '                   ______o=========================o______'
    tr '                  /         ****    ****    ****          \'
    tr '                 ||             *  *    *  *    *         ||'
    tr '                 ||          ***   *    *  *    *         ||'
    tr '                 ||         *      * |\ *  *    *         ||'
    tr '                  \_        *****   *|||    ****         _/'
    tr '                    \o===============| \\==============o/'
    tr '                      \_             | ||            _/'
    tr '                        \_           | ||          _/'
    tr '                          \_         | ||        _/'
    tr '                            \_       | ||      _/'
    tr '                              \_     | ||    _/'
    tr '                                \_   | ||  _/'
    tr '                                  \_ | ||_/'
    tr '                                    \|_|/'
  return
D4: /* 250 */
    tr '                   ______o=========================o______'
    tr '                  /         ****   *****    ****          \'
    tr '                 ||             *  *       *    *         ||'
    tr '                 ||          ***   *****   *    *         ||'
    tr '                 ||         *        |\ *  *    *         ||'
    tr '                  \_        *****  **|||    ****         _/'
    tr '                    \o===============| \\==============o/'
    tr '                      \_             | ||            _/'
    tr '                        \_           | ||          _/'
    tr '                          \_         | ||        _/'
    tr '                            \_       | ||      _/'
    tr '                              \_     | ||    _/'
    tr '                                \_   | ||  _/'
    tr '                                  \_ | ||_/'
    tr '                                    \|_|/'
  return
D5: /* 300 */
    tr '                   ______o=========================o______'
    tr '                  /         ****    ****    ****          \'
    tr '                 ||             *  *    *  *    *         ||'
    tr '                 ||          ***   *    *  *    *         ||'
    tr '                 ||             *  * |\ *  *    *         ||'
    tr '                  \_        ****    *|||    ****         _/'
    tr '                    \o===============| \\==============o/'
    tr '                      \_             | ||            _/'
    tr '                        \_           | ||          _/'
    tr '                          \_         | ||        _/'
    tr '                            \_       | ||      _/'
    tr '                              \_     | ||    _/'
    tr '                                \_   | ||  _/'
    tr '                                  \_ | ||_/'
    tr '                                    \|_|/'
  return
D6: /* 400 */
    tr '                   ______o=========================o______'
    tr '                  /         *   *   ****    ****          \'
    tr '                 ||         *   *  *    *  *    *         ||'
    tr '                 ||         *****  *    *  *    *         ||'
    tr '                 ||             *  * |\ *  *    *         ||'
    tr '                  \_            *   *|||    ****         _/'
    tr '                    \o===============| \\==============o/'
    tr '                      \_             | ||            _/'
    tr '                        \_           | ||          _/'
    tr '                          \_         | ||        _/'
    tr '                            \_       | ||      _/'
    tr '                              \_     | ||    _/'
    tr '                                \_   | ||  _/'
    tr '                                  \_ | ||_/'
    tr '                                    \|_|/'
  return
D7: /* 450 */
    tr '                   ______o=========================o______'
    tr '                  /         *   *  *****    ****          \'
    tr '                 ||         *   *  *       *    *         ||'
    tr '                 ||         *****  *****   *    *         ||'
    tr '                 ||             *    |\ *  *    *         ||'
    tr '                  \_            *  **|||    ****         _/'
    tr '                    \o===============| \\==============o/'
    tr '                      \_             | ||            _/'
    tr '                        \_           | ||          _/'
    tr '                          \_         | ||        _/'
    tr '                            \_       | ||      _/'
    tr '                              \_     | ||    _/'
    tr '                                \_   | ||  _/'
    tr '                                  \_ | ||_/'
    tr '                                    \|_|/'
  return
D8: /* 500 */
    tr '                   ______o=========================o______'
    tr '                  /         *****   ****    ****          \'
    tr '                 ||         *      *    *  *    *         ||'
    tr '                 ||         ****   *    *  *    *         ||'
    tr '                 ||             *  * |\ *  *    *         ||'
    tr '                  \_        ****    *|||    ****         _/'
    tr '                    \o===============| \\==============o/'
    tr '                      \_             | ||            _/'
    tr '                        \_           | ||          _/'
    tr '                          \_         | ||        _/'
    tr '                            \_       | ||      _/'
    tr '                              \_     | ||    _/'
    tr '                                \_   | ||  _/'
    tr '                                  \_ | ||_/'
    tr '                                    \|_|/'
  return
D9: /* 600 */
    tr '                   ______o=========================o______'
    tr '                  /           ***   ****    ****          \'
    tr '                 ||          *     *    *  *    *         ||'
    tr '                 ||         ****   *    *  *    *         ||'
    tr '                 ||         *   *  * |\ *  *    *         ||'
    tr '                  \_         ***    *|||    ****         _/'
    tr '                    \o===============| \\==============o/'
    tr '                      \_             | ||            _/'
    tr '                        \_           | ||          _/'
    tr '                          \_         | ||        _/'
    tr '                            \_       | ||      _/'
    tr '                              \_     | ||    _/'
    tr '                                \_   | ||  _/'
    tr '                                  \_ | ||_/'
    tr '                                    \|_|/'
  return
D10: /* 750 */
    tr '                   ______o=========================o______'
    tr '                  /         *****  *****    ****          \'
    tr '                 ||             *  *       *    *         ||'
    tr '                 ||            *   *****   *    *         ||'
    tr '                 ||           *      |\ *  *    *         ||'
    tr '                  \_         *     **|||    ****         _/'
    tr '                    \o===============| \\==============o/'
    tr '                      \_             | ||            _/'
    tr '                        \_           | ||          _/'
    tr '                          \_         | ||        _/'
    tr '                            \_       | ||      _/'
    tr '                              \_     | ||    _/'
    tr '                                \_   | ||  _/'
    tr '                                  \_ | ||_/'
    tr '                                    \|_|/'
  return
D11: /* 1000 */
    tr '                   ______o=========================o______'
    tr '                  /        *    ****     ****    ****     \'
    tr '                 ||       **   *    *   *    *  *    *    ||'
    tr '                 ||        *   *    *   *    *  *    *    ||'
    tr '                 ||        *   *    *|\ *    *  *    *    ||'
    tr '                  \_      ***   **** ||| ****    ****    _/'
    tr '                    \o===============| \\==============o/'
    tr '                      \_             | ||            _/'
    tr '                        \_           | ||          _/'
    tr '                          \_         | ||        _/'
    tr '                            \_       | ||      _/'
    tr '                              \_     | ||    _/'
    tr '                                \_   | ||  _/'
    tr '                                  \_ | ||_/'
    tr '                                    \|_|/'
  return
D12: /* Free Spin */
    tr '                   ______o=========================o______'
    tr '                  /     *****  ****      *****  *****     \'
    tr '                 ||     *      *   *     *      *         ||'
    tr '                 ||     ***    ****      ***    ***       ||'
    tr '                 ||     *      *   * |\  *      *         ||'
    tr '                  \_    *      *   * ||| *****  *****    _/'
    tr '                    \o===============| \\==============o/'
    tr '                      \_             | ||            _/'
    tr '                        \_           | ||          _/'
    tr '                          \_         | ||        _/'
    tr '                            \_       | ||      _/'
    tr '                              \_     | ||    _/'
    tr '                                \_   | ||  _/'
    tr '                                  \_ | ||_/'
    tr '                                    \|_|/'
  return
D13: /* Surprise */
    tr '                   ______o=========================o______'
    tr '                  /     *       *   *****   *       *     \'
    tr '                 ||     *       *  *     *  *       *     ||'
    tr '                 ||     *   *   *  *     *  *   *   *     ||'
    tr '                 ||     *  * *  *  * |\  *  *  * *  *     ||'
    tr '                  \_     **   **    *|||*    **   **     _/'
    tr '                    \o===============| \\==============o/'
    tr '                      \_             | ||            _/'
    tr '                        \_           | ||          _/'
    tr '                          \_         | ||        _/'
    tr '                            \_       | ||      _/'
    tr '                              \_     | ||    _/'
    tr '                                \_   | ||  _/'
    tr '                                  \_ | ||_/'
    tr '                                    \|_|/'
  return
D14: /* Lose Turn */
    tr '                   ______o=========================o______'
    tr '                  /    *       ****       ****  *****     \'
    tr '                 ||    *      *    *     *      *         ||'
    tr '                 ||    *      *    *      ***   ***       ||'
    tr '                 ||    *      *    * |\      *  *         ||'
    tr '                  \_   *****   ****  ||| ****   *****    _/'
    tr '                    \o===============| \\==============o/'
    tr '                      \_             | ||            _/'
    tr '                        \_           | ||          _/'
    tr '                          \_         | ||        _/'
    tr '                            \_       | ||      _/'
    tr '                              \_     | ||    _/'
    tr '                                \_   | ||  _/'
    tr '                                  \_ | ||_/'
    tr '                                    \|_|/'
  return
D15: /* Bankrupt */
    tr '                   ______o=========================o______'
    tr '                  /     ****    ***      **    *  *   *   \'
    tr '                 ||     *   *  *   *     * *   *  *  *    ||'
    tr '                 ||     ****   *****     *  *  *  ***     ||'
    tr '                 ||     *   *  *   * |\  *   * *  *  *    ||'
    tr '                  \_    ****   *   * ||| *    **  *   *  _/'
    tr '                    \o===============| \\==============o/'
    tr '                      \_             | ||            _/'
    tr '                        \_           | ||          _/'
    tr '                          \_         | ||        _/'
    tr '                            \_       | ||      _/'
    tr '                              \_     | ||    _/'
    tr '                                \_   | ||  _/'
    tr '                                  \_ | ||_/'
    tr '                                    \|_|/'
  return

TITLE:
    tr '         _________________          *=====================================*'
    tr '       _/                 \_        | /R\ /O\ /?\ /?\ /R\ /T\ ### ### ### |'
    tr '     _/        T H E        \_      | \R/ \O/ \?/ \?/ \R/ \T/ ### ### ### |'
    tr '   _/                         \_    |                                     |'
    tr '  /          W H E E L          \   | /R\ /?\ /?\ /?\ /O\ /R\ /?\ ### ### |'
    tr ' |                               |  | \R/ \?/ \?/ \?/ \O/ \R/ \?/ ### ### |'
    tr ' |              O F              |  *=====================================*'
    tr ' |                               |'
    tr '  \_       F O R T U N E       _/                 P E R S O N'
    tr '    \_                       _/'
    tr '      \_     V 6 . 0 b     _/           Completely ReWritten by Dotoran!'
    tr '        \_               _/'
    tr '          \_____________/               Your Hosts: Pat Sajack & Vanna!!n1'
  return

SYNTAX: ; ERROR: ; IOERR:
    tr '*** BOOM *** Error Detected!' ; tr 'ER:'rc' ('errortext(rc)') @ 'sigl
    tr 'Sysop has been notified...' ; bf ; changewhere oldwh
    call open(f1,dfile||'wof.errors',substr('wa',exists(dfile||'wof.errors')+1,1))
    call writeln(f1,'ASC Error: 'rc' ('errortext(rc)') in line 'sigl' ('date()')') ; call close(f1)
  signal QUIT2

/* Completed: November 26, 1993              Frontiers BBS (716)/823-9892 */
