Skip to content

added util fns - play-from-hand-with-prompt, click-prompts#7942

Merged
NBKelly merged 4 commits intomtgred:masterfrom
NBKelly:test-prompt-util-fns
Feb 26, 2025
Merged

added util fns - play-from-hand-with-prompt, click-prompts#7942
NBKelly merged 4 commits intomtgred:masterfrom
NBKelly:test-prompt-util-fns

Conversation

@NBKelly
Copy link
Collaborator

@NBKelly NBKelly commented Feb 4, 2025

I added a couple of util fns to the test framework.

(play-from-hand-with-prompt [state side card prompt]): play a card, then click a prompt. This plays a card, then makes a call to click-prompts with the given choice.

(click-prompts [state side & prompts])

Clicks the argument prompts, in order. They are all clicked from the given side, but you can instead pass in {:side ... :choice ...}.

Click-prompts intelligently examines the prompt state, to see if it's a card prompt, or a text/button prompt that's open, and chooses the correct subroutine for that (it defers to the click-card, click-prompt).

So, for example, to resolve ad blitz, you could call:
(click-prompts state :corp "2" "Launch Campaign" "New remote" "Pop-up Window" "Server 1")
And to resolve dirty laundry on HQ, you could call:
(play-from-hand-with-prompt state :runner "Dirty Laundry" "HQ")

I rewrote a couple of unit tests, just as a demo/proof of concept. I don't propose replacing everything with this, I just think it's a nice tool to have for later tests (ie for dawn cards).

As an example, the singular card that's been revealed so far is basically a bunch of stacked prompts, so it could have a very verbose set of unit tests:

kpi

@NBKelly NBKelly marked this pull request as draft February 4, 2025 19:12
@NBKelly
Copy link
Collaborator Author

NBKelly commented Feb 4, 2025

I extended the play-with-prompt to take an arbitrary amount, just incase we need it later.

Next step is adding the ability to pass in 1-fn's that act on state to select their element (this will be useful for any test which can be constructed as (doseq [x ...] (deftest ...))

@NBKelly NBKelly marked this pull request as ready for review February 4, 2025 23:44
@NBKelly NBKelly merged commit 749a3c2 into mtgred:master Feb 26, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant