def addItem(self, item): # a new item is available self._items[item] = SMBool(True, items=[item]) if self.isCountItem(item): count = self._counts[item] + 1 self._counts[item] = count self.computeNewCacheKey(item, count) else: self.computeNewCacheKey(item, 1) Cache.update(self.cacheKey)
def removeItem(self, item): # randomizer removed an item (or the item was added to test a post available) if self.isCountItem(item): count = self._counts[item] - 1 self._counts[item] = count if count == 0: self._items[item] = smboolFalse self.computeNewCacheKey(item, count) else: self._items[item] = smboolFalse self.computeNewCacheKey(item, 0) Cache.update(self.cacheKey)
def addItems(self, items): if len(items) == 0: return for item in items: self._items[item] = SMBool(True, items=[item]) if self.isCountItem(item): count = self._counts[item] + 1 self._counts[item] = count self.computeNewCacheKey(item, count) else: self.computeNewCacheKey(item, 1) Cache.update(self.cacheKey)
def __init__(self): self._items = {} self._counts = {} # cache related self.cacheKey = 0 self.computeItemsPositions() Cache.reset() self.helpers = Logic.HelpersGraph(self) self.doorsManager = DoorsManager() self.createFacadeFunctions() self.createKnowsFunctions() self.resetItems()
def addItem(self, item): # a new item is available already = self.haveItem(item) isCount = self.isCountItem(item) if isCount or not already: self._items[item] = SMBool(True, items=[item]) else: # handle duplicate major items (plandos) self._items['dup_' + item] = True if isCount: count = self._counts[item] + 1 self._counts[item] = count self.computeNewCacheKey(item, count) else: self.computeNewCacheKey(item, 1) Cache.update(self.cacheKey)
def __init__(self, player=0, maxDiff=sys.maxsize, onlyBossLeft=False): self._items = {} self._counts = {} self.player = player self.maxDiff = maxDiff self.onlyBossLeft = onlyBossLeft # cache related self.cacheKey = 0 self.computeItemsPositions() Cache.reset() Logic.factory('vanilla') self.helpers = Logic.HelpersGraph(self) self.doorsManager = DoorsManager() self.createFacadeFunctions() self.createKnowsFunctions(player) self.resetItems()
def resetItems(self): self._items = {item: smboolFalse for item in self.items} self._counts = {item: 0 for item in self.countItems} self.cacheKey = 0 Cache.update(self.cacheKey)
def restoreKnows(self, knows): if isKnows(knows): self._createKnowsFunction(knows) Cache.reset() else: raise ValueError("Invalid knows " + str(knows))
def changeKnows(self, knows, newVal): if isKnows(knows): self._setKnowsFunction(knows, newVal) Cache.reset() else: raise ValueError("Invalid knows " + str(knows))