Thousand Card Game: The battle is over...

in utopian-io •  7 years ago  (edited)

image.png
Image source: pixabay.com

What is this project about?

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

PR:

https://github.com/gornanization/1k-table/pull/11

Details:

Recently I was writing about covering battle case. It was about throwing cards into a table. Today I would like to continue from this point.

How about a next step?

Imagine the last trick in a battle. After assigning won cards from a trick to a player, we must follow steps:

  1. Move all cards (won by the players) into a deck position (as it's the end of the battle).
  2. Show Points View to inform people about overall score obtained by the players.
  3. Initialise new battle by dealing cards to a player and the stock area.
  4. Show Bidding View.

All steps have been covered by the provided pull request. The overall result is available here: (Sorry for lagged gif)

You guys know, that I really want this game to be as flexible as possible. I want to let the game to be recreated from any point you want. Game logic (github.com/gornanization/1k) was designed in the way we can take an advantage of it. In unit tests section I provided set of cases which recreates the game from specific point. I want to something similar in the UI.

That's why game-cases.js file has been created. It's a simple object containing predefined state, describing the starting point of the game and actions, representing set of player actions which should be performed after game recreation. Need an example?

image.png

Each entry has it's own name. REGISTERING_PLAYERS_IN_PROGRESS in this case. What it does is reproducing player registration phase. As you can see we have already two players registered (:16 - :17). After initialising game we should see the Players View. Then we push another registration action (:31) and observe a result.

Having such defined game case, we can recreate the state by calling:

reproduceGameCase(cases.REGISTERING_PLAYERS_IN_PROGRESS);

reproduceGameCase function is no big deal:

image.png

initializeTable is a general file when the entire interaction between game logic and UI logic connections is managed. Within the contribution I defined 6 game cases which covers almost each part of the game. As always, for those more curious pull request is ready.

Bye, winners!

Recent articles:

  1. Thousand Card Game: Refactoring 'Card' Object
  2. Thousand Card Game: Throwing card phase coverage!



Posted on Utopian.io - Rewarding Open Source Contributors

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

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