Load more config data from files (instead of hardcoded)

This commit is contained in:
NGnius (Graham) committed 2025-03-30 17:54:06 -04:00
1 parent 0e048a17b1
commit a540cf6d8f
17 files changed
+244 -42

No files matched your search

+10 -5
View File
@@ -1,14 +1,19 @@
use polariton_server::operations::SimpleFunc;
use polariton::operation::{ParameterTable, Typed};
use polariton::operation::ParameterTable;
use rand::Rng;
use rc_core::ConfigProvider;
const MESSAGE_PARAM_KEY: u8 = 2;
const DISPLAY_TIME_PARAM_KEY: u8 = 15;
pub(super) fn dev_message_provider() -> SimpleFunc<8, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
SimpleFunc::new(|params, _| {
pub(super) fn dev_message_provider(conf: &rc_core::ConfigImpl) -> SimpleFunc<8, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
let messages = conf.login_messages();
SimpleFunc::new(move |params, _| {
let mut params = params.to_dict();
params.insert(MESSAGE_PARAM_KEY, Typed::Bytes(Vec::from("No jam was harmed in the reverse-engineering of this game".as_bytes()).into()));
params.insert(DISPLAY_TIME_PARAM_KEY, Typed::Int(60 /* seconds??? */));
let index = rand::rng().random::<u32>();
let dev_msg = messages.get(index as _);
params.insert(MESSAGE_PARAM_KEY, dev_msg.message);
params.insert(DISPLAY_TIME_PARAM_KEY, dev_msg.display_time);
Ok(params.into())
})
}