Advertisement
Aareon

Salty Bet's Bot Updated

Jul 27th, 2015
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. #Include <File.au3>
  2. #include <MsgBoxConstants.au3>
  3. #include <Date.au3>
  4.  
  5. Global $file = @ScriptDir & "\saltlick.txt"
  6.  
  7. getFighters()
  8.  
  9. Func getFighters()
  10. Global $leftChoose = InputBox("Find a fight","Who is fighting on the left side?")
  11. Global $rightChoose = InputBox("Find a fight","Who is fighting on the right side?")
  12. Global $search = $leftChoose&"*"&$rightChoose
  13. Global $src = 0
  14. Global $srcnum = 1
  15. Global $fileLines = _FileCountLines($file)
  16. Global $revFlag = 0
  17. setSearch()
  18. EndFunc
  19.  
  20. Func setSearch()
  21. If $src == 0 Then
  22. FileOpen($file, $FO_READ)
  23. search()
  24. EndIf
  25. EndFunc
  26.  
  27. Func search()
  28. Do
  29. $sFileRead = FileReadLine($file, $srcnum)
  30. If StringInStr($sFileRead, $search) Then ;;If the string fragment is found in the file
  31. $aSpl = StringSplit($sFileRead, "~ get") ;;Split everything before probability
  32. If $revFlag == 1 Then ;;If the string has been reversed, reverse the everything else
  33. $aRevSpl = StringSplit($aSpl[2], ":")
  34. If $aSpl[3] == "R" Then
  35. $aSpl[3] = "L"
  36. Else
  37. $aSpl[3] = "R"
  38. EndIf
  39. 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])
  40. Else
  41. MsgBox($MB_SYSTEMMODAL, "Odds", "Left: "&$leftChoose&" | Right: "&$rightChoose&@CRLF&"Win Probability: "&$aSpl[2]&@CRLF&"Historical winner: "&$aSpl[3]&@CRLF&@CRLF&"Date recorded: "&$aSpl[4])
  42. EndIf
  43. ElseIf $srcnum == $fileLines AND $revFlag = 0 Then ;;If string isn't in the file and string hasn't been reversed
  44. $revFlag = 1 ;;Flag to reverse the search string
  45. $srcnum = 1
  46. $search = $rightChoose&"*"&$leftChoose
  47. setSearch()
  48. ExitLoop
  49. ElseIf $srcnum == $fileLines AND $revFlag = 1 Then ;;If the reversed string isn't found, the fight is new
  50. newFight()
  51. Else
  52. $srcnum+=1
  53. search()
  54. EndIf
  55. Until 1
  56. EndFunc
  57.  
  58. Func newFight()
  59. $hDetails = MsgBox($MB_YESNO, "New fight!", "Are these details correct?"&@CRLF&"Left: "&$leftChoose&" | Right: "&$rightChoose)
  60. If $hDetails = 6 Then
  61. $optRadOdds = InputBox("Optional: Odds","What are the odds of the fight?"&@CRLF&"No unnecessary characters such as spaces.")
  62. $histOutNew = InputBox("Who won the fight?","Only 'L' or 'R', please.")
  63. If StringInStr($optRadOdds, ":") Then
  64. FileWriteLine($file, $leftChoose&"*"&$rightChoose&"~"&$optRadOdds&"~"&$histOutNew&"~"&@MON&"/"&@MDAY&"/"&@YEAR)
  65. getFighters()
  66. Else
  67. FileWriteLine($file, $leftChoose&"*"&$rightChoose&"~"&"N/A"&"~"&$histOutNew&"~"&@MON&"/"&@MDAY&"/"&@YEAR)
  68. getFighters()
  69. EndIf
  70. ElseIf $hDetails = 7 Then
  71. $leftChoose = InputBox("Find a fight","Who is fighting on the left side?")
  72. $rightChoose = InputBox("Find a fight","Who is fighting on the right side?")
  73. newFight()
  74. EndIf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement