Fix skill presets, add tests

This commit is contained in:
juliancoffee 2021-05-22 15:47:56 +03:00 committed by Sam
parent 1014ac45bf
commit ca6266e780
3 changed files with 63 additions and 12 deletions

View File

@ -76,21 +76,23 @@
(UnlockGroup(Weapon(Bow)), 1),
(Bow(ProjSpeed), 2),
(Bow(BDamage), 3),
(Bow(BRegen), 2),
(Bow(CDamage), 3),
(Bow(CKnockback), 2),
(Bow(CProjSpeed), 2),
(Bow(CDrain), 2),
(Bow(CSpeed), 2),
(Bow(CRegen), 2),
(Bow(CMove), 2),
(Bow(UnlockRepeater), 1),
(Bow(RGlide), 1),
(Bow(RDamage), 2),
(Bow(RArrows), 2),
(Bow(RDamage), 3),
(Bow(RCost), 2),
(Bow(RSpeed), 2),
(Bow(UnlockShotgun), 1),
(Bow(SDamage), 2),
(Bow(SCost), 2),
(Bow(SArrows), 2),
(Bow(SSpread), 2),
// Staff
(UnlockGroup(Weapon(Staff)), 1),
@ -126,4 +128,40 @@
(Sceptre(ARange), 2),
(Sceptre(ACost), 2),
],
// Basic skill preset to unlock all abilities
"basic": [
// General skills
// Sword
(UnlockGroup(Weapon(Sword)), 1),
(Sword(InterruptingAttacks), 1),
(Sword(DInfinite), 1),
(Sword(UnlockSpin), 1),
// Axe
(UnlockGroup(Weapon(Axe)), 1),
(Axe(SInfinite), 1),
(Axe(UnlockLeap), 1),
// Hammer
(UnlockGroup(Weapon(Hammer)), 1),
(Hammer(UnlockLeap), 1),
// Bow
(UnlockGroup(Weapon(Bow)), 1),
(Bow(UnlockShotgun), 1),
// Staff
(UnlockGroup(Weapon(Staff)), 1),
(Staff(UnlockShockwave), 1),
// Sceptre
(UnlockGroup(Weapon(Sceptre)), 1),
(Sceptre(UnlockAura), 1),
],
})

View File

@ -912,3 +912,14 @@ impl ArgumentSpec {
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_loading_skill_presets() {
SkillPresetManifest::load_expect("server.manifests.presets");
}
}

View File

@ -3059,10 +3059,12 @@ fn clear_skillset(skill_set: &mut comp::SkillSet) { *skill_set = comp::SkillSet:
fn set_skills(skill_set: &mut comp::SkillSet, preset: &str) -> CmdResult<()> {
let presets =
if let Ok(presets) = common::cmd::SkillPresetManifest::load("server.manifests.presets") {
presets.read().0.clone()
} else {
return Err("Error while loading presets".to_owned());
match common::cmd::SkillPresetManifest::load("server.manifests.presets") {
Ok(presets) => presets.read().0.clone(),
Err(err) => {
warn!("Error in preset: {}", err);
return Err("Error while loading presets".to_owned());
},
};
if let Some(preset) = presets.get(preset) {
for (skill, level) in preset {