H
H
hidden_pingvin2015-09-03 20:11:51
PHP
hidden_pingvin, 2015-09-03 20:11:51

What methods/libraries/technologies to use in a web project?

On the server, a small card game is given, written in php, without any interface, using built-in bots instead of users. The game is a knockout, the first one out is the winner, the last one remaining is the loser. Players take turns walking, when the queue ends, a new cycle begins, the queue starts again. Each player makes one move once per cycle.
The bots are now playing with each other and the client can only observe the results so far. It is necessary to:
1) Replace bots with people
2) And accordingly write an interface
Attention question:
Using what methods/libraries/technologies can you communicate with the client without interrupting the php script, collect data from him and use them to run the script?
It's just that now the script is running continuously, and the page is not reloaded (because if it is reloaded, it will be a new game), and with the addition of clients from which the request leaves through AJAX, this will no longer work.
I'm trying to dig in the direction of saving the positions of the players on the field by saving the game objects (serialize) in the database through each cycle and, accordingly, at the beginning of the next one, expanding it, but this is somehow sophisticated.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stanislav Makarov, 2015-09-03
@hidden_pingvin

> in the database through each cycle and, accordingly, at the beginning of the next one, unrolling it, but this is somehow subtly obtained.
There is nothing sophisticated about this, at least if you want to implement it all in PHP.
The pattern of using this language is such that it is better to let scripts work out quickly at the cost of the need to save state. Additional pluses automatically come:
scaling (one server can save the state, and another can extract it) and reliability - a fallen script will not kill the game.
As a database, I advise you to take Redis or Mongo, you can even pair it, RDBMS for saving the state of the game will be of little use, although it will be much more useful for saving and processing statistics, if any.

I
Ivan, 2015-09-03
@LiguidCool

So one AJAX figs, just when requested, it must pass the ID of the game (consider rooms) that it wants to enter.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question