Skip to content

Commit

Permalink
plural skills have an @ in the name
Browse files Browse the repository at this point in the history
  • Loading branch information
Lamby777 committed Jul 11, 2024
1 parent 6e6fd94 commit 34542b4
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 12 deletions.
18 changes: 18 additions & 0 deletions pets-gd/assets/skillregistries/psi.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,30 @@
"plural": false,
"status_effect": null
},
"Caustics @A": {
"type": "AttackSkill",
"tr_key": "SKILL_ATTACK_FIRE_DMG_NAME",
"element": "Fire",
"power": 1,
"plural": true,
"status_effect": null
},
"Caustics B": {
"type": "AttackSkill",
"tr_key": "SKILL_ATTACK_FIRE_DMG_NAME",
"element": "Fire",
"power": 2,
"plural": false,
"status_effect": null
},
"Recovery A": {
"type": "RecoverySkill",
"power": 1,
"recovery": {
"HPAmount": {
"amount": 50
}
},
"plural": false
}
}
12 changes: 7 additions & 5 deletions pets-gd/i18n/translations.csv
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ ELEMENT_ADJ_Whip,Whip
,
SKILL_PSI_FLUX_NAME,PSI Flux
SKILL_PSI_FLUX_DESC,Warps time in your favor for {seconds} seconds.
SKILL_RECOVERY_COMBINED,{family} {power}
SKILL_RECOVERY_HP_AMOUNT_NAME,Recover
SKILL_RECOVERY_HP_AMOUNT_DESC,Heals {amount} of the target's HP.
SKILL_RECOVERY_HP_PERCENT_NAME,Renew
Expand All @@ -69,11 +70,12 @@ SKILL_ATTACK_SPIRIT_FX_NAME,Curse
SKILL_ATTACK_FUZZ_NAME,PK Fuzz
SKILL_ATTACK_WHIP_NAME,PK Whip
,
SKILL_ATTACK_TIER_1,A
SKILL_ATTACK_TIER_2,B
SKILL_ATTACK_TIER_3,C
SKILL_ATTACK_TIER_4,D
SKILL_ATTACK_TIER_5,E
SKILL_TIER_1,A
SKILL_TIER_2,B
SKILL_TIER_3,C
SKILL_TIER_4,D
SKILL_TIER_5,E
SKILL_POWER_PLURAL,@{power}
,
SKILL_ATTACK_NAME_COMBINED,{family} {power}
SKILL_ATTACK_DESCRIBE_COMBINED,{dmg} {fx}
Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/battle/skills/attack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl AttackSkill {
impl Skill for AttackSkill {
fn name(&self) -> String {
let family = tr!("{}", self.tr_key.clone());
let power = self.power.map(|p| tr(&format!("SKILL_ATTACK_TIER_{}", p)));
let power = self.power.map(|p| power_to_letter_pl(p, self.plural));

match power {
Some(power) => tr_replace! {
Expand Down
15 changes: 14 additions & 1 deletion pets-lib/src/battle/skills/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,22 @@ mod shields;
pub(crate) use attack::AttackSkill;
pub(crate) use buffs::BuffSkill;
pub(crate) use other::PSIFluxSkill;
pub(crate) use recovery::RecoverySkill;
pub(crate) use recovery::{RecoverySkill, RecoveryType};
pub(crate) use shields::ShieldSkill;

fn power_to_letter(power: u8) -> GString {
tr(&format!("SKILL_TIER_{}", power))
}

fn power_to_letter_pl(power: u8, plural: bool) -> GString {
let power = power_to_letter(power);

match plural {
true => tr_replace!("SKILL_POWER_PLURAL"; power).into(),
false => power,
}
}

#[typetag::serde(tag = "type")]
pub trait Skill: Debug + Sync + Send {
fn name(&self) -> String;
Expand Down
13 changes: 11 additions & 2 deletions pets-lib/src/battle/skills/recovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ use super::*;

#[derive(Debug, Serialize, Deserialize)]
pub struct RecoverySkill {
pub name: String,
pub power: u8,
pub recovery: RecoveryType,
pub plural: bool,
}

#[derive(Debug, Serialize, Deserialize)]
Expand All @@ -16,7 +17,15 @@ pub enum RecoveryType {
#[typetag::serde]
impl Skill for RecoverySkill {
fn name(&self) -> String {
self.name.clone()
let family = match self.recovery {
RecoveryType::HPAmount { .. } => "SKILL_RECOVERY_HP_AMOUNT",
RecoveryType::HPPercent { .. } => "SKILL_RECOVERY_HP_PERCENT",
RecoveryType::Status { .. } => "SKILL_RECOVERY_STATUS",
};

let power = power_to_letter_pl(self.power, self.plural);

tr_replace!("SKILL_RECOVERY_COMBINED"; family, power)
}

fn description(&self) -> String {
Expand Down
15 changes: 12 additions & 3 deletions pets-lib/src/stats/autoload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use godot::global::randomize;
use godot::prelude::*;

use crate::battle::skills::{load_skill_registry, SKILL_REGISTRY};
use crate::battle::skills::load_skill_registry;
use crate::prelude::*;

#[derive(GodotClass)]
Expand Down Expand Up @@ -70,6 +70,15 @@ impl IObject for StatsInterface {
/// put stuff like serialization testing in here temporarily to mess around
/// it'll run when the game starts
fn print_debug_crap() {
let ser = SKILL_REGISTRY.get().unwrap().get("Caustics A").unwrap();
godot_print!("{:?}", ser);
// use crate::battle::skills::*;
//
// let ser = SKILL_REGISTRY.get().unwrap().get("Caustics A").unwrap();
// let skill = RecoverySkill {
// power: 2,
// recovery: RecoveryType::HPAmount { amount: 10 },
// plural: false,
// };
//
// let ser = serde_json::to_string(&skill);
// godot_print!("{:?}", ser);
}

0 comments on commit 34542b4

Please sign in to comment.