def generateWeeklyCatalog(self, avatar, week, monthlyCatalog): weeklyCatalog = CatalogItemList.CatalogItemList() self.notify.debug('Generating catalog for %s for week %s.' % (avatar.doId, week)) if week >= 1 and week <= len(WeeklySchedule): saleItem = 0 schedule = WeeklySchedule[week - 1] if isinstance(schedule, Sale): schedule = schedule.args saleItem = 1 for item in schedule: weeklyCatalog += self.__selectItem(avatar, item, monthlyCatalog, saleItem=saleItem) if nextAvailableCloset not in schedule: weeklyCatalog += self.__selectItem(avatar, nextAvailableCloset, monthlyCatalog, saleItem=0) if nextAvailableBank not in schedule: weeklyCatalog += self.__selectItem(avatar, nextAvailableBank, monthlyCatalog, saleItem = 0) if nextAvailableTank not in schedule: weeklyCatalog += self.__selectItem(avatar, nextAvailableTank, monthlyCatalog, saleItem = 0) if time.time() < 1096617600.0: def hasPetTrick(catalog): for item in catalog: if isinstance(item, CatalogPetTrickItem): return 1 return 0 if not hasPetTrick(weeklyCatalog) and not hasPetTrick(avatar.weeklyCatalog) and not hasPetTrick(avatar.backCatalog): self.notify.debug('Artificially adding pet trick to catalog') weeklyCatalog += self.__selectItem(avatar, 5000, monthlyCatalog, saleItem=saleItem) self.notify.debug('Generated catalog: %s' % weeklyCatalog) return weeklyCatalog
def generateBackCatalog(self, avatar, week, previousWeek, weeklyCatalog): backCatalog = CatalogItemList.CatalogItemList() lastBackCatalog = avatar.backCatalog[:] thisWeek = min(len(WeeklySchedule), week - 1) lastWeek = min(len(WeeklySchedule), previousWeek) for week in range(thisWeek, lastWeek, -1): self.notify.debug('Adding items from week %s to back catalog' % week) schedule = WeeklySchedule[week - 1] if not isinstance(schedule, Sale): for item in schedule: for item in self._CatalogGenerator__selectItem(avatar, item, weeklyCatalog + backCatalog): item.putInBackCatalog(backCatalog, lastBackCatalog) if previousWeek < week: self.notify.debug('Adding current items from week %s to back catalog' % previousWeek) for item in avatar.weeklyCatalog: item.putInBackCatalog(backCatalog, lastBackCatalog) backCatalog += lastBackCatalog for item in weeklyCatalog: while item in backCatalog: backCatalog.remove(item) return backCatalog
def generateMonthlyCatalog(self, avatar, weekStart): dayNumber = int(weekStart / (24 * 60)) itemLists = self.__getMonthlyItemLists(dayNumber, weekStart) monthlyCatalog = CatalogItemList.CatalogItemList() for list in itemLists: saleItem = 0 if isinstance(list, Sale): list = list.args saleItem = 1 for item in list: monthlyCatalog += self.__selectItem(avatar, item, [], saleItem=saleItem) return monthlyCatalog
def setDeliverySchedule(self, onOrder): self.onOrder = CatalogItemList.CatalogItemList( onOrder.decode('base64'), store=CatalogItem.Customization | CatalogItem.DeliveryDate)
def setMailboxContents(self, contents): self.mailboxContents = CatalogItemList.CatalogItemList( contents.decode('base64'), store=CatalogItem.Customization)
def generateTFPrizeCatalog(self, avatar): prizeCatalog = CatalogItemList.CatalogItemList() for item in TFPrizeCatalog: prizeCatalog += self.__selectItem(avatar, item, []) return prizeCatalog