Thousand Card Game: Announcing A Trump Suit

in #utopian-io7 years ago (edited)

image.png

What is this project about?

This contribution is made to gornanization/1k. If you would like to find more info - I strongly recommend reading this post first.

PR:

https://github.com/gornanization/1k/pull/31

Details:

At the very beginning, I'm sorry to American audience for such click-bait title, but actually the feature I want to describe is really called so... see wiki article.

But what is a trump at all? When you have pair of a Queen and a King of the same suit (i.e.: [K♥ and Q♥] or [K♦ and Q♦ ], you basically can announce a trump. There are of course some requirements for it:

  • You have to be a trick leader and
  • before doing so, no card should be already thrown on a table.

We have to cover this case in our codebase. Within the current contribution throwCard action reducer has been updated. New helper functions was prepared in order to quickly find out, whether thrown card is also a trump announcement. Here is a set of steps we need to follow, while performing throw card action:

  1. Is a thrown card a first on the table? (no other cards specified in trickCards).
  2. If so, is the card rank a King or a Queen?
  3. If so, does the player have already marriage of given card suit? (checking cards['playerName'] field).
  4. If so, register a trump announcement by adding new entry in trumpAnnoncements.

If you are not familiar with state properties like trickCards, please take a look on my latest article. I have described whole game state object in details.

If one of the above described circumstances is not met, process of registering a trump is skipped. Two new unit tests has been added also to cover such cases. If you are interested in, see pull request on github page.

Coverage increased (+0.3%) to 95.803%
Bye, winners!

Image source: pixabay.com



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Your contribution cannot be approved yet because you have not given the Image Source (if its your own image then state that). See the Utopian Rules. Please edit your contribution to reapply for approval.

You may edit your post here, as shown below:

You can contact us on Discord.
[utopian-moderator]

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Hey @adasq I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x