Open artyom-poptsov opened 4 years ago
There is a break
statement on that line
Edit: OK. In #12 there is that line:
answer = curPlayer.getMap().viewMapArea(curPlayer.getPos(), curPlayer.getFieldOfView());
I think, when bot is restarted, curPlayer
becomes null
, so we need to save players list somewhere, or even implement registration system?
We should save game state somewhere (e.g. to a database) periodically or keep the actual state here altogether.
A more fast solution could be that we should notify the player that the bot was restarted and ask his/her to re-start game by issuing /start
command again.
Saving a game state using a manually written logic is a hell of a job. After each addition to the game (e.g. new player property, new thing, etc) manual serialization logic should be updated too.
Recently I looked at https://github.com/EsotericSoftware/kryo, but was not able to integrate it to my branch yet. Seems like Map
is a too complex object to be processed by Kryo without many modifications, and I have a little experience with Java serialization libraries.
The https://github.com/kostaskougios/cloning library is powerful enough to clone the entire game state automagically, but it is not purposed for serialization, only for cloning.
I will continue the investigation, but later. If no serialization library will be found, manual serializing may be considered as a last resort...
When bot is restarted and a user tries to interact with it, the bot produces the following error:
If the user issues
/start
command after restart, the error does not occur.