Thousand Card Game: How about increasing bid value?

in #utopian-io7 years ago

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/34

Details:

I just realised, that bidding process should be extended. Why? It's not entirely true, that a player can make a bid only during BIDDING_IN_PROGRESS phase...

Imagine case, when player wins bidding process. When we have bidding process done, game logic makes a transition from BIDDING_IN_PROGRESS into BIDDING_FINISHED. Then through stock cards management and finally into BATTLE_START. But, during this transition, player who have won bidding might still increase his bid value. It is not allowed now, so within this contribution I want to fix it.

image.png

What should we do?

I was thinking about extending bid action. But I have realised quickly, that it might overcomplicate this validator, so preparing separated action for it seemd to be better option.

I have chosen name for it, increaseBid. What is does is basically the same as bid. It puts another entry into bid array.

image.png

As its totally separated action, we have to create appropriate validator for it, canIncreaseBid. Its logic is way complicated comparing to action itself. A couple of things should be considered before allowing player to increase bid:

  • Is it allowed phase (we can increase bid only at phases: BIDDING_FINISHED, SHARE_STOCK, ASSIGN_STOCK, BATTLE_START, TRICK_START or TRICK_IN_PROGRESS)?
  • Is bid value valid?
  • Has the player already won bidding phase?
  • Is bid value higher than last one?
  • If bid value is more than 120 points, has the player have a trump pair?
  • Is it a first trick, without any card thrown into the table?

If so, we can increase bid value. Within the contribution I have also provided public API unit tests to check whether it works as designed from API user perspective...

More details in pull request.

That's it for today, dear players!
See you soon!



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Congratulations @adasq! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the total payout received

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

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

Coin Marketplace

STEEM 0.18
TRX 0.16
JST 0.030
BTC 68272.80
ETH 2645.15
USDT 1.00
SBD 2.70