I’ve actually developed most of it by the time I write this blog

PHP part, unity part are almost the same, because KBEngine(kBE) has no contact with, in fact, many places PHP part of the logic can be directly transferred to KBE. In fact, for the sake of development efficiency, I still write the same logic quickly in PHP, so the composition of the project is a little weird

Currently working on the interface between KBE and PHP:

1. When entering a room, call the entry interface /room/ Join

2. In the preparation state, call /game/prepare

A. When PHP detects the number of prepared players preparedPlayerCount == room.maxPlayerCount (the last player calls the prepare interface), PHP end will generate a card pool of 52 cards (excluding Kings and big ones). Shuffle… shuffle… shuffle… shuffle… shuffle… shuffle Insert the card pool data into the database table cards_pool to generate a new poolId

B. Tell KBE to send the game start message to all players in the room and tell the poolId that was just generated (roundCount in all card pools in each room starts from 1, that is, create a new room to start the game and count the first round +1 for each new pool)

C. After receiving the message, players (unity terminal) call the card touch interface /game/getCards, and the cardsCount in the interface parameter depends on the specific game play to determine how many rows each player touches (for example, 13 rows of players), and prepare the game interface:

4. Notify KBE to send a message to the player who plays the card first (the player ID of the first card is determined by specific rules), unity terminal starts a 20-second countdown, in which the player needs to call the card interface /game/stepCards and splice the cards into a string as a parameter, if selected, the parameter will be null. The interface only records the card processing steps to the database table cards_pool_step, and does not verify whether the card type is legitimate, which is verified by unity terminal

5. Notify KBE to send a message to the next player and repeat step 4 until maxPlayerCount-1 card record is null to judge the end of this round, record the userID of this player and start the next round

6. Notify KBE to send a message to the player to play a card and repeat steps 4~5 until the number of cards in any player’s hand is 0(depending on the specific play to determine the victory condition). The round is over, and the client checks by itself

7. Repeat steps 2 to 6 until either player leaves the room

= = = = = = = = = = = = = = = = = = =

Interface test data: After a player touches a card from the table:

{" error ":" licensing Success ", "errorCode" : "200", "errorMsg" : "Get Cards Success", "cardPool" : {" poolId ":" 1 ", "createTime":"2016-11-04 04:50:15", "cards":"3_10|3_1|3_6|4_10|3_8|4_12|3_13|4_2|2_6|2_4|1_10|4_3|1_3|2_13|2_8|1_6|4_6|1_9|3_12|1_2|3_7|1_8|3_5|2_2|4_11|1_1 4 _13 _12 3 _4 | | 2 | | 1 _11 | 1 _4 | 2 _1 _3 | 3 | 2 _7 _10 | 2 | 4 _4 _9 | 3 | 2 _5 | 4 _7 | 1 _5 _2 | 3 | 1 _13 _11 | 2 | 3 _11 | 4 _9 | 4 _1 _12 | 1 | 4 _8 | 2 _3 _9 | 2 | 4 _5 ", "roomId":"1003", "roundCount":"1" }, "myCards":"1_7" }Copy the code

Prefixes 1 to 4 represent suits and suffixes represent numbers

Cards are the deck after the shuffle

Unity currently looks like this:

Play a 3 with a pair of steps (tablecloth UI material has not given me to use our mahjong tablecloth):

【 Web Version of Poker Games 】