Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;This script will prompt the user for a MTGO .dek file, parse it into the format used by TappedOut.net, and copy it to the clipboard.
- ;If the dek has a sideboard, that will also be parsed.
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- #Warn ; Recommended for catching common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- ;PLEASE ENTER YOUR DEFAULT STARTING DIRECTORY BELOW
- CONST_STARTING_DIR = C:\
- arrayDeckParsed =
- arraySideboardParsed =
- boolSideboardExists = 0
- stringRegExMain = Quantity="(?P<Count>[0-9]+)" Sideboard="false" Name="(?P<Name>[^"]+)
- stringRegExSideboard = Quantity="(?P<Count>[0-9]+)" Sideboard="true" Name="(?P<Name>[^"]+)
- ;-----END INIT-----
- ;user can't proceed without choosing a file
- Loop
- {
- FileSelectFile, stringFileChosen,,%CONST_STARTING_DIR%,Choose a .dek file to convert to Tapped-Out format:,MTGO Deck Files (*.dek)
- if (ErrorLevel <> 1)
- break
- else
- MsgBox,Please choose a file to continue!
- }
- ;read the .dek the user just chose
- FileRead,arrayDeck,%stringFileChosen%
- ;loop through the .dek line by line
- Loop,parse,arrayDeck,`n,`r
- {
- ;if the first regex matches, it's a main card, if not (check that) it's a sideboard card (the sideboard exists)
- stringTempRegEx =
- RegExMatch(A_LoopField,stringRegExMain,stringTempRegEx)
- if (stringTempRegEx <> "")
- arrayDeckParsed = %arrayDeckParsed%%stringTempRegExCount%x %stringTempRegExName%`n
- else
- {
- RegExMatch(A_LoopField,stringRegExSideboard,stringTempRegEx)
- if (stringTempRegEx <> "")
- {
- arraySideboardParsed = %arraySideboardParsed%%stringTempRegExCount%x %stringTempRegExName%`n
- if (boolSideboardExists = 0)
- boolSideboardExists = 1
- }
- }
- }
- Clipboard = %arrayDeckParsed%
- ;if there was a sideboard, display different prompt and copy that too.
- if (boolSideBoardExists = 1)
- {
- MsgBox,Main parsed and copied to clipboard!`n`nPress OK to copy sideboard to clipboard.
- Clipboard = %arraySideboardParsed%
- MsgBox,Sideboard copied to clipboard!`n`nPress OK to quit.
- }
- else
- MsgBox,Main parsed and copied to clipboard!`n`nPress OK to quit.
- ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement