New ways to earn Codepoints + Terminal Cleanup

Alrighty. This one's a small one.

I've ported the two beginner apps from UltraDOS that helped you earn
codepoints (scriptpoints in UltraDOS) to ShiftOS-Next.

I've also moved some Terminal methods like AddLine() to an API.vb
module. I've also hid the MathQuiz and GuessTheNumber code in the
TerminalGames module.
This commit is contained in:
TheUltimateHacker 2015-05-22 17:42:21 -04:00
parent ed36135241
commit 02df35aba0
9 changed files with 268 additions and 94 deletions

94
shiftos_next/API.vb Normal file
View file

@ -0,0 +1,94 @@
Module API
'Terminal
Public txtterm As TextBox = Terminal.txtterm
Public Sub wrongcommand()
AddLine("Invalid command! Type ""help"" for a list of commands.")
End Sub
Public Sub AddLine(text As String)
txtterm.Text += vbNewLine + text
SelectBottom()
End Sub
Public Sub openfile(file As String)
Dim filinfo As New IO.FileInfo(file)
Select Case filinfo.Extension
Case ".txt"
If boughttextpad = True Then
Dim sr As New IO.StreamReader(file)
TextPad.txtfilebody.Text = sr.ReadToEnd()
sr.Close()
TextPad.Show()
Else
wrongcommand()
End If
Case Else
wrongcommand()
End Select
End Sub
Public Sub showterminalcolors()
AddLine(" ==== SUPPORTED TERMINAL COLORS ==== " & vbNewLine)
AddLine("Below is a list of values that you can specify in <colorname> arguments. Note that only certain colors are supported; and if the video driver can output a color but it isn't on this list, it is not supported by the Terminal display engine." & vbNewLine)
If boughtgray Then AddLine("gray")
AddLine("white")
AddLine("black")
If boughtred Then AddLine("red")
If boughtgreen Then AddLine("green")
If boughtblue Then AddLine("blue")
If boughtyellow Then AddLine("yellow")
If boughtorange Then AddLine("orange")
If boughtpink Then AddLine("pink")
If boughtpurple Then AddLine("purple")
If boughtbrown Then AddLine("brown")
End Sub
Public Sub ShowHelp()
AddLine("ShiftOS Help" & vbNewLine)
AddLine("Usage tips: " & vbNewLine)
AddLine(" - The terminal runs in full-screen.")
If boughttextpad = True Then AddLine(" - Typing the path to a text file will open it in Textpad.")
AddLine(" - There are no window managers or desktop environments.")
If boughtbasicgui = True Then
AddLine(" - Applications can use the GUI server to display a proper GUI.")
Else
AddLine(" - Applications are fully text-based.")
End If
AddLine(" - Terminal commands are case-insensitive." & vbNewLine)
AddLine("Commands: " & vbNewLine)
If boughtdirectorysurfing Then
AddLine(" - cd: Change to the specified directory.")
AddLine(" - mkdir: Create a directory inside the current directory (marked before the %)")
AddLine(" - ls, dir: View the contents of the current directory.")
End If
If boughtbasicsettings Then
AddLine(" - set <setting> <value>: Change some minimal settings in ShiftOS.")
If boughtcustomusername Then
AddLine(" Settings: ")
AddLine(" username <string>: Set the username of the OS.")
End If
If boughtterminalsettextcolor = True Then
AddLine(" textcolor <colorname>: Set the terminal text color.")
End If
End If
AddLine(" - codepoints: Shows the current amount of codepoints.")
AddLine(" - shutdown: Shuts the system down.")
AddLine(" - colors: Shows the colors supported by both the Terminal display engine, and the video driver.")
AddLine(" - help: Shows this screen." & vbNewLine)
AddLine("Installed Programs:" & vbNewLine)
AddLine("Below is a list of all the programs on your computer, followed by what they do. You can open one by typing ""open <name>""." & vbNewLine)
AddLine(" - shiftorium: Upgrade the OS with Codepoints using this application.")
If boughtfileskimmer Then AddLine(" - file skimmer: A handy little file browser.")
If boughttextpad Then AddLine(" - textpad: An application that allows for creating and editing text files.")
AddLine(" - MathQuiz: Earn Codepoints by solving math questions.")
AddLine(" - Guess the Number: Earn Codepoints by guessing a random number between 1 and 100.")
End Sub
Public Sub SelectBottom()
txtterm.Select(txtterm.Text.Length, 0)
End Sub
End Module

View file

@ -15,9 +15,7 @@
End If
End Sub
Public Sub SelectBottom()
txtterm.Select(txtterm.Text.Length, 0)
End Sub
Public Sub Interpret(command As String)
command = command.ToLower
@ -177,8 +175,16 @@
ElseIf command Like "shutdown" Then
savegame()
Me.Close()
ElseIf command Like "math*" Then
mathquiz = True
changeinterpreter()
ElseIf command Like "guess the number" Or command Like "guess" Then
guessthenumber = True
changeinterpreter()
ElseIf command Like "code*" Or command = "code points" Then
AddLine("You have " & codepoints & " Codepoints.")
ElseIf command = "colors" Then
ShowTerminalColors()
showterminalcolors()
ElseIf command Like "" Then
'This is here to make it so that the Terminal doesn't say "Wrong Command" if the user doesn't input anything.
Else
@ -192,85 +198,11 @@
End If
End Sub
Public Sub openfile(file As String)
Dim filinfo As New IO.FileInfo(file)
Select Case filinfo.Extension
Case ".txt"
If boughttextpad = True Then
Dim sr As New IO.StreamReader(file)
TextPad.txtfilebody.Text = sr.ReadToEnd()
sr.Close()
TextPad.Show()
Else
wrongcommand()
End If
Case Else
wrongcommand()
End Select
End Sub
Public Sub wrongcommand()
AddLine("Invalid command! Type ""help"" for a list of commands.")
End Sub
Public Sub showterminalcolors()
AddLine(" ==== SUPPORTED TERMINAL COLORS ==== " & vbNewLine)
AddLine("Below is a list of values that you can specify in <colorname> arguments. Note that only certain colors are supported; and if the video driver can output a color but it isn't on this list, it is not supported by the Terminal display engine." & vbNewLine)
If boughtgray Then AddLine("gray")
AddLine("white")
AddLine("black")
If boughtred Then AddLine("red")
If boughtgreen Then AddLine("green")
If boughtblue Then AddLine("blue")
If boughtyellow Then AddLine("yellow")
If boughtorange Then AddLine("orange")
If boughtpink Then AddLine("pink")
If boughtpurple Then AddLine("purple")
If boughtbrown Then AddLine("brown")
End Sub
Public Sub ShowHelp()
AddLine("ShiftOS Help" & vbNewLine)
AddLine("Usage tips: " & vbNewLine)
AddLine(" - The terminal runs in full-screen.")
If boughttextpad = True Then AddLine(" - Typing the path to a text file will open it in Textpad.")
AddLine(" - There are no window managers or desktop environments.")
If boughtbasicgui = True Then
AddLine(" - Applications can use the GUI server to display a proper GUI.")
Else
AddLine(" - Applications are fully text-based.")
End If
AddLine(" - Terminal commands are case-insensitive." & vbNewLine)
AddLine("Commands: " & vbNewLine)
If boughtdirectorysurfing Then
AddLine(" - cd: Change to the specified directory.")
AddLine(" - mkdir: Create a directory inside the current directory (marked before the %)")
AddLine(" - ls, dir: View the contents of the current directory.")
End If
If boughtbasicsettings Then
AddLine(" - set <setting> <value>: Change some minimal settings in ShiftOS.")
If boughtcustomusername Then
AddLine(" Settings: ")
AddLine(" username <string>: Set the username of the OS.")
End If
If boughtterminalsettextcolor = True Then
AddLine(" textcolor <colorname>: Set the terminal text color.")
End If
End If
AddLine(" - shutdown: Shuts the system down.")
AddLine(" - colors: Shows the colors supported by both the Terminal display engine, and the video driver.")
AddLine(" - help: Shows this screen." & vbNewLine)
AddLine("Installed Programs:" & vbNewLine)
AddLine("Below is a list of all the programs on your computer, followed by what they do. You can open one by typing ""open <name>""." & vbNewLine)
AddLine(" - shiftorium: Upgrade the OS with Codepoints using this application.")
If boughtfileskimmer Then AddLine(" - file skimmer: A handy little file browser.")
If boughttextpad Then AddLine(" - textpad: An application that allows for creating and editing text files.")
End Sub
Public Sub AddLine(text As String)
txtterm.Text += vbNewLine + text
SelectBottom()
End Sub
Dim firstuseconversation As Integer = 0
@ -337,24 +269,56 @@
If e.KeyCode = Keys.Enter Then
e.SuppressKeyPress = True
Dim command As String = txtterm.Lines(txtterm.Lines.Length - 1).Replace(username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> ", "").ToLower
Interpret(command)
If command = "clear" Then
txtterm.Text = username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> "
txtterm.Select(txtterm.Text.Length, 0)
If mathquiz = True Then
Dim question As String = txtterm.Lines(txtterm.Lines.Length - 2)
Dim answer As String = txtterm.Lines(txtterm.Lines.Length - 1).Replace("> ", "")
If answer = "exit" Then
mathquiz = False
AddLine(username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> ")
Else
Try
MQInterpret(question, answer)
Catch ex As Exception
AddLine("The answer provided isn't a proper number!")
End Try
AddLine("> ")
End If
ElseIf guessthenumber = True Then
Dim answer As String = txtterm.Lines(txtterm.Lines.Length - 1).Replace("> ", "")
If answer = "exit" Then
guessthenumber = False
AddLine(username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> ")
Else
Try
GTNInterpret(answer)
Catch ex As Exception
AddLine("The answer provided isn't a proper number.")
End Try
AddLine("> ")
End If
Else
AddLine(username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> ")
txtterm.Select(txtterm.Text.Length, 0)
End If
Dim command As String = txtterm.Lines(txtterm.Lines.Length - 1).Replace(username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> ", "").ToLower
Interpret(command)
trackpos = 0
If mathquiz Or guessthenumber Then
AddLine("> ")
Else
If command = "clear" Then
txtterm.Text = username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> "
txtterm.Select(txtterm.Text.Length, 0)
Else
AddLine(username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> ")
txtterm.Select(txtterm.Text.Length, 0)
End If
End If
End If
trackpos = 0
Else
If e.KeyCode = Keys.Back Then
Else
trackpos = trackpos + 1
End If
If e.KeyCode = Keys.Back Then
Else
trackpos = trackpos + 1
End If
End If
If e.KeyCode = Keys.Back Then
@ -379,4 +343,6 @@
AddLine(username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> ")
End If
End Sub
End Class

View file

@ -0,0 +1,110 @@
Module TerminalGames
Public mathquiz As Boolean = False
Public guessthenumber As Boolean = False
Public Sub MQInterpret(question As String, answer As Integer)
Dim random As New Random()
Dim args() As String = question.Replace("What is ", "").Split(" ")
Select Case args(1)
Case "+"
If answer = args(0) + args(2) Then
Dim cptoadd As Integer = random.Next(1, 5)
AddLine("Correct! You have earned " & cptoadd & " Codepoints!")
AddCP(cptoadd)
Else
AddLine("Incorrect! Better luck next time...")
End If
Case "-"
If answer = args(0) - args(2) Then
Dim cptoadd As Integer = random.Next(1, 5)
AddLine("Correct! You have earned " & cptoadd & " Codepoints!")
AddCP(cptoadd)
Else
AddLine("Incorrect! Better luck next time...")
End If
Case "*"
If answer = args(0) * args(2) Then
Dim cptoadd As Integer = random.Next(1, 5)
AddLine("Correct! You have earned " & cptoadd & " Codepoints!")
AddCP(cptoadd)
Else
AddLine("Incorrect! Better luck next time...")
End If
Case "/"
If answer = args(0) / args(2) Then
Dim cptoadd As Integer = random.Next(1, 5)
AddLine("Correct! You have earned " & cptoadd & " Codepoints!")
AddCP(cptoadd)
Else
AddLine("Incorrect! Better luck next time...")
End If
End Select
MQCreateQuestion()
End Sub
Public Sub MQCreateQuestion()
Dim rand As New Random
Dim num1 As Integer = rand.Next(1, 10)
Dim num2 As Integer = rand.Next(1, 10)
Dim operandchooser As Integer = rand.Next(1, 4)
Dim operand As String
Select Case operandchooser
Case 1
operand = " + "
Case 2
While num2 > num1
num2 = rand.Next(1, 10)
End While
operand = " - "
Case 3
operand = " * "
Case 4
operand = " / "
Case Else
operand = " + "
End Select
AddLine("What is " & num1 & operand & num2 & " ?")
End Sub
Public Sub changeinterpreter()
If mathquiz = True Then
AddLine(" === MathQuiz ===" & vbNewLine)
AddLine("MathQuiz is a basic game for ShiftOS that allows you to earn Codepoints for solving math " & vbNewLine & "questions. These questions will always be (num1) (operand) (num2) = (answer)." & vbNewLine)
AddLine("(num1) and (num2) will always be integers between 1 and 10.")
AddLine("(operand) Will always be either a +, -, * (times) or / (division) statement that can change the answer.")
MQCreateQuestion()
End If
If guessthenumber = True Then
AddLine(" -= Guess The Number =-" & vbNewLine)
AddLine("Guess the Number is a game that allows you to earn Codepoints for")
AddLine("guessing a number between 1 and 100." & vbNewLine)
GTNStart()
End If
End Sub
Public GTNCorrect As Integer
Public Sub GTNStart()
Dim rand As New Random()
GTNCorrect = rand.Next(1, 100)
AddLine("Choose a number between 1 and 100:")
End Sub
Public Sub GTNInterpret(num As Integer)
If num < 100 And num > 0 Then
If GTNCorrect = num Then
Dim rand As New Random()
Dim cptoadd As Integer = rand.Next(1, 10)
AddLine("Correct! You have earned " & cptoadd & " Codepoints.")
GTNStart()
ElseIf num > GTNCorrect Then
AddLine("Lower!")
ElseIf num < GTNCorrect Then
AddLine("Higher!")
End If
Else
AddLine("Number isn't between 1 and 100!")
End If
End Sub
End Module

View file

@ -61,6 +61,8 @@
FileType = "Data File"
Case ".dri"
FileType = "Driver"
Case Else
FileType = "Unknown File"
End Select
Return FileType
End Function

View file

@ -70,6 +70,7 @@
<Import Include="System.Threading.Tasks" />
</ItemGroup>
<ItemGroup>
<Compile Include="API.vb" />
<Compile Include="BasicWM_ColorTable.vb" />
<Compile Include="basicwm_infobox.Designer.vb">
<DependentUpon>basicwm_infobox.vb</DependentUpon>
@ -120,6 +121,7 @@
<Compile Include="Terminal.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="TerminalGames.vb" />
<Compile Include="TextPad.Designer.vb">
<DependentUpon>TextPad.vb</DependentUpon>
</Compile>