mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Refactor item purchase logic into core, implement promo codes #70
This commit is contained in:
1 parent
2c6ef3edbe
commit
2f826835dc
10 files changed
+298
-68
No files matched your search
@@ -508,4 +508,24 @@ impl <C: Clone + Send> super::ConfigProvider<C> for CubeConfig {
|
||||
fn shop_entries(&self) -> super::ShopEntriesResolver {
|
||||
super::ShopEntriesResolver::new(self.shop.items.clone())
|
||||
}
|
||||
|
||||
fn promo_codes(&self) -> std::collections::HashMap<String, super::PromoCode> {
|
||||
let mut map = std::collections::HashMap::with_capacity(self.shop.promo_codes.len());
|
||||
for (key, val) in self.shop.promo_codes.iter() {
|
||||
let tx = super::ShopAction {
|
||||
cost_free: 0,
|
||||
cost_paid: 0,
|
||||
gives: val.gives.iter().map(|x| x.to_owned().into()).collect(),
|
||||
};
|
||||
map.insert(key.to_owned(), super::PromoCode {
|
||||
message: val.message.clone(),
|
||||
bundle_id: val.bundle_id.to_owned().unwrap_or_else(|| key.to_owned()),
|
||||
promo_id: val.promo_id.to_owned().unwrap_or_else(|| key.to_owned()),
|
||||
is_serial: val.is_serial,
|
||||
value: val.value,
|
||||
transaction: tx,
|
||||
});
|
||||
}
|
||||
map
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ mod cubes_json;
|
||||
pub use cubes_json::CubeConfig;
|
||||
|
||||
mod traits;
|
||||
pub use traits::{ConfigProvider, DevMessageProvider, ServerConfig, GarageUpgrades, GarageUpgradeIncrement, ChatSystemConfig, GameEventSequence, GameEvents, GameRotationStrategy, GameEvent, GameMap, GameVisibility, GameType, SingleplayerConfig, VehicleInfo, VehicleDescriptor, QueueChangeMode, Point, Sphere, MapConfig, LinksConfig, FakePlayer, ClientEmulator, EnergyConfig, BattleArenaResolver, PitSettings, PitWinCondition, TeamDeathMatchSettings, ShopEntriesResolver, ShopAction, ShopGain};
|
||||
pub use traits::{ConfigProvider, DevMessageProvider, ServerConfig, GarageUpgrades, GarageUpgradeIncrement, ChatSystemConfig, GameEventSequence, GameEvents, GameRotationStrategy, GameEvent, GameMap, GameVisibility, GameType, SingleplayerConfig, VehicleInfo, VehicleDescriptor, QueueChangeMode, Point, Sphere, MapConfig, LinksConfig, FakePlayer, ClientEmulator, EnergyConfig, BattleArenaResolver, PitSettings, PitWinCondition, TeamDeathMatchSettings, ShopEntriesResolver, ShopAction, ShopGain, PromoCode};
|
||||
|
||||
mod validation;
|
||||
pub use validation::{SelfValidator, ValidationInfo, ValidationMessage};
|
||||
|
||||
@@ -37,6 +37,7 @@ pub trait ConfigProvider<C: Clone> {
|
||||
fn pit_settings(&self) -> PitSettings;
|
||||
fn tdm_settings(&self) -> TeamDeathMatchSettings;
|
||||
fn shop_entries(&self) -> ShopEntriesResolver;
|
||||
fn promo_codes(&self) -> std::collections::HashMap<String, PromoCode>;
|
||||
}
|
||||
|
||||
pub struct DevMessageProvider<C: Clone> {
|
||||
@@ -486,3 +487,13 @@ pub enum ShopGain {
|
||||
PaidCurrency(i64),
|
||||
TechPoints(i32)
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PromoCode {
|
||||
pub message: Option<String>,
|
||||
pub bundle_id: String,
|
||||
pub promo_id: String,
|
||||
pub is_serial: bool,
|
||||
pub value: f32,
|
||||
pub transaction: ShopAction,
|
||||
}
|
||||
Reference in new issue
Block a user