mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Implement tech tree cube unlock
This commit is contained in:
1 parent
6bcd812738
commit
59b253dc52
7 files changed
+130
-25
No files matched your search
@@ -1,17 +1,19 @@
|
||||
use polariton_server::operations::Immediate;
|
||||
use oj_rc_core::ConfigProvider;
|
||||
use polariton_server::operations::{SimpleOpError, SimpleOperation, SimpleOpImpl};
|
||||
use polariton::operation::ParameterTable;
|
||||
|
||||
const PARAM_KEY: u8 = 210;
|
||||
const CODE: u8 = 183;
|
||||
|
||||
pub(super) fn tech_tree_layout_provider(cubes: &oj_rc_core::ConfigImpl) -> Immediate<183, crate::UserTy> {
|
||||
const NODES_PARAM_KEY: u8 = 210;
|
||||
|
||||
/*pub(super) fn tech_tree_layout_provider(cubes: &oj_rc_core::ConfigImpl) -> Immediate<183, crate::UserTy> {
|
||||
Immediate::new(|| {
|
||||
let mut params = std::collections::HashMap::with_capacity(2);
|
||||
params.insert(PARAM_KEY, cubes.tech_tree_nodes(&vec![
|
||||
params.insert(NODES_PARAM_KEY, cubes.tech_tree_nodes(&vec![
|
||||
227205318,
|
||||
227917916,
|
||||
1931676396,
|
||||
].into_iter().collect()));
|
||||
/*params.insert(PARAM_KEY, Typed::Dict(Dict {
|
||||
/*params.insert(NODES_PARAM_KEY, Typed::Dict(Dict {
|
||||
key_ty: TypePrefix::Str, // str
|
||||
val_ty: TypePrefix::HashMap, // hashmap
|
||||
items: vec![
|
||||
@@ -28,4 +30,29 @@ pub(super) fn tech_tree_layout_provider(cubes: &oj_rc_core::ConfigImpl) -> Immed
|
||||
}));*/
|
||||
params.into()
|
||||
})
|
||||
}*/
|
||||
|
||||
pub(super) struct TechTreeNoder {
|
||||
nodes: oj_rc_core::persist::config::TechTreeNodeProvider,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl <C: Send + 'static> SimpleOperation<C> for TechTreeNoder {
|
||||
type User = crate::UserTy;
|
||||
const CODE: u8 = CODE;
|
||||
|
||||
async fn handle(&self, params: ParameterTable<C>, user: &Self::User) -> Result<ParameterTable<C>, SimpleOpError> {
|
||||
let mut params = params.to_dict();
|
||||
let user_info = user.user()?;
|
||||
let unlocked = user_info.unlocked_parts().await;
|
||||
let nodes = self.nodes.tech_tree_nodes(&unlocked.into_iter().collect());
|
||||
params.insert(NODES_PARAM_KEY, nodes);
|
||||
Ok(params.into())
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn tech_tree_layout_provider<C: Send + 'static>(cubes: &oj_rc_core::ConfigImpl) -> SimpleOpImpl<C, crate::UserTy, TechTreeNoder> {
|
||||
SimpleOpImpl::new(TechTreeNoder {
|
||||
nodes: <oj_rc_core::ConfigImpl as oj_rc_core::ConfigProvider<()>>::tech_tree_nodes(cubes),
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user