Skip to content

Commit

Permalink
better defaults + stat translation speed is now logarithmic
Browse files Browse the repository at this point in the history
  • Loading branch information
Lamby777 committed Jul 5, 2024
1 parent bf49d3e commit 9fcd0e3
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
8 changes: 2 additions & 6 deletions pets-lib/src/battle/stat_translation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@
//!
use crate::prelude::*;
const SPEED_STAT_MULTIPLIER: FloatStat = 200.0;
const SPEED_STAT_MULTIPLIER: FloatStat = 800.0;

pub fn speed(speed: IntegralStat) -> FloatStat {
// oh boy, linear algebra! maybe school DID actually teach me something
// TODO maybe use logarithms, refer to that one graph i made a while ago
// ofc,, past me didn't know about the "units" in godot, so values might
// need to be adjusted for speed and similar implementation-heavy stats
(speed as FloatStat) * SPEED_STAT_MULTIPLIER
((10 + speed) as FloatStat).log2() * SPEED_STAT_MULTIPLIER
}
5 changes: 2 additions & 3 deletions pets-lib/src/stats/charmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,17 @@ macro_rules! ch_unique_registry {
pub fn default_charmap() -> CharMap {
let mut res_map = uniform_charmap();

// max_hp, max_energy, attack, defense, speed,
// stability, delta, epsilon, lambda, max_mana,

ch_unique_registry! {
res_map,

ETHAN {
display_name = "Ethan".to_owned(),
inherent_stats.max_mana = Some(10),
},

SIVA {
display_name = "Siva".to_owned(),
inherent_stats.max_mana = Some(10),
},

TERRA {
Expand Down
31 changes: 29 additions & 2 deletions pets-lib/src/stats/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,25 @@ pub use pchars::{EnemyID, PChar};
pub use quests::QuestPhase;
pub use savefiles::SaveFile;

#[derive(Clone, Debug, Default, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct BattleStats {
pub hp: IntegralStat,
pub mana: Option<IntegralStat>,
pub energy: IntegralStat,
pub buffs: Vec<InherentStats>,
}

impl Default for BattleStats {
fn default() -> Self {
BattleStats {
hp: 30,
mana: None,
energy: 1,
buffs: vec![],
}
}
}

/// All the information the game needs to know about a character
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct CharData {
Expand Down Expand Up @@ -114,7 +125,6 @@ impl Battler for CharData {
#[derive(
Clone,
Debug,
Default,
Eq,
Hash,
PartialEq,
Expand Down Expand Up @@ -142,6 +152,23 @@ pub struct InherentStats {
pub max_mana: Option<IntegralStat>,
}

impl Default for InherentStats {
fn default() -> Self {
InherentStats {
max_hp: 30,
max_energy: 1,
attack: 1,
defense: 1,
speed: 1,
stability: 1,
delta: 1,
epsilon: 1,
lambda: None,
max_mana: None,
}
}
}

#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum StatusEffect {
/// Can't move, but recover 20% energy on wakeup
Expand Down

0 comments on commit 9fcd0e3

Please sign in to comment.