Dealing with dates in an RPG

Hi All,

Just wondering if anyone has done something similar. In my RPG I want to track time but I don’t want to use a real Date or Calendar. I want to have a custom set of months and days of week.

example:


 public enum DaysOfWeek {
        SolDay, MoonDay, SkyDay, WoodDay, StormDay, FreeDay, CronDay;
    }

    public enum MonthOfYear {
        Janus, Februa, Marz, Aprilis, Maia, Juno, Quintilis, Numa, Septis, Octon, Novon, Decton;
    }

Amusing 30 days a month and 7 days a week and 24 hours in a day.

Has anyone written something similar? My idea was to have a tick method that could take a minute as integer and increment the current date/time. I would call that method when the user moves.

Keep all your ‘time state’ data in a single int. (to count up to the year 4100, otherwise use a long)

Assuming that you measure time in minutes, simply do:


totalMinutes += 1; // tick!


int totalHours = totalMinutes / 60;
int totalDays = totalHours / 24;
int totalWeeks = totalDays / 7;
int totalMonth = totalDays / 30;
int totalYears = totalDays / (12*30);

int hourInDay = totalHours % 24;
int dayInMonth = totalDays % 30;
int dayInWeek = totalDays % 7;

Further, to be more ‘correct’ and not having to rely on enum.ordinal(), you should do:


public enum DaysOfWeek {
        SolDay(0), MoonDay(1), SkyDay(2), WoodDay(3), StormDay(4), FreeDay(5), CronDay(6);
    }

Thanks!