- Jul 26, 2017
- 56
- 26
So I am about to get super stubborn with this calendar class I have been working on because I dug it up from lemmasoft and modified it to suit my needs but I am having some major trouble getting the damn thing to reset. I don't want to totally scrap it because I have it set up with a basic display calendar and have it worked into the code all sorts of other places.
It's been a long time since I have python'ed around and 90% of what I have going is working well. the problem I have is that I plan on using "months" as stages and since this thing was more meant to lay out a full year I may be using it against it's purpose.
Here is the class I am messing with and a sample in case anyone wants to poke it
The problem I am running into is when you reach past the full cycle the damn thing stops altogether. It gets caught up on that while statement. I did rename the "months" to weeks 1-4 because I plan on actually creating months as a way of formatting stages that loop so the player can replay that month either because they haven't met the requirement to move on or because they feel like it. I put a stupid time advance in there that I can call with a timeskip label which includes an if statement that is meant to reset the time if it exceeds the counter set by this however it totally skips the reset due to the while statement. I know I am missing something simple in regards to using the class to reset itself but I am fried from building the general game structure as far as locations, character art, and trying to figure out how I am actually going to work the other core mechanics. I have a nearly functional demo working if only I could get this bastard to reset when it cycles through all 4 weeks. any help would be awesome
It's been a long time since I have python'ed around and 90% of what I have going is working well. the problem I have is that I plan on using "months" as stages and since this thing was more meant to lay out a full year I may be using it against it's purpose.
Here is the class I am messing with and a sample in case anyone wants to poke it
Code:
init -2 python:
class Game_Time:
PERIODS = ("Dawn", "Morning", "Shift2", "Afternoon", "Shift3", "Evening", "Night", "Late Night")
MONTHS = ("week1", "week2", "week3", "week4")
WEEK_DAYS = ("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")
MONTHS_DAYS = (7, 7, 7, 7)
def __init__(self, now = 0):
self.period = 0
self.day = 0
self.week = 0
self.week_day = 0
self.month = 0
self.month_day = 0
self.now = now
self.update()
def advance(self, n = 1):
self.now += n
self.update()
def reset(self, now = 0):
self.period = 0
self.day = 0
self.week = 0
self.week_day = 0
self.month = 0
self.month_day = 0
self.now = now
self.update()
def update(self):
self.period = self.now % len(Game_Time.PERIODS)
self.day = self.now / len(Game_Time.PERIODS)
self.week_day = self.day % 7
self.week = self.day / 7
day = self.day
self.month = 0
#month = self.month % 4
while day >= Game_Time.MONTHS_DAYS[self.month]:
day -= Game_Time.MONTHS_DAYS[self.month]
self.month += 1
month_day = day + 1
def period_name(self):
return Game_Time.PERIODS[self.period]
def week_day_name(self):
return Game_Time.WEEK_DAYS[self.week_day]
def month_name(self):
return Game_Time. MONTHS[self.month]
def date_name(self):
return self.week_day_name() + ", " + self.month_name() + " "