home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / games / jots.zip / GUESLIST.BAS < prev    next >
BASIC Source File  |  1989-03-13  |  2KB  |  87 lines

  1. ' GUESLIST.BAS -- This module handles the list of guesses
  2. ' $INCLUDE: 'J.INC'
  3.  
  4. TYPE GuessType
  5.     Word AS STRING * 5
  6.     Points AS INTEGER
  7. END TYPE
  8.  
  9. DIM SHARED Guess(1 TO 20) AS GuessType, Guesses
  10. DIM SHARED MyBox AS BoxType, TopRow, BotRow, LftCol, RtCol
  11.  
  12. SUB InitGuessList
  13.     FOR Lp = 1 TO 20
  14.         Guess(Lp).Word$ = " "
  15.         Guess(Lp).Points = GuessScore(Lp)
  16.     NEXT Lp
  17.     Guesses = 0
  18.     GameWonFlag = FALSE
  19.     CALL BoxCoords(GuessListBox, MyBox)
  20.     TopRow = MyBox.TopRow
  21.     BotRow = MyBox.BotRow
  22.     LftCol = MyBox.LftCol
  23.     RtCol = MyBox.RtCol
  24.  
  25.     NormalBox (GuessListBox)
  26.     COLOR Dark, Background, Background
  27.     FOR Lp = 1 TO 20
  28.         LOCATE Lp + TopRow, LftCol + 2, 0
  29.         PRINT USING "----- ###"; Guess(Lp).Points;
  30.     NEXT Lp
  31.     COLOR Normal, Background, Background
  32. END SUB
  33.  
  34. SUB AddGuess (NewWord$)
  35.     Guesses = Guesses + 1
  36.     Guess(Guesses).Word$ = NewWord$
  37.     Temp$ = SecretWord$
  38.     Points = 0
  39.     IF NewWord$ <> Temp$ THEN
  40.         FOR Lp = 1 TO 5
  41.             Letter$ = MID$(NewWord$, Lp, 1)
  42.             Posn = INSTR(Temp$, Letter$)
  43.             IF Posn THEN
  44.                 Points = Points + 1
  45.                 MID$(Temp$, Posn, 1) = " "
  46.             END IF
  47.         NEXT Lp
  48.         Guess(Guesses).Points = Points
  49.         IF Points = 0 THEN
  50.             RemoveFromPossList (NewWord$)
  51.         END IF
  52.         AddToScore (Points)
  53.         AddToUsedList (NewWord$)
  54.     ELSE
  55.         AddToScore (GuessScore(Guesses))
  56.     END IF
  57.     RedrawGuessList
  58. END SUB
  59.  
  60. SUB RedrawGuessList
  61.     TempPossList$ = PossibleLetterList$
  62.     FOR Lp = 1 TO Guesses
  63.         TempKnown$ = KnownList$
  64.         FOR Lp2 = 1 TO 5
  65.             Letter$ = MID$(Guess(Lp).Word$, Lp2, 1)
  66.             COLOR Normal, Background, Background
  67.             IF INSTR(TempPossList$, Letter$) THEN
  68.                 COLOR Exclude, Background, Background
  69.             END IF
  70.             IF INSTR(TempKnown$, Letter$) THEN
  71.                 COLOR Known, Background, Background
  72.                 MID$(TempKnown$, INSTR(TempKnown$, Letter$), 1) = " "
  73.             ELSEIF INSTR(KnownList$, Letter$) THEN
  74.                 COLOR Uncertain, Background, Background
  75.             END IF
  76.             LOCATE TopRow + Lp, LftCol + Lp2 + 1, 0
  77.             PRINT Letter$;
  78.         NEXT Lp2
  79.         COLOR Normal, Background, Background
  80.         PRINT USING " ###"; Guess(Lp).Points;
  81.     NEXT Lp
  82. END SUB
  83.  
  84. FUNCTION GuessCount%
  85.     GuessCount = Guesses
  86. END FUNCTION
  87.