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

OVERLORDTRANSPORT not recognized #83

Open
RedPlatypus opened this issue Jul 13, 2018 · 4 comments
Open

OVERLORDTRANSPORT not recognized #83

RedPlatypus opened this issue Jul 13, 2018 · 4 comments

Comments

@RedPlatypus
Copy link

RedPlatypus commented Jul 13, 2018

I receive this error:
KeyError: <UnitTypeId.OVERLORDTRANSPORT: 893>
only for this unit in unit_typeid.py

I have a dictionary of units like:

ENEMY_DRAW_DICT = {
    NEXUS: [4, (0, 0, 255)],
    ASSIMILATOR: [2, (4, 10, 255)],
    CYBERNETICSCORE: [3, (8, 20, 255)],
    OVERLORDTRANSPORT: [1, (59, 230, 240)],
    ...
}

Later in a draw method, I use the unit's name to reference the size & color in my dictionary.
I only have a problem with OVERLORDTRANSPORT

# draw method
unit_name = enemy_unit.name.upper()
cv2.circle(
      game_data,
       (int(pos[0]), int(pos[1])),
        ENEMY_DRAW_DICT[UnitTypeId[unit_name]][0],
        ENEMY_DRAW_DICT[UnitTypeId[unit_name]][1],
         -1
)

ENEMY_DRAW_DICT[UnitTypeId[unit_name]][0], => should returns 1

Would appreciate debugging/ help on this. Cheers

@vgainullin
Copy link

OVERLORD is what you want, not OVERLORDTRANSPORT,
also say hi to sentdex

@RedPlatypus
Copy link
Author

@vgainullin Thank you! Will try when back tonight. If I forgot to include OVERLORD, then we definitely need a different error for this.

And will do haha

@RedPlatypus
Copy link
Author

To confirm OVERLORD was included. The error occurs when we have a dropperlord come into view. Again this isn't happening with any other unit_id constant. I think there is something wrong with OVERLORDTRANSPORT as a constant in unit_typeid.py or where ever is is used after that.

@vgainullin
Copy link

Your code should look like this:

ENEMY_DRAW_DICT = {
NEXUS: [4, (0, 0, 255)],
ASSIMILATOR: [2, (4, 10, 255)],
CYBERNETICSCORE: [3, (8, 20, 255)],
OVERLORD: [1, (59, 230, 240)],
...
}

And draw method something like this:

async def intel(self)
for unit in self.units.ready:
pos = unit.position
unit_type = str(unit.name).upper()
if unit_type in ENEMY_DRAW_DICT :
ud = ENEMY_DRAW_DICT [unit_type]
cv2.circle(game_data, (int(pos[0]), int(pos[1])), ud[0], (ud[1][0], ud[1][1], ud[1][2]), -1) # BGR

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