The time class works as expected and when I restart it goes back to it's 0 state while the build screen keeps whatever was last in the game (e.g. 10 built offices where there should be 0). saving and loading seems to work as expected for both classes as far as I can tell.
below part of the timeclass.
Code: Select all
init python:
class timeclass: #adding in EOD modules
standards = {'nextday':{'Monday':'Tuesday','Tuesday':'Wednesday','Wednesday':'Thursday','Thursday':'Friday','Friday':'Saturday','Saturday':'Sunday','Sunday':'Monday'},
'nextmonth':{'January':'February', 'February':'March', 'March':'April', 'April':'May', 'May':'June', 'June':'July', 'July':'August', 'August':'September', 'September':'October', 'October':'November', 'November':'December', 'December':'January'},
'monthdays': {'January':31,'February':28,'March':31,'April':30,'May':31,'June':30,'July':31,'August':31,'September':30,'October':31,'November':30,'December':31},
'nextseason':{'spring':'summer', 'summer':'autumn', 'autumn':'winter', 'winter':'spring'}}
def __init__(self, dayN=0, dateday=1, dayname='Saturday', hour=8, minute=0, period='morning', month='April', simseason='spring', vnseason='spring', simyear=0, vnyear=0, lastcheck=99):
self.dayN = dayN
self.dateday = dateday
self.dayname = dayname
self.hour = hour
self.minute = minute
self.period = period
self.month = month #Only used for special holiday events like christmas, carnival etc
self.simseason = simseason
self.vnseason = vnseason
self.simyear = simyear
self.vnyear = vnyear
self.lastcheck = lastcheck
def timeinc(self, newmin):
if newmin > 0:
self.hour += newmin // 60
self.minute += newmin % 60
while self.minute >= 60:
self.minute -= 60
self.hour += 1
while self.hour >= 24:
self.hour -= 24
self.EOD()
if self.hour < 6:
if self.period != 'night':
maps.decidecurrent()
self.period = 'night'
self.lastcheck = 0
elif self.hour < 12:
if self.period != 'morning':
maps.decidecurrent()
self.period = 'morning'
self.lastcheck = 0
elif self.hour < 18:
if self.period != 'afternoon':
maps.decidecurrent()
self.period = 'afternoon'
self.lastcheck = 0
else:
if self.period != 'evening':
maps.decidecurrent()
self.period = 'evening'
self.lastcheck = 0
if self.lastcheck == 99:
maps.decidecurrent()
self.lastcheck = 0
Code: Select all
class commonhandlerclass:
def __init__(self, store={}):
self.store = store
def building(self, OID, amount, what, remove=False): #building new buildings/offices/classrooms etc
OID = getattr(store, OID)
if what == None:
if remove == False:
OID.money -= OID.space['unallocated']['icps'] * amount * OID.mod['constructioncost']
OID.store['timers']['building'].append(('unallocated',OID.space['unallocated']['T'],amount))
else:
OID.money = OID.base['removalcost'] * amount * OID.mod['constructioncost'] * 10
OID.space['unallocated']['total'] -= amount
else:
if remove == False:
size = OID.space[what]['size'] * amount
cost = OID.space[what]['icps'] * size * OID.mod['constructioncost']
if OID.space['unallocated']['total'] >= size:
OID.space['unallocated']['total'] -= size
OID.money -= cost
OID.store['timers']['building'].append((what, OID.space[what]['T'],amount))
else:
size = OID.space[what]['size'] * amount
cost = OID.base['removalcost'] * size * OID.mod['constructioncost']
OID.space['unallocated']['total'] += size
OID.space[what]['total'] -= amount
OID.money -= cost
def maintenance(self, OID):
OID = getattr(store, OID)
temp = []
for i in OID.store['timers']['building']:
if i[1] <= 0:
OID.space[i[0]]['total'] += i[2]
else:
temp.append((i[0],i[1]-1,i[2]))
OID.store['timers']['building'] = temp
Code: Select all
class campusclass: #population = students + workers
def __init__(self, OID='campus', name='Turner University', money=250, corruption=0, prestige=-1000, space={}, base={}, mod={}, store={}, stats={}):
self.OID = OID
self.name = name
self.money = money
self.corruption = corruption
self.prestige = prestige
self.space = space
self.base = base
self.mod = mod
self.store = store
self.stats = stats
if not 'timers' in store: store['timers'] = {'building':[]}
if not 'removalcost' in base: base['removalcost'] = 75
if not 'constructioncost' in mod: mod['constructioncost']= 1
if not 'total' in space: space['total'] = 0
if not 'unallocated' in space: space['unallocated'] = {'total':0, 'T':15,'icps':1500, 'ccps':1.0}
if not 'cabinetoffice' in space: space['cabinetoffice'] = {'total':0, 'seats':1, 'size':10, 'T':2, 'icps':1000.0, 'ccps':10.0, 'ccpo':10.0, 'pop':'cabinet', 'demand':1.0} #cost per size vs cost per occupant negative numbers give income.
if not 'supportoffice' in space: space['supportoffice'] = {'total':0, 'seats':5, 'size':25, 'T':3, 'icps':100.0, 'ccps':1.5, 'ccpo':1.0, 'pop':'admin', 'demand':1.0} #pop means who uses this, demand is how likely to use/want this. If demand is not met happiness will drop
if not 'toilet' in space: space['toilet'] = {'total':0, 'seats':9, 'size':10, 'T':5, 'icps':200.0, 'ccps':2.5, 'ccpo':5.0, 'pop':'population', 'demand':0.063}
if not 'storage' in space: space['storage'] = {'total':0, 'seats':2, 'size':10, 'T':1, 'icps':20.0, 'ccps':1.1, 'ccpo':1.0, 'pop':'janitor', 'demand':1.0}
def EOD(self):
commonhandler.maintenance(self.OID)
Code: Select all
default time = timeclass()
default commonhandler = commonhandlerclass()
default campus = campusclass()
Code: Select all
screen TSTtimeSCR():
$renpy.retain_after_load()
$dayN = (store.time.dayN +14) % 52
$time = store.time.displaytime()
$date = store.time.dayname + ' ' + str(store.time.dateday) + ' ' + store.time.month + ' ' + str(store.time.vnyear)
$currentperiod = store.time.period
$currentvnseason = store.time.vnseason
$currentsimseason = store.time.simseason
$currentsimyear = store.time.simyear
vbox:
hbox:
text "It is currently [time], [date].\nIt is currently a fine [currentvnseason] [currentperiod].\nThe simulation is currently in week [dayN] year [currentsimyear] and it's currently [currentsimseason]."
hbox:
button:
action Function(store.time.timeinc, 6)
text "increase 6 minutes"
hbox:
button:
action Function(store.time.timeinc, 60)
text "increase 60 minutes"
hbox:
button:
action Function(store.time.timeinc, 600)
text "increase 600 minutes"
hbox:
button:
action Function(store.time.timeinc, 6000)
text "increase 6.000 minutes"
hbox:
button:
action Function(store.time.timeinc, 60000)
text "increase 60.000 minutes"
hbox:
button:
action ToggleScreen("TSTtimeSCR"), ToggleScreen("TSToverlaySCR")
text "return"
Code: Select all
screen TSTbuildSCR():
$renpy.retain_after_load()
$unallocated = globals()['campus'].space['unallocated']['total']
$CO = globals()['campus'].space['cabinetoffice']['total']
$SO = globals()['campus'].space['supportoffice']['total']
vbox:
hbox:
text "you currently have [CO] cabinetoffices and [SO] supportoffices. there is [unallocated] space left"
hbox:
button:
action Function(store.time.timeinc, 1440)
text "next day"
hbox:
button:
action Function(store.commonhandler.building, 'campus', 200, None)
text 'build 200m2 of building space.'
hbox:
button:
action Function(store.commonhandler.building, 'campus', 1, 'cabinetoffice')
text 'build a cabinetoffice'
hbox:
button:
action Function(store.commonhandler.building, 'campus', 5, 'supportoffice')
text 'build 5 supportoffices'
hbox:
button:
action ToggleScreen("TSTbuildSCR"), ToggleScreen('TSToverlaySCR')
text 'back'