RobinReinecke / GrepBOTlis

Grepolis Bot in C#
4 stars 2 forks source link

"Nothing to build" #6

Closed huguesdevimeux closed 4 years ago

huguesdevimeux commented 4 years ago

Hi,

Basically the title. I put on the GUI a building queue but the logs say "Nothing to build". (and thus nothing is built). Same for the units.

I play on a french world (so everything is in-game is written in French - maybe it is the source of the issue?

How could I fix it?

I love your work.

RobinReinecke commented 4 years ago

Hi, thanks for your commendation :) I must admit that I havn't played Grepolis for a while and don't develop the bot at the moment because I can't test it. But I can help you find the cause for your problem. As far as I know the bot is language indipendent. Good news for you :)

Please have a look at the Controller.cs On line 1290 you got "CheckBuildingQueueRequest". This method gets called everytime the bot tries to build something. At line 1372 starts the building queue part. It's much easier if you set a breakpoint here and look what happens. Maybe the bot thinks the buildings are not upgradable at line 1395 and concludes "Nothing to build". This could be caused if they changed some server responses. For example the BuildingBuildData. Have a look at line 2763 "BuildingBuildDatasResponse". In line 2804 the bot gets the information if a building is upgradeable. Or they changed the Main Building response. At line 3821 "CheckMainBuildingResponse". At line 3857 the bot gets the desired information. Set breakpoints here and look what the reponses looks like.

I personally think this is caused by a small change in a response like the Main Building Response. So i would start looking here.

I hope this helps you. If you need further help, feel free to ask me :)

huguesdevimeux commented 4 years ago

HI,

thanks for your answer! I have found the solution to my issue, which was quite obvious. I didn't have enough resources to upgrade my building. In this case, the bot just says "Nothing to build", because at line 1396 the condition is not satisfied. I have added an else statement at after that condition, which logs "building can not be upgraded. Maybe you do not have enough resources.", so it is better (maybe).

I also have had another issue, which is that the building queue within the bot was not emptying as the buildings were built by the bot. I have fixed that by adding at line 1431 m_Town.BotBuildingQueue.RemoveAt(0);. It seems to work; should I add something else?

Finally, the in-game building queue does not refresh (and thus also the queue within the bot that shows the queue in-game(yea that's complicated)) when the bot adds a building. When I re-start Grepolis I can see the building in the queue, so it has been added, it was just not visible. How would it be possible to fix that? Maybe by refreshing the page.

PS : Sorry if I said idiot stuff but I am a beginner in both Grepolis and C :) .

RobinReinecke commented 4 years ago

Okay nice. Then the code is not faulty after all :)! Thanks for your fixes. Keep going 👍

The ingame queue (in the browser control) not updating is a bug caused by the fact, that the bot queues the building by directly communicating with the server. The browser control does not know a new builiding was queued. I don't see a solution here to fix this except reloading the browser. But I thought the bot queue gets updated.. Maybe this is a real bug because the bot does not update his queue. At line 3889 the bot should clear his ingame queue. Maybe this isn't working anymore. Or maybe it's just missing an event calling the UpdateQueueGUI method in the MainForm.cs to update the GUI. Have you tried switching the towns in the queue tab?

If you are done with your improvement to the code, please create a pull request so I can keep this project up to date :).

PS: You are absolutely welcome! Feel free to ask more. I used this project in my early programming state to improve my skills too :)

huguesdevimeux commented 4 years ago

Hi,

I have fixed that bug. I think the issue was relative to the time zone. The bot is settled with the time zone of the computer, but Grepolis is settled with UTC. Now it seems to work. I don't remember what exactly it was, but I have made a commit :).

I will continue to work on the bot, I think. I will create a pull request asap!