mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
065da20812
+ Villagers only wear christmas hat + Guards wear boreal_warhelm + Gave guards christmas color lanterns + Grave_robbers now wear hood and hood_dark too while also dropping them at a higher rate than previously. + Christmas event now starts at 20th and goes till 30th of december + item_image_manifest.ron manifest fix + Created a potential boss loot table which allows the player to get the winter_cap, the boreal_warhelm, polaris lantern, and more blue cheese. + Updated hood_dark with another index 17 layer to prevent hair clip.
43 lines
1.2 KiB
Rust
43 lines
1.2 KiB
Rust
use chrono::{DateTime, Datelike, Local, TimeZone, Utc};
|
|
use chrono_tz::Tz;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
#[repr(u16)]
|
|
pub enum CalendarEvent {
|
|
Christmas = 0,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
|
pub struct Calendar {
|
|
events: Vec<CalendarEvent>,
|
|
}
|
|
|
|
impl Calendar {
|
|
pub fn is_event(&self, event: CalendarEvent) -> bool { self.events.contains(&event) }
|
|
|
|
pub fn events(&self) -> impl ExactSizeIterator<Item = &CalendarEvent> + '_ {
|
|
self.events.iter()
|
|
}
|
|
|
|
pub fn from_events(events: Vec<CalendarEvent>) -> Self { Self { events } }
|
|
|
|
pub fn from_tz(tz: Option<Tz>) -> Self {
|
|
let mut this = Self::default();
|
|
|
|
let now = match tz {
|
|
Some(tz) => {
|
|
let utc = Utc::now().naive_utc();
|
|
DateTime::<Tz>::from_utc(utc, tz.offset_from_utc_datetime(&utc)).naive_local()
|
|
},
|
|
None => Local::now().naive_local(),
|
|
};
|
|
|
|
if now.month() == 12 && (20..=30).contains(&now.day()) {
|
|
this.events.push(CalendarEvent::Christmas);
|
|
}
|
|
|
|
this
|
|
}
|
|
}
|