Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Include <File.au3>
- #include <MsgBoxConstants.au3>
- #include <Date.au3>
- Global $file = @ScriptDir & "\saltlick.txt"
- getFighters()
- Func getFighters()
- Global $leftChoose = InputBox("Find a fight","Who is fighting on the left side?")
- Global $rightChoose = InputBox("Find a fight","Who is fighting on the right side?")
- Global $search = $leftChoose&"*"&$rightChoose
- Global $src = 0
- Global $srcnum = 1
- Global $fileLines = _FileCountLines($file)
- Global $revFlag = 0
- setSearch()
- EndFunc
- Func setSearch()
- If $src == 0 Then
- FileOpen($file, $FO_READ)
- search()
- EndIf
- EndFunc
- Func search()
- Do
- $sFileRead = FileReadLine($file, $srcnum)
- If StringInStr($sFileRead, $search) Then ;;If the string fragment is found in the file
- $aSpl = StringSplit($sFileRead, "~ get") ;;Split everything before probability
- If $revFlag == 1 Then ;;If the string has been reversed, reverse the everything else
- $aRevSpl = StringSplit($aSpl[2], ":")
- If $aSpl[3] == "R" Then
- $aSpl[3] = "L"
- Else
- $aSpl[3] = "R"
- EndIf
- MsgBox($MB_SYSTEMMODAL, "Odds", "Left: "&$leftChoose&" | Right: "&$rightChoose&@CRLF&"Win Probability: "&$aRevSpl[2]&":"&$aRevSpl[1]&@CRLF&"Historical outcome: "&$aSpl[3]&@CRLF&@CRLF&"Date recorded: "&$aSpl[4])
- Else
- MsgBox($MB_SYSTEMMODAL, "Odds", "Left: "&$leftChoose&" | Right: "&$rightChoose&@CRLF&"Win Probability: "&$aSpl[2]&@CRLF&"Historical winner: "&$aSpl[3]&@CRLF&@CRLF&"Date recorded: "&$aSpl[4])
- EndIf
- ElseIf $srcnum == $fileLines AND $revFlag = 0 Then ;;If string isn't in the file and string hasn't been reversed
- $revFlag = 1 ;;Flag to reverse the search string
- $srcnum = 1
- $search = $rightChoose&"*"&$leftChoose
- setSearch()
- ExitLoop
- ElseIf $srcnum == $fileLines AND $revFlag = 1 Then ;;If the reversed string isn't found, the fight is new
- newFight()
- Else
- $srcnum+=1
- search()
- EndIf
- Until 1
- EndFunc
- Func newFight()
- $hDetails = MsgBox($MB_YESNO, "New fight!", "Are these details correct?"&@CRLF&"Left: "&$leftChoose&" | Right: "&$rightChoose)
- If $hDetails = 6 Then
- $optRadOdds = InputBox("Optional: Odds","What are the odds of the fight?"&@CRLF&"No unnecessary characters such as spaces.")
- $histOutNew = InputBox("Who won the fight?","Only 'L' or 'R', please.")
- If StringInStr($optRadOdds, ":") Then
- FileWriteLine($file, $leftChoose&"*"&$rightChoose&"~"&$optRadOdds&"~"&$histOutNew&"~"&@MON&"/"&@MDAY&"/"&@YEAR)
- getFighters()
- Else
- FileWriteLine($file, $leftChoose&"*"&$rightChoose&"~"&"N/A"&"~"&$histOutNew&"~"&@MON&"/"&@MDAY&"/"&@YEAR)
- getFighters()
- EndIf
- ElseIf $hDetails = 7 Then
- $leftChoose = InputBox("Find a fight","Who is fighting on the left side?")
- $rightChoose = InputBox("Find a fight","Who is fighting on the right side?")
- newFight()
- EndIf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement