2022-11-02 04:17:14 +00:00
Module TerminalApps
2022-11-03 15:27:40 +00:00
Public ShouldChange As Boolean = False
'This is for GTN's RAM
Public TheNumber As Integer = 0
Public Sub ChangeCP ( Addition As Boolean , NeededCP As Integer )
Dim TempCP As Integer = Convert . ToInt32 ( Strings . ComputerInfo ( 2 ) )
If Addition = True Then
TempCP = TempCP + NeededCP
Else
TempCP = TempCP - NeededCP
End If
Strings . ComputerInfo ( 2 ) = Convert . ToString ( TempCP )
End Sub
2022-11-02 04:17:14 +00:00
Public Sub AppHost ( App As Object )
2022-11-03 15:27:40 +00:00
Select Case App
Case " guess " 'Guess the Number
Terminal . DefaultPrompt = " Your answer: "
Terminal . TextBox1 . Text = Terminal . TextBox1 . Text & Environment . NewLine & " Guess the Number " & Environment . NewLine & " Guess the correct number between 1 and 50 and you'll get anything between 1 to 5 Codepoints " & Environment . NewLine & " Type 'exit' to terminate this game "
Terminal . CurrentInterpreter = " guess "
GTN_GenerateNumber ( )
ShouldChange = True
End Select
If ShouldChange = True Then
Terminal . ChangeInterpreter = True
ShouldChange = False
End If
End Sub
Public Sub TerminateApp ( )
Terminal . ChangeInterpreter = False
Terminal . PrintPrompt ( )
Terminal . AssignPrompt ( )
End Sub
Public Sub DoChildCommand ( )
Select Case Terminal . CurrentInterpreter
Case " guess "
Select Case Terminal . command
Case " exit "
TerminateApp ( )
Case Else
Try
GTN_CheckNumber ( )
Catch ex As Exception
Terminal . TextBox1 . Text = Terminal . TextBox1 . Text & Environment . NewLine & " Invalid value! "
End Try
End Select
End Select
End Sub
Public Sub GTN_GenerateNumber ( )
Dim RandNum As New Random
TheNumber = RandNum . Next ( 1 , 51 )
End Sub
2022-11-02 04:17:14 +00:00
2022-11-03 15:27:40 +00:00
Public Sub GTN_CheckNumber ( )
Dim TheirNumber As Integer = Convert . ToInt32 ( Terminal . command )
If TheirNumber > 0 And TheirNumber < 51 Then
If TheirNumber = TheNumber Then
Dim GetCP As New Random
Dim GotCP As Integer = GetCP . Next ( 1 , 6 )
ChangeCP ( True , GotCP )
Terminal . TextBox1 . Text = Terminal . TextBox1 . Text & Environment . NewLine & " You are correct!, you got " & GotCP & " Codepoint(s) " & Environment . NewLine & " Guess the new number between 1 and 50. "
GTN_GenerateNumber ( )
Else
If TheirNumber < TheNumber Then
Terminal . TextBox1 . Text = Terminal . TextBox1 . Text & Environment . NewLine & " Higher! "
ElseIf TheirNumber > TheNumber Then
Terminal . TextBox1 . Text = Terminal . TextBox1 . Text & Environment . NewLine & " Lower! "
End If
End If
End If
2022-11-02 04:17:14 +00:00
End Sub
End Module