88 lines
2.3 KiB
Rust
88 lines
2.3 KiB
Rust
use std::fmt::Display;
|
|
|
|
use bevy::prelude::Component;
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub enum PurchasableObject {
|
|
Cursor,
|
|
Grandma,
|
|
Farm,
|
|
Mine,
|
|
Factory,
|
|
Bank,
|
|
Temple,
|
|
WizardTower,
|
|
}
|
|
|
|
#[derive(Component, Debug)]
|
|
pub struct Purchased {
|
|
pub object: PurchasableObject,
|
|
pub count: u32,
|
|
}
|
|
|
|
impl Display for PurchasableObject {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
write!(
|
|
f,
|
|
"{}",
|
|
match self {
|
|
PurchasableObject::Cursor => "Cursor",
|
|
PurchasableObject::Grandma => "Grandma",
|
|
PurchasableObject::Farm => "Farm",
|
|
PurchasableObject::Mine => "Mine",
|
|
PurchasableObject::Factory => "Factory",
|
|
PurchasableObject::Bank => "Bank",
|
|
PurchasableObject::Temple => "Temple",
|
|
PurchasableObject::WizardTower => "Wizard Tower",
|
|
}
|
|
)
|
|
}
|
|
}
|
|
|
|
#[derive(Component, Debug)]
|
|
pub struct PlayerStats {
|
|
pub cookies: f64,
|
|
}
|
|
|
|
impl PlayerStats {
|
|
pub fn new() -> PlayerStats {
|
|
return PlayerStats { cookies: 0.0 };
|
|
}
|
|
}
|
|
|
|
pub fn get_current_price(object: &PurchasableObject, num_owned: &u32) -> f64 {
|
|
get_base_price(object) * (1.0 + get_price_scaling_factor(object) * f64::from(*num_owned))
|
|
}
|
|
|
|
pub fn get_base_price(object: &PurchasableObject) -> f64 {
|
|
match object {
|
|
PurchasableObject::Cursor => 15.0,
|
|
PurchasableObject::Grandma => 100.0,
|
|
PurchasableObject::Farm => 1_100.0,
|
|
PurchasableObject::Mine => 21_000.0,
|
|
PurchasableObject::Factory => 130_000.0,
|
|
PurchasableObject::Bank => 1_400_000.0,
|
|
PurchasableObject::Temple => 20_000_000.0,
|
|
PurchasableObject::WizardTower => 330_000_000.0,
|
|
}
|
|
}
|
|
|
|
pub fn get_price_scaling_factor(object: &PurchasableObject) -> f64 {
|
|
match object {
|
|
_ => 0.15,
|
|
}
|
|
}
|
|
|
|
pub fn get_base_returns(object: &PurchasableObject) -> f64 {
|
|
match object {
|
|
PurchasableObject::Cursor => 0.1,
|
|
PurchasableObject::Grandma => 1.0,
|
|
PurchasableObject::Farm => 8.0,
|
|
PurchasableObject::Mine => 47.0,
|
|
PurchasableObject::Factory => 260.0,
|
|
PurchasableObject::Bank => 1_400.0,
|
|
PurchasableObject::Temple => 7_800.0,
|
|
PurchasableObject::WizardTower => 44_000.0,
|
|
}
|
|
}
|