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

Bug: MaxNbUpgrade not always respected when units_always_have_upgrades is used. #58

Closed
neocerber opened this issue Sep 26, 2023 · 2 comments

Comments

@neocerber
Copy link

neocerber commented Sep 26, 2023

What happened?

I have found a bug when units_always_have_upgrades is activated and the maxUpgrad option is used with either a locked items or starting units: the quantity of an upgrade that was reduced with maxUpgrad is ignored.

E.g.: Start unit Marauder. MaxUpgrade=3. Only one stim upgrade should have been kept but it is reintroduced in the "# Locking associated items for items that have already been placed when units_always_have_upgrades is on".

Another example is with Hellion locked and MaxUpgrade=3. With the seed 9490178312856908139 applied to the linked yaml, we have four upgrades:
Hellbat Aspect (Hellion) (Player 1)
Jump Jets (Hellion) (Player 1)
Progressive Stimpack (Hellion) (Player 1)
Progressive Stimpack (Hellion) (Player 1)

dsa_sc2.yaml.txt

With seed = 32955254312027006217 and removing "Hellbat Aspect (Hellion)" for the locked items, Marauder has 4 upgrades.

What were the expected results?

Only three ugrades per unit.

Software

Local generation

@neocerber
Copy link
Author

neocerber commented Sep 26, 2023

I think I found a solution. In short, keep in memory the quantity of upgrades before locking:

# Unit upgrades, lock all levels
# item_quantity = inventory.count(item)
# for _ in range(item_quantity):
for _ in range(inventory.count(item)):
    inventory.remove(item)
if item not in locked_items:
    # Lock all the associated items if not already locked
    # for _ in range(item_quantity):
    for _ in range(get_item_quantity(item)):
        locked_items.append(copy_item(item))

@Ziktofel
Copy link
Owner

Fixed:

Tested that this seed produced only 1 stim (cut from the bottom)
Tested that you get multiple stims when you should

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