Ideally, I want it to be able to tell how many cards are in my deck, and be able to click them all one after another in my preferred order, i.e....
My Deck has 10 cards, and I want them played in the order - a, a, b, a, c, d, b, a, e
Let's say my starting hand contained cards b,c,d, it should play b, then remove that instance of 'b' from the queue, so that if I drew an 'a' next, it would play that, but if I drew the second 'b' next, it would play 'c' instead, since the first 'b' had already been played.
My code is below. All it really does is to go through the ordered list (defense.txt) and pick the first available card that is in my hand.... The imagesearch and click work just fine, but I'm not sure how to modify my array. As you can see, my current strategy is to rewrite the used array value with an empty string. This doesn't help since I need to loop this whole thing for (# of cards in deck) cycles, removing a used card each time. Any help would be greatly appreciated. Please ask questions if you think you can help. I'm bad at explaining things, but I don't think this is actually a tough problem, I'm just too close to it to see the solution....
Code: Select all
^+m::
{
;Locate my hand on the playfield
HandLocator := ".\Actions\Hand.png"
ImageSearch, TempX, TempY, 0, 0, 1920, 1080, %HandLocator%
Hand1X := TempX - 5
Hand1Y := TempY + 15
Hand2X := Hand1X + 270
Hand2Y := Hand1Y + 120
;
; Create my preferred order card list from a text file
DeckCount = 0
Loop, Read, Defense.txt
{
DeckCount += 1
Array%DeckCount% := A_LoopReadLine
}
;
; Play cards in order
Loop %DeckCount%
{
CardCheck := Array%A_Index%
ImageSearch, CardX, CardY, %Hand1X%, %Hand1Y%, %Hand2X%, %Hand2Y%, %CardCheck%
If Errorlevel = 0
{
Click, %CardX%, %CardY%
Array%A_Index% = ""
MouseMove 1000,250
}
If Errorlevel = 1
Continue
;If ErrorLevel = 2
;msgbox, Problem
}
}