A cross-server battle method, device and medium for chess and card games
By selecting a battle server in a chess and card game and only performing game management and message forwarding on the central server, the problem of tight performance and data conflict in the cross-server technology is solved, and efficient player game management and data processing is achieved. Supports replay function for combat process.
Patent Information
- Application Number
- CN202210622681.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-01
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2042-06-01
AI Technical Summary
When existing cross-server technologies deal with a large number of player games, the central server performance is tight, hardware resources are wasted, game rule control and player asset management are complex, and data conflicts are prone to problems.
By selecting one between the first and second servers as the battle server, the central server is only responsible for game management and message forwarding. The battle character proxy object is used to communicate and business logic processing with the player client, avoiding multiple servers operating simultaneously Player data.
It reduces the performance pressure of the central server, simplifies data management, avoids data conflicts, improves the efficiency and development efficiency of the game server, and supports the replay function of the combat process.
Smart Images

Figure CN115253311B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of communication and data integration, and in particular to a cross-server battle method, device and medium for chess and card games. Background Art
[0002] As more and more players play chess and cards online, and due to the limitations of server hardware performance and the network status of players in different regions, game providers cannot place all players on one game server. In order to solve the above problems, game providers set up game servers in different regions to share a large number of players, but this also brings another problem: how can players on different game servers play the same game?
[0003] In order to enable players on different game servers to play the same game, cross-server technology came into being. The existing cross-server technology is implemented in the following ways: 1. Transmit player data from different game servers to an independent central server and create a player object on the central server. 2. The central server communicates with the player and uses the new player object to play the game.
[0004] However, the disadvantages of this approach are:
[0005] 1. If there is only one central server, it still cannot solve the problem of tight central server performance caused by a large number of players playing games;
[0006] 2. If there are multiple central servers, a large amount of hardware resources and virtual resources will be required, resulting in unnecessary waste;
[0007] 3. Game rules control and player asset management require additional programming in the central server;
[0008] 4. The game server where the player is initially located and the central server both have a player object of the same player. When both servers modify the player data, it is easy to cause player data conflicts, which in turn causes some data to be unable to be written. Summary of the invention
[0009] In view of this, the present invention provides a cross-server battle method, device and medium for chess and card games to solve the problems of tight central server performance and conflict in management of multiple sets of player object data caused by playing games on the central server.
[0010] To achieve the above object, the present invention provides the following solutions:
[0011] A cross-server battle method for a chess and card game, comprising:
[0012] When the first server receives a game request sent by the first player client, the first server sends the game request to the central server; the first server is the game server where the first player client is located;
[0013] The central server screens a player client that matches the first player client according to the game request, and when the first player client successfully matches with the second player client, the central server creates a game according to the matching result, and then enables the first player client and the second player client to enter the game through the first server and the second server; the second server is a game server where the second player client is located;
[0014] The central server determines a combat server according to the pressure value of the first server and the pressure value of the second server; the combat server is the first server or the second server;
[0015] The battle server creates a battle role proxy object corresponding to each player client in the game according to the game ID and battle data, and the chess and card game starts when the battle role proxy object is created; the battle role proxy object is used to communicate with the corresponding player client and process data in business logic.
[0016] Optionally, it also includes:
[0017] When the first server receives an operation command sent by the first player client, and the battle server is the first server, the battle role proxy object corresponding to the first player client in the battle server performs a logic judgment on the operation command, and sends the logic judgment result to the first server, and the first server performs a game operation according to the logic judgment result, and sends the game operation result to the first player client;
[0018] When the first server receives an operation command sent by the first player client and the battle server is the second server, the first server sends the operation instruction to the central server, the central server sends the operation instruction to the battle server, the battle character proxy object corresponding to the first player client in the battle server performs logical judgment on the operation command and sends the logical judgment result to the central server, the central server sends the logical judgment result to the first server, the first server performs game operation according to the logical judgment result, and sends the game operation result to the first player client.
[0019] Optionally, it also includes:
[0020] When the battle server is the first server, the battle server broadcasts the logic judgment result to each of the second servers through the central server;
[0021] When the battle server is the second server, the battle server broadcasts the logic judgment result to the first server and other second servers through the central server; other second servers are second servers other than the battle server.
[0022] Optionally, the first player client displays the game operation result.
[0023] Optionally, it also includes: when the first server and the second server are started, the first server and the second server both communicate with the central server by creating a link, and the central server saves the ID of the game server communicating with the central server and the corresponding link information.
[0024] Optionally, the communication information sent by the first server or the second server to the central server includes the ID of the game, the destination of information transmission, the ID of the player client and the operation instruction.
[0025] Optionally, the first server records useful information of the first player client during the game by means of a filter; and the second server records useful information of the second player client during the game by means of a filter.
[0026] An electronic device comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0027] The memory is used to store computer programs;
[0028] The processor is used to implement the steps of the cross-server battle method of chess and card games when executing the computer program stored in the memory.
[0029] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of a cross-server battle method for a chess and card game.
[0030] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects:
[0031] The central server provided by the present invention is only responsible for game management and message forwarding, which greatly reduces the performance pressure of the central server; in addition, since the combat role proxy object is only used to communicate with the corresponding player client and process data in business logic, the actual data processing of the player is still in the game server where the original player is located, and the data management is simple, that is, only the game server where the player is located is used to process its own player data, avoiding the risk of data conflicts caused by multiple servers operating player data at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0033] Figure 1 This is the combat role agent class diagram of the present invention;
[0034] Figure 2 It is the network link state diagram of the present invention;
[0035] Figure 3 This is a diagram of the communication information data structure of the present invention;
[0036] Figure 4 It is a flow chart of the cross-server battle method of the chess and card game of the present invention;
[0037] Figure 5 This is a battle flow chart of players in the chess and card game of the present invention;
[0038] Figure 6 This is a battle sequence diagram of players in the chess and card game of the present invention; Figure 6 (a) is a timing diagram of a chess and card game player creating a game; Figure 6 (b) is a battle sequence diagram of players in the chess and card game of the present invention. DETAILED DESCRIPTION
[0039] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0040] The present invention provides a cross-server battle method, device and medium for chess and card games. The present invention is suitable for players located on different game servers to quickly conduct battles without switching servers, while facilitating data management, reducing the pressure on the central server, and supporting the battle process replay function.
[0041] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0042] Name definition:
[0043] First player client (or player 1): The first player client that sends a game request.
[0044] Second player client (or player 2): The second and subsequent player clients that send game requests. The number of second player clients is determined by the game rules.
[0045] First server (or server 1): the game server where the first player client is located.
[0046] Second server (or server 2): the game server where the second player client is located.
[0047] Central server: refers to a server that is independent of the game server and is used for information forwarding and player matching between different game servers. After each game server is started, a link will be created to connect to the central server, but the game servers are unaware of each other's existence.
[0048] Battle Server: A server used to process game rules and logic, essentially the first server or the second server.
[0049] Forward: Send the received information intact to another game server.
[0050] Broadcast: Send information to all player clients in the game.
[0051] Player client: The player's terminal, which can be a mobile phone or a computer.
[0052] Game server pressure value: the current number of players in the game server, memory usage, and the number of games when acting as a battle server (there may be multiple games in a game server at the same time, and different players play different games). These data are weighted and added to obtain the game server pressure value.
[0053] Weighted addition: It is divided into two steps. The first step is to multiply the basic value by the corresponding configured weight to get the calculated value; the second step is to add up all the calculated values.
[0054] Combat role agent: Figure 1 As shown, it is used to encapsulate the combat roles, transform the data in the game process and the outer packaging of the network link; if the player character is on the game server, it communicates with the player client directly through the original player link; if the player character is on other game servers, it communicates through the process of central server forwarding <----> corresponding game server forwarding <----> player client, thereby reducing the coupling degree and ensuring that the logic processing does not need to consider which game server the player is on.
[0055] Network link status diagram: Figure 2 As shown, each game server will create a link with the central server when it starts up for communication with the central server. The central server will save the game server id and the corresponding link information. When each player logs in to the player client online, the game server of the player client will send registration information to the central server to record the game server where the player is located.
[0056] Communication information data structure: such as Figure 3 As shown, the way in which game servers communicate with each other is: game server 1 sends communication information to the central server (carrying information: 1. Game ID, indicating which game it is, this ID is generated when the central server creates the game and sent to all game servers in the game; 2. Sent to the target location, divided by type, into battle server, game server where a certain player is located, and all game servers; 3. Player ID list, if the target location is the game server where a certain player is located, the player ID in this data is used to find the corresponding game server; 4. Other custom information carried by each, such as information used for business logic processing), the central server will find the target server according to the game ID and the information sent to the target location and forward the message to the target server.
[0057] Figure 4 The flowchart of the cross-server battle method of the chess and card game of the present invention is as follows: Figure 4 As shown, the cross-server battle method of a chess and card game provided by an embodiment of the present invention includes:
[0058] Step 100: When the first server receives a game request sent by the first player client, the first server sends the game request to the central server.
[0059] Step 200: The central server screens a second player client that matches the first player client according to the game request, and when the first player client is successfully matched with the second player client, the central server creates a game according to the matching result, and then allows the first player client and the second player client to enter the game through the first server and the second server.
[0060] Step 300: The central server determines a combat server according to the pressure value of the first server and the pressure value of the second server; the combat server is the first server or the second server.
[0061] Step 400: The battle server creates a battle role proxy object corresponding to each player client in the game according to the game ID and battle data, and the chess and card game starts when the battle role proxy object is created; the battle role proxy object is used to communicate with the corresponding player client and process data in business logic.
[0062] Furthermore, the method provided by the embodiment of the present invention also includes:
[0063] When the first server receives an operation command sent by the first player client and the battle server is the first server, the battle character proxy object corresponding to the first player client in the battle server performs logical judgment on the operation command and sends the logical judgment result to the first server. The first server executes the game operation according to the logical judgment result and sends the game operation result to the first player client; the first player client displays the game operation result.
[0064] When the first server receives an operation command sent by the first player client and the battle server is the second server, the first server sends the operation instruction to the central server, the central server sends the operation instruction to the battle server, the battle role proxy object corresponding to the first player client in the battle server performs logical judgment on the operation command and sends the logical judgment result to the central server, the central server sends the logical judgment result to the first server, the first server performs game operation according to the logical judgment result, and sends the game operation result to the first player client; the first player client displays the game operation result.
[0065] Wherein, when the battle server is the first server, the battle server broadcasts the logic judgment result to each of the second servers through the central server.
[0066] When the battle server is the second server, the battle server broadcasts the logic judgment result to the first server and other second servers through the central server; other second servers are second servers other than the battle server.
[0067] The processing process of the second player client is the same as that of the first player client, which will not be described in detail here.
[0068] Preferably, in an embodiment of the present invention, when the first server and the second server are started, the first server and the second server both communicate with the central server by creating a link, and the central server saves the ID of the game server communicating with the central server and the corresponding link information.
[0069] The first server records useful information of the first player client during the game by means of a filter; the second server records useful information of the second player client during the game by means of a filter
[0070] First, take player 1 and player 2 as an example to illustrate the cross-server battle method of a chess and card game provided by an embodiment of the present invention. Figure 5 and Figure 6 As shown, including:
[0071] First, player 1 sends a game request, which is received by server 1 and forwarded to the central server for matching.
[0072] Secondly, after receiving the request, the central server searches for the corresponding player 2. If it does not find the corresponding player 2, it waits for more players to request a game. If it finds the corresponding player 2, it adds player 1 and player 2 to the new game, notifies server 1 and server 2, and player 1 and player 2 find the game and start the game.
[0073] Then, the central server selects a better server from Server 1 and Server 2 to act as the battle server. Each game server in the game sends its current server pressure to the central server. The central server compares the pressure of Server 1 and Server 2 in the game and selects the server with the smallest value to act as the battle server. The weight can be customized.
[0074] Next, Server 1 and Server 2 send battle data to the battle server. After receiving the data, the battle server creates a battle character proxy object based on the game ID and player information and joins the game to handle communication with the players and data processing in business logic.
[0075] Next, player 1 sends an operation command to server 1, and server 1 forwards the command to the battle server. The battle server accepts the player's operation and performs logical processing. The processing rules here are strongly business-related, and different solutions are specified according to the specific game rules.
[0076] For example: in a grid-walking game, the battle server receives the operation of player 1 clicking the dice, and determines whether the player can perform this operation in the current round. If yes, the player continues, then randomly rolls the dice number, and moves the chess piece of player 1 forward the corresponding number of steps. Finally, the result is sent to the client of the player (the player operation is successful, the random dice number, the final position of the chess piece of player 1, etc. are all sent to the corresponding player client through the battle role agent of all players, thereby showing the operation and performance of the player). If not, the result (player operation failed, reason for failure) is directly sent to the client of the player, prompting the player that the operation failed.
[0077] Finally, the result broadcast is sent to Server 1 and Server 2. After receiving the information, Server 1 and Server 2 forward it to the corresponding player client. The player client receives the result information and displays it.
[0078] To achieve the above-mentioned purpose, an embodiment of the present invention further provides an electronic device, which includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; the memory is used to store computer programs; and the processor is used to implement the steps of a cross-server battle method for chess and card games when executing the computer program stored in the memory.
[0079] In addition, an embodiment of the present invention also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of a cross-server battle method for a chess and card game are implemented.
[0080] Compared with the prior art, the present invention has the following advantages:
[0081] 1. The central server set up in the present invention is only responsible for game management and message forwarding, which greatly reduces the performance pressure of the central server; game management: which players are in the same game and the game servers where these players are located; message forwarding: forwarding information between different game servers in the same game.
[0082] 2. Players do not need to connect to the central server additionally, and there is no need to switch servers when playing against other players.
[0083] 3. During initialization, there is no need to transmit all player information, only battle-related information is needed, which reduces network resource consumption.
[0084] 4. Each game server only connects to the central server and does not need to know the existence of other game servers. The central server is responsible for sending information to other game servers to avoid the problem of too many connections when a single game server has too many games.
[0085] 5. The actual data processing of the player is still in the game server where the original player is located. The data management is simple, that is, only the game server where the player is located is used to process its own player data, avoiding the risk of data conflicts caused by multiple servers operating player data at the same time.
[0086] 6. The game server can record useful information during the player's game process through filters.
[0087] 7. Add combat role proxy to decouple cross-server communication and logic. When developers develop game logic, they do not need to consider whether the game server the player is on is the game server of this game, which improves the development efficiency of developers.
[0088] 8. The player's operations are encapsulated into command information and sent to the battle server. The battle server broadcasts the result information in the form of status information to other players. Players can replay previous games by re-entering the command list and then replaying the game.
[0089] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0090] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the method and core idea of the present invention. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A cross-server battle method for chess and card games, characterized in that: include: When the first server receives the game request sent by the first player client, the first server sends the game request to the central server; The first server is a game server where the first player client is located; The central server screens a player client that matches the first player client according to the game request, and when the first player client is successfully matched with the second player client, the central server creates a game according to the matching result, and then enables the first player client and the second player client to enter the game through the first server and the second server; The second server is a game server where the second player client is located; The central server determines the combat server according to the pressure value of the first server and the pressure value of the second server; The battle server is the first server or the second server; the pressure value is obtained by weighted addition of the current number of players in the game server, the memory usage, and the number of games when the server acts as the battle server; The battle server creates a battle role proxy object corresponding to each player client in the game according to the game ID and battle data, and the chess and card game starts after the battle role proxy object is created; The combat role proxy object is used to communicate with the corresponding player client and process data in business logic; The combat role proxy is used to encapsulate combat roles, transform data during the game, and provide an outer layer of packaging for network links; When the first server receives an operation command sent by the first player client, and the battle server is the first server, the battle role proxy object corresponding to the first player client in the battle server performs a logic judgment on the operation command, and sends the logic judgment result to the first server, and the first server performs a game operation according to the logic judgment result, and sends the game operation result to the first player client; When the first server receives an operation command sent by the first player client, and the battle server is the second server, the first server sends the operation command to the central server, the central server sends the operation command to the battle server, the battle role proxy object corresponding to the first player client in the battle server performs a logical judgment on the operation command, and sends the logical judgment result to the central server, the central server sends the logical judgment result to the first server, the first server performs a game operation according to the logical judgment result, and sends the game operation result to the first player client; When the battle server is the first server, the battle server broadcasts the logic judgment result to each of the second servers through the central server; When the battle server is the second server, the battle server broadcasts the logic judgment result to the first server and other second servers through the central server; other second servers are second servers other than the battle server.
2. A cross-server battle method for chess and card games according to claim 1, characterized in that: The cross-server battle method for chess and card games also includes: the first player client displays the game operation results.
3. A cross-server battle method for chess and card games according to claim 1, characterized in that: The cross-server battle method for chess and card games also includes: when the first server and the second server are started, the first server and the second server both communicate with the central server by creating a link, and the central server saves the ID of the game server communicating with the central server and the corresponding link information.
4. A cross-server battle method for chess and card games according to claim 1, characterized in that: The communication information sent by the first server or the second server to the central server includes the ID of the game, the destination of information transmission, the ID of the player client and the operation command.
5. A cross-server battle method for chess and card games according to claim 1, characterized in that: The first server records useful information of the first player client during the game by means of a filter; The second server records useful information of the second player client during the game by means of a filter.
6. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; The memory is used to store computer programs; The processor is used to implement the cross-server battle method of chess and card games described in any one of claims 1-5 when executing the computer program stored in the memory.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the cross-server battle method for chess and card games described in any one of claims 1-5 is implemented.