mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-22 02:42:16 -04:00
Remove crashing holiday (#11988)
This commit is contained in:
parent
d1f39131a6
commit
ca4c479719
@ -55,16 +55,16 @@ object HolidayDates {
|
|||||||
override fun getByYear(year: Int) =
|
override fun getByYear(year: Int) =
|
||||||
DateRange.of(LocalDate.of(year, 11, 30).closestWeekday(DayOfWeek.SUNDAY))
|
DateRange.of(LocalDate.of(year, 11, 30).closestWeekday(DayOfWeek.SUNDAY))
|
||||||
},
|
},
|
||||||
Qingming {
|
// Qingming {
|
||||||
// https://en.wikipedia.org/wiki/Qingming_Festival
|
// // https://en.wikipedia.org/wiki/Qingming_Festival
|
||||||
// "it falls on the first day of the fifth solar term (also called Qingming) of the traditional Chinese lunisolar calendar.
|
// // "it falls on the first day of the fifth solar term (also called Qingming) of the traditional Chinese lunisolar calendar.
|
||||||
// This makes it the 15th day after the Spring Equinox, either 4, 5 or 6 April in a given year"
|
// // This makes it the 15th day after the Spring Equinox, either 4, 5 or 6 April in a given year"
|
||||||
override fun getByYear(year: Int): DateRange {
|
// override fun getByYear(year: Int): DateRange {
|
||||||
val springEquinoxInstant = Tables.equinoxes[year] ?: return DateRange.never
|
// val springEquinoxInstant = Tables.equinoxes[year] ?: return DateRange.never
|
||||||
val springEquinox = LocalDate.ofInstant(springEquinoxInstant, ZoneId.systemDefault())
|
// val springEquinox = LocalDate.ofInstant(springEquinoxInstant, ZoneId.systemDefault())
|
||||||
return DateRange.of(springEquinox.plusDays(15L))
|
// return DateRange.of(springEquinox.plusDays(15L))
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
Diwali(0.2f) {
|
Diwali(0.2f) {
|
||||||
// https://en.wikipedia.org/wiki/Diwali#Dates
|
// https://en.wikipedia.org/wiki/Diwali#Dates
|
||||||
// Darkest new moon night between mid-october and mid-november, then add +/- two days for a 5-day festival...
|
// Darkest new moon night between mid-october and mid-november, then add +/- two days for a 5-day festival...
|
||||||
@ -125,7 +125,7 @@ object HolidayDates {
|
|||||||
abstract fun getByYear(year: Int): DateRange
|
abstract fun getByYear(year: Int): DateRange
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun safeValueOf(name: String) = values().firstOrNull { it.name == name }
|
fun safeValueOf(name: String) = entries.firstOrNull { it.name == name }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ object HolidayDates {
|
|||||||
fun getHolidayByDate(date: LocalDate = LocalDate.now()): Holidays? {
|
fun getHolidayByDate(date: LocalDate = LocalDate.now()): Holidays? {
|
||||||
return System.getProperty("easterEgg")?.let {
|
return System.getProperty("easterEgg")?.let {
|
||||||
Holidays.safeValueOf(it)
|
Holidays.safeValueOf(it)
|
||||||
} ?: Holidays.values().firstOrNull {
|
} ?: Holidays.entries.firstOrNull {
|
||||||
val range = it.getByYear(date.year)
|
val range = it.getByYear(date.year)
|
||||||
date in range && Random.nextFloat() <= it.chance
|
date in range && Random.nextFloat() <= it.chance
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user