Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it easy to test simple interactions? #5

Open
amalloy opened this issue Feb 7, 2014 · 4 comments
Open

Make it easy to test simple interactions? #5

amalloy opened this issue Feb 7, 2014 · 4 comments

Comments

@amalloy
Copy link
Contributor

amalloy commented Feb 7, 2014

I don't really know how to run any of this code right now "in isolation" - things seem geared towards playing entire games with a specified strategy. But there are a number of effects that I think have issues, and I'd like a way to write a test like "Here is a player's hand. After he does XYZ, his hand should change as follows, and the supply/trash should change as follows." This would help me verify my understanding of how things are put together, so that I can properly direct my efforts at improving them.

One example is that I think you're discarding cards immediately after playing them, rather than putting them into the play area and then discarding post-turn, which would be quite bad. Additionally, some trash/discard effects are not judicious enough, and can affect other cards in hand unintentionally. I'd like to test a player holding Throne Room and three Feast cards, and throning one of them. It should be the case that the played Feast is trashed while the other two stay in hand, and the player gains two cards. But I suspect that instead two Feasts will be trashed and one will be discarded.

@ajwheeler
Copy link
Contributor

I think a good strategy might be to start writing HSpec tests, ensuring that functions to state them concisely are available. This is good because (1) testing is good and (2) writing a lot of code to use the library will help to asses where its design could be better.

@egonSchiele
Copy link
Owner

What about this?

withHand lets you play one round with a hand of your choice. Then you return a boolean value indicating whether the test passed or failed. You can examine the player / the state etc, so it gives some flexibility.

I added a silly usage example with market.

@amalloy
Copy link
Contributor Author

amalloy commented Feb 8, 2014

Thanks, that's great. It will probably be important to be able to also specify the kingdom cards, so that it's possible to test things like "play Workshop, gaining Feast, then Village drawing Feast, then play Feast".

@egonSchiele
Copy link
Owner

Implemented in 534f26c. You can pass options in to withHand now, so you can specify the cards on the table with something like:

withHand [workshop, village, estate, estate, copper] [Card [feast]].

You also have the full game state, so you could modify the user's deck to place a feast on top for when you play village?

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

No branches or pull requests

3 participants