mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
SM: 0.4.2 percent goals fix (#2183)
fixed percent items goals that can fail generation (reported here https://discord.com/channels/731205301247803413/1147318124383850516/1147318124383850516 and here https://discord.com/channels/731205301247803413/1138137515505750108/1138137515505750108)
This commit is contained in:
@@ -511,16 +511,18 @@ class Objectives(object):
|
||||
def setScavengerHuntFunc(self, scavClearFunc):
|
||||
self.goals["finish scavenger hunt"].clearFunc = scavClearFunc
|
||||
|
||||
def setItemPercentFuncs(self, totalItemsCount=None, allUpgradeTypes=None):
|
||||
def getPctFunc(pct, totalItemsCount):
|
||||
def setItemPercentFuncs(self, totalItemsCount=None, allUpgradeTypes=None, container=None):
|
||||
def getPctFunc(total_needed, container):
|
||||
def f(sm, ap):
|
||||
nonlocal pct, totalItemsCount
|
||||
return sm.hasItemsPercent(pct, totalItemsCount)
|
||||
nonlocal total_needed, container
|
||||
locs_checked = len(container.getUsedLocs(lambda loc: True))
|
||||
return SMBool(locs_checked >= total_needed)
|
||||
return f
|
||||
|
||||
# AP: now based on location checks instead of local item
|
||||
for pct in [25,50,75,100]:
|
||||
goal = 'collect %d%% items' % pct
|
||||
self.goals[goal].clearFunc = getPctFunc(pct, totalItemsCount)
|
||||
self.goals[goal].clearFunc = getPctFunc(totalItemsCount * pct / 100, container)
|
||||
if allUpgradeTypes is not None:
|
||||
self.goals["collect all upgrades"].clearFunc = lambda sm, ap: sm.haveItems(allUpgradeTypes)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user