mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Add basic currency support and plumb multiplayer rewards screen #70
This commit is contained in:
1 parent
5e05cbdb59
commit
4ec64a9cd9
26 files changed
+802
-48
No files matched your search
@@ -1,16 +1,34 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed};
|
||||
use polariton_server::operations::{SimpleOpError, SimpleOperation, SimpleOpImpl};
|
||||
|
||||
const CURRENT_CODE: u8 = 187;
|
||||
const CURRENT_PARAM_KEY: u8 = 214;
|
||||
|
||||
pub(super) fn tech_points_provider() -> SimpleFunc<187, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(CURRENT_PARAM_KEY, Typed::Int(1337));
|
||||
Ok(params.into())
|
||||
})
|
||||
pub(super) struct CurrentTechPointers;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl <C: Send + 'static> SimpleOperation<C> for CurrentTechPointers {
|
||||
type User = crate::UserTy;
|
||||
const CODE: u8 = CURRENT_CODE;
|
||||
|
||||
async fn handle(&self, _params: ParameterTable<C>, user: &Self::User) -> Result<ParameterTable<C>, SimpleOpError> {
|
||||
let mut table = ParameterTable::with_capacity(2);
|
||||
let user_info = user.user()?;
|
||||
let exp = user_info.currency(
|
||||
oj_rc_core::persist::user::CurrencyType::TechPoints,
|
||||
oj_rc_core::persist::user::CurrencyOp::Get,
|
||||
).await?;
|
||||
table.insert(CURRENT_PARAM_KEY, Typed::Int(exp as _));
|
||||
Ok(table)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn tech_points_provider<C: Send + 'static>() -> SimpleOpImpl<C, crate::UserTy, CurrentTechPointers> {
|
||||
SimpleOpImpl::new(CurrentTechPointers)
|
||||
}
|
||||
|
||||
|
||||
const UNCLAIMED_PARAM_KEY: u8 = 212;
|
||||
|
||||
pub(super) fn tech_points_awards_provider() -> SimpleFunc<185, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||
|
||||
Reference in new issue
Block a user