Lunar Cycles | Patreon Weekly #234
Added 2023-11-27 16:00:06 +0000 UTCHey Patrons, in this weekly I’m going to change gears a little bit. I fell down a bit of a rabbit hole while working on some side content, and thought I’d share some of that journey with you.
This weekly also includes an audio Q&A! Go and give it a listen if you’d like. You can find audio timestamps at the end of this weekly.
Figuring out Holiday Dates
As mentioned in the last weekly, new holiday items did reasonably well in the most recent patreon poll. I don’t intend to add them all in one go but I wanted to spend a little time implementing backend functionality for them in v2.3.0. Mainly that meant coming up with what holidays I want Shattered to celebrate, and creating a better system to tell whether a particular holiday was occurring.
Most holidays occur on the same date each year, and so coding in support for them was easy, but there were two exceptions: Easter, and Lunar New Year.
Easter Sunday occurs on the first Sunday after the first full moon on or after March 21st, placing it some time between March 22nd and April 25th each year. Because of this, rigidly coding a specific date just doesn’t work, the game needs to algorithmically compute when Easter occurs in a given year. The good news is that algorithms for doing this do exist, the bad news is that they look like this:

I’m not even going to pretend that I understand what’s going on here. The short answer is that a bunch of unexplained numerical bullshit happens and at the end of it n is equal to our month (3 for March, 4 for April), and o+1 is equal to our day. Done.
Lunar New Year is also a moving target, occurring on the first new moon of the Chinese lunar calendar, which places it between January 21st and February 20th. As we can see with Easter, moon cycles can be calculated algorithmically, but we have the added complication of the date being based on an entirely different calendar system. Converting from Chinese Lunar to Gregorian is possible of course, but it’s another moving target that varies on a per-year basis.
This time that variance does not have an existing algorithmic solution (or at least none that I could find). So, for Lunar New Year, there’s nothing for it but to hard-code dates. Yuck.

Figuring these two out, as well as concepting work for other holidays, ended up eating quite a bit of my time this week. It’s all coded out properly now (at least until 2051), but I expected this to take much less time than it did. At the very least I’m now all set up to slowly add holiday items to the game as we move through 2024.
Lunar New Year occurs on February 10th this year, and I’m very confident that I’ll release v2.3.0 before then, so that’ll be the first of the new holiday celebrations. If you’re curious about which holidays and dates I picked, I shared some info on that in the most recent Shattered Secrets.
Audio TImestamps
This month there were 13 questions from 6 different Patrons.
- 0:09 "how did you come up with the six champion buffs? were there any that you scrapped or changed significantly between when you came up with them and first proposed them to the patreon?" - depresbian
- 1:49 "how was your day? :>" - depresbian
- 2:42 "Did you get the idea for golem "pull" ability from Dead Cells? Because the game has a stone golem enemy that does exactly the same thing. If not, where did you get it from?" - Block Vader
- 4:47 "what made you originally want to add holiday-themed items to replace pasties?" - radiantchaos
- 6:46 "What is the most possible buffs/debuffs possible? Ive managed ten, but I'm curious what the theorical limit is." - Chewyou
- 8:41 "How does the shopkeeper (and Imp) not notice you stealing things? Its not like anyone else buys things from them." - Veek
- 9:29 "whats your favorite enchantment/glyph?" - radiantchaos
- 11:11 "what, if anything, are you nominating for the steam awards?" - depresbian
- 15:02 "have you considered adding support for discord rich presence to the desktop versions of shattered?" - depresbian
- 17:34 "did you watch the five nights at freddy's movie?" - radiantchaos
- 18:59 "Considering the backend work for the sublayers to get the blacksmith quest rework to be functional, have you thought about using that system anywhere else and how difficult do you see it being to implement said other uses of the system" - Arclightning
- 20:41 "Which rare or alternate enemy (like the caustic slime) is your favorite that you designed? Any plans for more?" - Veek
- 21:55 "Are all Evil Eyes evil? Are there any "nice" evil eyes?" - Zrp200
Comments
Dates do indeed suck, but as annoying as adding this code was, I MUCH prefer it to adding a dependency just for holiday calculations. EDIT: I do think I watched that video a long while ago, but I forgot the specifics. Thankfully this problem is just an extremely small subset of figuring out the local date, I don't even need to think about time or coordination between different zones/standards, so it's a bit more feasible to do it myself.
Shattered Pixel
2023-11-28 01:23:30 +0000 UTCOh that's neat, I had no idea that other games added holiday stuff inspired by Shattered.
Shattered Pixel
2023-11-28 01:21:10 +0000 UTCI agree with your favorite unique enemy. The Chaos Elemental is by far the one that sparks the most excitement (not necessarily just because of its great reward).
Veek
2023-11-27 21:16:13 +0000 UTCFYI - This code: [HolidayDates](https://github.com/yairm210/Unciv/blob/master/core/src/com/unciv/logic/HolidayDates.kt) was inspired by Shattered. And for the "all eyes evil" question read recent OOTS.
Robert Heinig
2023-11-27 18:51:54 +0000 UTCAnd this is why programmers should never make algorithms about dealing with dates or timezones :D Did you consider using some date library that has common holidays dates programmed? Also you reminded me of one Tom Scott video. I recommend if you did not watch it yet :) https://youtube.com/watch?v=-5wpm-gesOY
Alex Allperino Zgabur
2023-11-27 18:25:26 +0000 UTC