Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACS attack IDs are not int #117

Closed
brodo97 opened this issue Aug 4, 2021 · 5 comments
Closed

ACS attack IDs are not int #117

brodo97 opened this issue Aug 4, 2021 · 5 comments

Comments

@brodo97
Copy link
Contributor

brodo97 commented Aug 4, 2021

This morning I woke up with a lot of errors. It turns out that if you're under an ACS attack the fleet ID will be something like 'union959'. So it will throw an exception cause it can't be casted to int.

How can we handle this problem without breaking anything?

Traceback (most recent call last):
  File "/home/pi/bot/FleetSave.py", line 234, in <module>
    check_attacked()
  File "/home/pi/bot/FleetSave.py", line 80, in check_attacked
    for hostile_fleet in EMPIRE.hostile_fleet():
  File "/home/pi/bot/venv/lib/python3.7/site-packages/ogame/__init__.py", line 840, in hostile_fleet
    for id in fleet_ids
  File "/home/pi/bot/venv/lib/python3.7/site-packages/ogame/__init__.py", line 840, in <listcomp>
    for id in fleet_ids
ValueError: invalid literal for int() with base 10: 'union959'
@PiecePaperCode
Copy link
Collaborator

i had the same problem today.
also on pyogame.net the bots broke down, when i was attacked

@brodo97
Copy link
Contributor Author

brodo97 commented Aug 5, 2021

I locally removed the int cast, in my case it shouldn't break anything cause I use enemy's fleet ID only for identification/tracking in a database. I guess it could even break friendly_fleet if you take part in a ACS

@PiecePaperCode
Copy link
Collaborator

does this solve the issue with the pull merge #118

@brodo97
Copy link
Contributor Author

brodo97 commented Aug 27, 2021

It should solve it!
I mean... Now all IDs a treated as strings. So it can accommodate either IDs like 123456 and 'union123'.
The only downside of this change is the need to change you're script if you're expecting it to be an int. Like for example storing the IDs in a DB. In fact I had to change my DB columns from INTEGER to TEXT.

I never tested an actual ACS attack vs me or vice versa, so I don't know what will happen when you'll try to return an 'unionXXX' fleet.

I realized I made a mistake!
I forgot to change this line!

self.assertIsInstance(fleet.id, int)

It should be

    self.assertIsInstance(fleet.id, str) 

@PiecePaperCode
Copy link
Collaborator

OK should be fixed now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants