DANIEL: New catalog year shit

This commit is contained in:
John 2015-05-30 11:30:18 +03:00 committed by Loudrob
parent 6bfb28c36f
commit a65952bb67
2 changed files with 40 additions and 119 deletions

View file

@ -1,7 +1,7 @@
from direct.directnotify import DirectNotifyGlobal from direct.directnotify import DirectNotifyGlobal
import CatalogItem import CatalogItem
import CatalogItemList import CatalogItemList
from CatalogFurnitureItem import CatalogFurnitureItem, nextAvailableCloset, nextAvailableBank, getAllClosets, get50ItemCloset, getMaxClosets, get50ItemTrunk from CatalogFurnitureItem import CatalogFurnitureItem, nextAvailableCloset, nextAvailableBank, getAllClosets, get50ItemCloset, getMaxClosets, get50ItemTrunk, getAllBanks
from CatalogAnimatedFurnitureItem import CatalogAnimatedFurnitureItem from CatalogAnimatedFurnitureItem import CatalogAnimatedFurnitureItem
from CatalogClothingItem import CatalogClothingItem, getAllClothes from CatalogClothingItem import CatalogClothingItem, getAllClothes
from CatalogChatItem import CatalogChatItem, getChatRange from CatalogChatItem import CatalogChatItem, getChatRange
@ -401,29 +401,7 @@ MonthlySchedule = ((7,
15, 15,
8, 8,
15, 15,
2010,
2010,
((4, 2940),)), ((4, 2940),)),
(9,
1,
9,
30,
(CatalogGardenItem(135, 1),)),
(1,
1,
1,
31,
(CatalogGardenItem(135, 1),)),
(4,
1,
4,
30,
(CatalogGardenItem(135, 1),)),
(6,
1,
6,
30,
(CatalogGardenItem(135, 1),)),
(6, (6,
26, 26,
7, 7,
@ -482,22 +460,16 @@ MonthlySchedule = ((7,
9, 9,
7, 7,
15, 15,
2010,
2010,
(CatalogClothingItem(1751, 0),)), (CatalogClothingItem(1751, 0),)),
(6, (6,
14, 14,
7, 7,
15, 15,
2010,
2010,
(CatalogClothingItem(1754, 0), CatalogClothingItem(1755, 0), CatalogClothingItem(1756, 0))), (CatalogClothingItem(1754, 0), CatalogClothingItem(1755, 0), CatalogClothingItem(1756, 0))),
(7, (7,
21, 21,
8, 8,
17, 17,
2010,
2010,
(CatalogClothingItem(1749, 0), (CatalogClothingItem(1749, 0),
CatalogClothingItem(1750, 0), CatalogClothingItem(1750, 0),
CatalogClothingItem(1757, 0), CatalogClothingItem(1757, 0),
@ -506,8 +478,6 @@ MonthlySchedule = ((7,
25, 25,
9, 9,
21, 21,
2010,
2010,
(CatalogClothingItem(1763, 0),)), (CatalogClothingItem(1763, 0),)),
(6, (6,
5, 5,
@ -528,6 +498,7 @@ MonthlySchedule = ((7,
CatalogRentalItem(2, 2890, 1000), CatalogRentalItem(2, 2890, 1000),
CatalogGardenStarterItem(), CatalogGardenStarterItem(),
CatalogNametagItem(0), CatalogNametagItem(0),
CatalogFurnitureItem(1530),
CatalogClothingItem(1605, 0, True), CatalogClothingItem(1605, 0, True),
CatalogClothingItem(1602, 0, True), CatalogClothingItem(1602, 0, True),
CatalogClothingItem(1604, 0, True), CatalogClothingItem(1604, 0, True),
@ -549,15 +520,11 @@ MonthlySchedule = ((7,
26, 26,
6, 6,
30, 30,
2013,
2013,
(CatalogAccessoryItem(175),)), (CatalogAccessoryItem(175),)),
(8, (8,
27, 27,
9, 9,
5, 5,
2013,
2013,
((3, 2900), ((3, 2900),
CatalogChatItem(10003), CatalogChatItem(10003),
CatalogClothingItem(1001, 0), CatalogClothingItem(1001, 0),
@ -607,8 +574,6 @@ MonthlySchedule = ((7,
3, 3,
9, 9,
12, 12,
2013,
2013,
((3, 2910), ((3, 2910),
CatalogFurnitureItem(680), CatalogFurnitureItem(680),
CatalogFurnitureItem(681), CatalogFurnitureItem(681),
@ -643,8 +608,6 @@ MonthlySchedule = ((7,
20, 20,
9, 9,
19, 19,
2013,
2013,
(CatalogAccessoryItem(101), (CatalogAccessoryItem(101),
CatalogAccessoryItem(103), CatalogAccessoryItem(103),
CatalogAccessoryItem(117), CatalogAccessoryItem(117),
@ -1517,12 +1480,9 @@ class CatalogGenerator:
def __init__(self): def __init__(self):
self.__itemLists = {} self.__itemLists = {}
self.__releasedItemLists = {}
def getReleasedCatalogList(self, weekStart): if config.GetBool('save-catalog-schedule', False):
dayNumber = int(weekStart / (24 * 60)) self.outputSchedule('catalog-schedule.txt')
itemLists = self.__getReleasedItemLists(dayNumber, weekStart)
return itemLists
def generateMonthlyCatalog(self, avatar, weekStart): def generateMonthlyCatalog(self, avatar, weekStart):
dayNumber = int(weekStart / (24 * 60)) dayNumber = int(weekStart / (24 * 60))
@ -1560,7 +1520,7 @@ class CatalogGenerator:
weeklyCatalog += self.__selectItem(avatar, nextAvailableTank, monthlyCatalog, saleItem=0) weeklyCatalog += self.__selectItem(avatar, nextAvailableTank, monthlyCatalog, saleItem=0)
weeklyCatalog += self.__selectItem(avatar, get50ItemTrunk, monthlyCatalog, saleItem=0) weeklyCatalog += self.__selectItem(avatar, get50ItemTrunk, monthlyCatalog, saleItem=0)
if time.time() < 1096617600.0: if True:
def hasPetTrick(catalog): def hasPetTrick(catalog):
for item in catalog: for item in catalog:
@ -1570,7 +1530,6 @@ class CatalogGenerator:
return 0 return 0
if not hasPetTrick(weeklyCatalog) and not hasPetTrick(avatar.weeklyCatalog) and not hasPetTrick(avatar.backCatalog): 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) weeklyCatalog += self.__selectItem(avatar, 5000, monthlyCatalog, saleItem=saleItem)
self.notify.debug('Generated catalog: %s' % weeklyCatalog) self.notify.debug('Generated catalog: %s' % weeklyCatalog)
return weeklyCatalog return weeklyCatalog
@ -1600,45 +1559,12 @@ class CatalogGenerator:
return backCatalog return backCatalog
def __getReleasedItemLists(self, dayNumber, weekStart):
itemLists = self.__releasedItemLists.get(dayNumber)
if itemLists != None:
return itemLists
else:
self.__releasedItemLists.clear()
testDaysAhead = config.GetInt('test-server-holiday-days-ahead', 0)
nowtuple = time.localtime(weekStart * 60 + testDaysAhead * 24 * 60 * 60)
year = nowtuple[0]
month = nowtuple[1]
day = nowtuple[2]
itemLists = []
for monthlyItems in MonthlySchedule:
startMM = monthlyItems[0]
startDD = monthlyItems[1]
endMM = monthlyItems[2]
endDD = monthlyItems[3]
if len(monthlyItems) == 7:
startYYYY = monthlyItems[4]
endYYYY = monthlyItems[5]
list = monthlyItems[6]
else:
startYYYY = 1969
endYYYY = year
list = monthlyItems[4]
pastStart = year > startYYYY or (year == startYYYY and (month > startMM or (month == startMM and day >= startDD)))
if pastStart:
itemLists.append(list)
self.__releasedItemLists[dayNumber] = itemLists
return itemLists
def __getMonthlyItemLists(self, dayNumber, weekStart): def __getMonthlyItemLists(self, dayNumber, weekStart):
itemLists = self.__itemLists.get(dayNumber) itemLists = self.__itemLists.get(dayNumber)
if itemLists != None: if itemLists != None:
return itemLists return itemLists
testDaysAhead = config.GetInt('test-server-holiday-days-ahead', 0) testDaysAhead = config.GetInt('test-server-holiday-days-ahead', 0)
nowtuple = time.localtime(weekStart * 60 + testDaysAhead * 24 * 60 * 60) nowtuple = time.localtime(weekStart * 60 + testDaysAhead * 24 * 60 * 60)
year = nowtuple[0]
month = nowtuple[1] month = nowtuple[1]
day = nowtuple[2] day = nowtuple[2]
self.notify.debug('Generating seasonal itemLists for %s/%s.' % (month, day)) self.notify.debug('Generating seasonal itemLists for %s/%s.' % (month, day))
@ -1648,16 +1574,9 @@ class CatalogGenerator:
startDD = monthlyItems[1] startDD = monthlyItems[1]
endMM = monthlyItems[2] endMM = monthlyItems[2]
endDD = monthlyItems[3] endDD = monthlyItems[3]
if len(monthlyItems) == 7: list = monthlyItems[4]
startYYYY = monthlyItems[4] pastStart = month > startMM or (month == startMM and day >= startDD)
endYYYY = monthlyItems[5] beforeEnd = month < endMM or (month == endMM and day <= endDD)
list = monthlyItems[6]
else:
startYYYY = 1969
endYYYY = year
list = monthlyItems[4]
pastStart = year >= startYYYY and (month > startMM or (month == startMM and day >= startDD))
beforeEnd = year <= endYYYY and (month < endMM or (month == endMM and day <= endDD))
if endMM < startMM: if endMM < startMM:
if pastStart or beforeEnd: if pastStart or beforeEnd:
itemLists.append(list) itemLists.append(list)
@ -1788,33 +1707,35 @@ class CatalogGenerator:
def __recordSchedule(self, sched, weekCode, schedule): def __recordSchedule(self, sched, weekCode, schedule):
if isinstance(schedule, Sale): if isinstance(schedule, Sale):
schedule = schedule.args schedule = schedule.args
for item in schedule: try:
if callable(item): for item in list(schedule):
if item == nextAvailablePole: if callable(item):
item = getAllPoles() if item == nextAvailablePole:
elif item == nextAvailableCloset: item = getAllPoles()
item = getAllClosets() elif item == nextAvailableCloset:
elif item == nextAvailableBank: item = getAllClosets()
item = getAllBanks() elif item == nextAvailableBank:
elif item == nextAvailableTank: item = getAllBanks()
item = getAllTanks() elif item == nextAvailableTank:
elif item == get50ItemCloset: item = getAllTanks()
item = getMaxClosets() elif item == get50ItemCloset:
elif item == get50ItemTrunk: item = getMaxClosets()
item = getMaxTrunks() elif item == get50ItemTrunk:
else: item = getMaxTrunks()
self.notify.warning("Don't know how to interpret function " % repr(name)) else:
item = None self.notify.warning("Don't know how to interpret function " % repr(name))
elif isinstance(item, types.TupleType): item = None
item = item[1] elif isinstance(item, types.TupleType):
if isinstance(item, types.IntType): item = item[1]
item = MetaItems[item] if isinstance(item, types.IntType):
if isinstance(item, CatalogItem.CatalogItem): item = MetaItems[item]
self.__recordScheduleItem(sched, weekCode, None, item) if isinstance(item, CatalogItem.CatalogItem):
elif item != None: self.__recordScheduleItem(sched, weekCode, None, item)
for i in item: elif item != None:
self.__recordScheduleItem(sched, None, weekCode, i) for i in item:
self.__recordScheduleItem(sched, None, weekCode, i)
except:
print 'Wrong: %s' % schedule
return return
def __recordScheduleItem(self, sched, weekCode, maybeWeekCode, item): def __recordScheduleItem(self, sched, weekCode, maybeWeekCode, item):

View file

@ -89,7 +89,7 @@ def nextAvailableTank(avatar, duplicateItems):
def getAllTanks(): def getAllTanks():
list = [] list = []
for old, new in FishGlobals.NextTank: for old, new in FishGlobals.NextTank.iteritems():
list.append(CatalogPoleItem(new)) list.append(CatalogTankItem(new))
return list return list