; sol.wbt

mins = AskLine("Solitaire", "How many mins do you want to play?", "")
Switch mins
   case 0
        Display(5, "", "Game canceled")
        return
        break
   case 1
        Message("Only a minute?", "Wow! You've got willpower.")
        break
   case 2
        Message("2 Minutes?", "This isn't much of a break.")
        break
   case 3
        Message("3 Minutes?", "You're barely got time to shuffle")
        break
   case 4
        Message("HA,HA,HA",  "I dare you to try to beat me.")
        break
   case mins    ;default case - must be last in the switch
        Message("THAT LONG!!!",  "Where did you get all that time?")
        break
EndSwitch


If WinExist("Solitaire") == @TRUE 
     WinActivate("Solitaire")
Else
     Run("sol.exe", "")
Endif

for i = 0 to 9
        j=100-i*10
        k=300+i*70
        WinPlace(j,j,k,k,"Solitaire")
next

WinZoom("Solitaire")

SendKey("!gc{RIGHT}{SP}~")

GoSub dumdedum

if WinExist("Solitaire") then WinHide("Solitaire")
                         else exit
mins=AskLine("More Time?", "Enter additional minutes", 0)
WinShow("Solitaire")
If mins!=0 then GoSub dumdedum

errormode(@off)
while WinExist("Solitaire")
        WinClose("Solitaire")
endwhile
errormode(@cancel)
        
Message("Time's Up", "Get Back to Work!")
return

:dumdedum
goal = mins * 60
timer = 0
While timer < goal
        remain = goal - timer
        if WinExist("Solitaire")    ; Make user user did not close it manually
                WinTitle("Solitaire", "Solitaire (%remain% seconds left)")
        else
                return
        endif
        Delay(10)
        timer = timer + 10
EndWhile
Return


