Took me way too long to think of this.

Remember that game engine I've been writing? Well it's come a long way since last time I posted anything about it.

But one of the things is long lists of Select Case statements that I keep editing - mostly adding to.

So instead of going from lowest number to highest, do just the opposite.

Now everything I need is at the top of the procedure instead of the bottom.


Code:
' Declarations.

Private Const NON_CONSECUTIVE_RANDOM_MULTIPLIER As Double = 0.75


Public Property Get GotBuffed() As String
Const MAX_CHOICE As Long = 17
Static nRecentChoice(1 To MAX_CHOICE * NON_CONSECUTIVE_RANDOM_MULTIPLIER) As Long
Dim nChoice As Long

nChoice = SelectNonConsecutiveRandomChoice(MAX_CHOICE, nRecentChoice)

Select Case nChoice

  Case 17

    GotBuffed = "It's dangerous to go alone.  Take this."

  Case 16

    GotBuffed = "You've been hitting the gym!"

  Case 15

    GotBuffed = "Great job on those TPS reports!"

  Case 14

    GotBuffed = "You found the perfect balance between exploiting labor and resources for profit while selling the public an image of 'Corporate Responsibility'."

  Case 13

    ' Etc.

End Select

End Property

Public Function SelectNonConsecutiveRandomChoice(ByRef NumChoices As Long, ByRef RecentChoices() As Long) As Long
Dim nRnd As Long
Dim n As Long
Dim s() As String

Do

  nRnd = RollDie(NumChoices)

Loop While ArrayItemExistsLong(nRnd, RecentChoices)

ReDim s(LBound(RecentChoices) To UBound(RecentChoices))

For n = UBound(RecentChoices) To LBound(RecentChoices) + 1 Step -1

  RecentChoices(n) = RecentChoices(n - 1)

  s(n) = CStr(RecentChoices(n))

Next n

RecentChoices(LBound(RecentChoices)) = nRnd

s(LBound(RecentChoices)) = CStr(nRnd)

AddPlayerMessage vbCrLf & "Recent Choices: " & Join(s, ","), 0, True

SelectNonConsecutiveRandomChoice = nRnd

End Function