From ec6bcea8f1d7353e71f6640d3600c714364b6227 Mon Sep 17 00:00:00 2001 From: juliancoffee Date: Mon, 14 Jun 2021 13:55:25 +0300 Subject: [PATCH] Responding to review - make `skillset_builder::Preset` void enum and left comment about how to extend it - add `.with_default_equipment()` in case if preset is missing to `basic_summon` loadout creation to match old `build_loadout()` behaviour --- common/src/skillset_builder.rs | 14 +++++--------- common/src/states/basic_summon.rs | 3 ++- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/common/src/skillset_builder.rs b/common/src/skillset_builder.rs index 8fddd2b7b1..4f5726b1d2 100644 --- a/common/src/skillset_builder.rs +++ b/common/src/skillset_builder.rs @@ -6,10 +6,11 @@ use crate::assets::{self, AssetExt}; use serde::{Deserialize, Serialize}; use tracing::warn; +/// `SkillSetBuilder` preset. Consider using loading from assets, when possible. +/// When you're adding new enum variant, +/// handle it in [`with_preset`](SkillSetBuilder::with_preset) method #[derive(Copy, Clone, PartialEq, Serialize, Deserialize, Debug)] -pub enum Preset { - Empty, -} +pub enum Preset {} #[derive(Debug, Deserialize, Clone)] struct SkillSetTree(Vec); @@ -89,12 +90,7 @@ impl SkillSetBuilder { /// Applies preset #[must_use] - pub const fn with_preset(self, preset: Preset) -> Self { - match preset { - Preset::Empty => {}, - } - self - } + pub const fn with_preset(self, _preset: Preset) -> Self { self } #[must_use] /// # Panics diff --git a/common/src/states/basic_summon.rs b/common/src/states/basic_summon.rs index 1c094b8883..6a49e33c60 100644 --- a/common/src/states/basic_summon.rs +++ b/common/src/states/basic_summon.rs @@ -84,10 +84,11 @@ impl CharacterBehavior for Data { let loadout = { let loadout_builder = LoadoutBuilder::new().with_default_maintool(&body); + // If preset is none, use default equipment if let Some(preset) = loadout_config { loadout_builder.with_preset(preset).build() } else { - loadout_builder.build() + loadout_builder.with_default_equipment(&body).build() } };