Files
Paradise/code/controllers/Processes/event.dm
T
2019-04-23 10:55:36 +01:00

34 lines
1.0 KiB
Plaintext

var/global/datum/controller/holiday/holiday_master //This has to be defined before world.
/datum/controller/holiday
var/list/holidays
/datum/controller/holiday/proc/Setup()
getHoliday()
/datum/controller/holiday/proc/process()
if(holiday_master.holidays)
for(var/datum/holiday/H in holiday_master.holidays)
if(H.eventChance)
if(prob(H.eventChance))
H.handle_event()
/datum/controller/holiday/proc/getHoliday()
if(!config.allow_holidays) return //Holiday stuff was not enabled in the config!
var/YY = text2num(time2text(world.timeofday, "YY")) // get the current year
var/MM = text2num(time2text(world.timeofday, "MM")) // get the current month
var/DD = text2num(time2text(world.timeofday, "DD")) // get the current day
for(var/H in subtypesof(/datum/holiday))
var/datum/holiday/holiday = new H()
if(holiday.shouldCelebrate(DD, MM, YY))
holiday.celebrate()
if(!holidays)
holidays = list()
holidays[holiday.name] = holiday
if(holidays)
holidays = shuffle(holidays)
world.update_status()