diff --git a/mona_core/src/artifacts/artifact.rs b/mona_core/src/artifacts/artifact.rs index 6a788cc3..0a158380 100644 --- a/mona_core/src/artifacts/artifact.rs +++ b/mona_core/src/artifacts/artifact.rs @@ -75,6 +75,7 @@ pub enum ArtifactSetName { FragmentOfHarmonicWhimsy, UnfinishedReverie, ScrollOfTheHeroOfCinderCity, + ObsidianCodex, } impl ArtifactSetName { diff --git a/mona_core/src/artifacts/artifact_trait.rs b/mona_core/src/artifacts/artifact_trait.rs index 05a67775..02554567 100644 --- a/mona_core/src/artifacts/artifact_trait.rs +++ b/mona_core/src/artifacts/artifact_trait.rs @@ -33,4 +33,7 @@ pub trait ArtifactTrait { #[cfg(not(target_family = "wasm"))] const CONFIG4: Option<&'static [ItemConfig]> = None; + + #[cfg(not(target_family = "wasm"))] + const CONFIG2: Option<&'static [ItemConfig]> = None; } diff --git a/mona_core/src/artifacts/effect_config.rs b/mona_core/src/artifacts/effect_config.rs index be34898d..80c7a477 100644 --- a/mona_core/src/artifacts/effect_config.rs +++ b/mona_core/src/artifacts/effect_config.rs @@ -187,6 +187,13 @@ pub struct ConfigScrollOfTheHeroOfCinder { pub rate2: f64, } +#[derive(Serialize, Deserialize)] +#[derive(Debug, Clone, Default)] +pub struct ConfigObsidianCodex { + pub set2_rate: f64, + pub set4_rate: f64, +} + #[derive(Default, Debug, Clone)] #[derive(Serialize, Deserialize)] pub struct ArtifactEffectConfig { @@ -222,6 +229,7 @@ pub struct ArtifactEffectConfig { pub config_fragment_of_harmonic_whimsy: ConfigLevel, pub config_unfinished_reverie: ConfigRate, pub config_scroll_of_the_hero_of_cinder_city: ConfigScrollOfTheHeroOfCinder, + pub config_obsidian_codex: ConfigObsidianCodex, } #[derive(Serialize, Deserialize)] @@ -259,6 +267,7 @@ pub struct ArtifactConfigInterface { pub config_fragment_of_harmonic_whimsy: Option, pub config_unfinished_reverie: Option, pub config_scroll_of_the_hero_of_cinder_city: Option, + pub config_obsidian_codex: Option, } impl ArtifactConfigInterface { @@ -296,6 +305,7 @@ impl ArtifactConfigInterface { config_fragment_of_harmonic_whimsy: self.config_fragment_of_harmonic_whimsy.unwrap_or_default(), config_unfinished_reverie: self.config_unfinished_reverie.unwrap_or_default(), config_scroll_of_the_hero_of_cinder_city: self.config_scroll_of_the_hero_of_cinder_city.unwrap_or_default(), + config_obsidian_codex: self.config_obsidian_codex.unwrap_or_default(), } } } diff --git a/mona_core/src/artifacts/effects/mod.rs b/mona_core/src/artifacts/effects/mod.rs index 129ac829..3c027501 100644 --- a/mona_core/src/artifacts/effects/mod.rs +++ b/mona_core/src/artifacts/effects/mod.rs @@ -57,6 +57,7 @@ pub use nighttime_whispers_in_the_echoing_woods::NighttimeWhispersInTheEchoingWo pub use fragment_of_harmonic_whimsy::FragmentOfHarmonicWhimsy; pub use unfinished_reverie::UnfinishedReverie; pub use scroll_of_the_hero_of_cinder_city::ScrollOfTheHeroOfCinderCity; +pub use obsidian_codex::ObsidianCodex; pub mod empty; pub mod adventurer; @@ -111,6 +112,7 @@ pub mod nighttime_whispers_in_the_echoing_woods; pub mod fragment_of_harmonic_whimsy; pub mod unfinished_reverie; pub mod scroll_of_the_hero_of_cinder_city; +pub mod obsidian_codex; pub fn get_effect(name: ArtifactSetName, config: &ArtifactEffectConfig, character: &Character) -> Box> { name.create_effect(config, &character.common_data) diff --git a/mona_core/src/artifacts/effects/obsidian_codex.rs b/mona_core/src/artifacts/effects/obsidian_codex.rs new file mode 100644 index 00000000..99f9ff70 --- /dev/null +++ b/mona_core/src/artifacts/effects/obsidian_codex.rs @@ -0,0 +1,101 @@ +use crate::artifacts::artifact_trait::{ArtifactMetaData, ArtifactTrait}; +use crate::artifacts::ArtifactSetName; +use crate::artifacts::effect::ArtifactEffect; +use crate::artifacts::effect_config::ArtifactEffectConfig; +use crate::attribute::{Attribute, AttributeName}; +use crate::character::character_common_data::CharacterCommonData; +use crate::common::i18n::locale; +use crate::common::item_config_type::{ItemConfig, ItemConfigType}; + +pub struct ObsidianCodexEffect { + pub set2_rate: f64, + pub set4_rate: f64, +} + +impl ArtifactEffect for ObsidianCodexEffect { + fn effect2(&self, attribute: &mut A) { + attribute.set_value_by(AttributeName::BonusBase, "黑曜秘典2", self.set2_rate * 0.15); + } + + fn effect4(&self, attribute: &mut A) { + attribute.set_value_by(AttributeName::CriticalBase, "黑曜秘典4", self.set4_rate * 0.4); + } +} + +pub struct ObsidianCodex; + +impl ArtifactTrait for ObsidianCodex { + fn create_effect(config: &ArtifactEffectConfig, character_common_data: &CharacterCommonData) -> Box> { + Box::new(ObsidianCodexEffect { + set2_rate: config.config_obsidian_codex.set2_rate, + set4_rate: config.config_obsidian_codex.set4_rate + }) + } + + #[cfg(not(target_family = "wasm"))] + const META_DATA: ArtifactMetaData = ArtifactMetaData { + name: ArtifactSetName::ObsidianCodex, + name_mona: "ObsidianCodex", + name_locale: locale!( + zh_cn: "黑曜秘典", + en: "Obsidian Codex" + ), + flower: Some(locale!( + zh_cn: "异种的期许", + en: "Reckoning of the Xenogenic" + )), + feather: Some(locale!( + zh_cn: "灵髓的根脉", + en: "Root of the Spirit-Marrow" + )), + sand: Some(locale!( + zh_cn: "夜域的迷思", + en: "Myths of the Night Realm" + )), + goblet: Some(locale!( + zh_cn: "纷争的前宴", + en: "Pre-Banquet of the Contenders" + )), + head: Some(locale!( + zh_cn: "诸圣的礼冠", + en: "Crown of the Saints" + )), + star: (4, 5), + effect1: None, + effect2: Some(locale!( + zh_cn: "装备者处于夜魂加持状态,并且在场上时,造成的伤害提高15%。", + en: "While the equipping character is in Nightsoul's Blessing and is on the field, their DMG dealt is increased by 15%." + )), + effect3: None, + effect4: Some(locale!( + zh_cn: "装备者在场上消耗1点夜魂值后,暴击率提高40%,持续6秒。该效果每1秒至多触发一次。", + en: "After the equipping character consumes 1 Nightsoul point while on the field, CRIT Rate increases by 40% for 6s. This effect can trigger once every second." + )), + effect5: None, + internal_id: 15038, + }; + + #[cfg(not(target_family = "wasm"))] + const CONFIG4: Option<&'static [ItemConfig]> = Some(&[ + ItemConfig { + name: "set4_rate", + title: locale!( + zh_cn: "四件套被动比例", + en: "4-Set Ratio" + ), + config: ItemConfigType::Float { min: 0.0, max: 1.0, default: 0.0 } + } + ]); + + #[cfg(not(target_family = "wasm"))] + const CONFIG2: Option<&'static [ItemConfig]> = Some(&[ + ItemConfig { + name: "set2_rate", + title: locale!( + zh_cn: "二件套被动比例", + en: "2-Set Ratio" + ), + config: ItemConfigType::Float { min: 0.0, max: 1.0, default: 0.0 } + } + ]); +} \ No newline at end of file diff --git a/mona_derive/src/lib.rs b/mona_derive/src/lib.rs index 6973f669..247ea519 100644 --- a/mona_derive/src/lib.rs +++ b/mona_derive/src/lib.rs @@ -140,10 +140,12 @@ pub fn derive_artifact_data(input: TokenStream) -> TokenStream { let mut rows_effect = String::new(); let mut rows_meta = String::new(); let mut rows_config4 = String::new(); + let mut rows_config2 = String::new(); for v in vars.iter() { rows_effect.push_str(&format!("ArtifactSetName::{n} => crate::artifacts::effects::{n}::create_effect(config, common),\n", n=v)); rows_meta.push_str(&format!("ArtifactSetName::{n} => crate::artifacts::effects::{n}::META_DATA,\n", n=v)); rows_config4.push_str(&format!("ArtifactSetName::{n} => crate::artifacts::effects::{n}::CONFIG4,\n", n=v)); + rows_config2.push_str(&format!("ArtifactSetName::{n} => crate::artifacts::effects::{n}::CONFIG2,\n", n=v)) } let output = format!( @@ -172,11 +174,19 @@ pub fn derive_artifact_data(input: TokenStream) -> TokenStream { {rows_config4} }} }} + + #[cfg(not(target_family = "wasm"))] + pub fn get_config2(&self) -> Option<&'static [ItemConfig]> {{ + match *self {{ + {rows_config2} + }} + }} }} "#, rows_effect=rows_effect, rows_meta=rows_meta, - rows_config4=rows_config4 + rows_config4=rows_config4, + rows_config2=rows_config2 ); output.parse().unwrap() diff --git a/mona_generate/src/gen_meta/gen_artifact_meta.rs b/mona_generate/src/gen_meta/gen_artifact_meta.rs index 9cdc103a..3be77e24 100644 --- a/mona_generate/src/gen_meta/gen_artifact_meta.rs +++ b/mona_generate/src/gen_meta/gen_artifact_meta.rs @@ -19,6 +19,7 @@ struct ArtifactMeta { effect4: Option, effect5: Option, config4: Vec, + config2: Vec, flower: Option, feather: Option, @@ -58,6 +59,7 @@ pub fn gen_artifact_meta_as_js_file() -> String { let e: ArtifactSetName = num::FromPrimitive::from_usize(i).unwrap(); let meta: ArtifactMetaData = e.get_meta(); let config4: Option<&'static [ItemConfig]> = e.get_config4(); + let config2: Option<&'static [ItemConfig]> = e.get_config2(); let flower_icon: String = if let Some(_) = meta.flower { format!("UI_RelicIcon_{}_4", meta.internal_id) } else { String::new() }; let feather_icon: String = if let Some(_) = meta.feather { format!("UI_RelicIcon_{}_2", meta.internal_id) } else { String::new() }; @@ -77,6 +79,7 @@ pub fn gen_artifact_meta_as_js_file() -> String { effect4: if let Some(ref x) = meta.effect4 { Some(*index_map.get(x).unwrap()) } else { None }, effect5: if let Some(ref x) = meta.effect5 { Some(*index_map.get(x).unwrap()) } else { None }, config4: config4.unwrap_or(&[]).iter().map(|x| config_to_json(x)).collect(), + config2: config2.unwrap_or(&[]).iter().map(|x| config_to_json(x)).collect(), flower: if let Some(ref x) = meta.flower { Some(*index_map.get(x).unwrap()) } else { None }, feather: if let Some(ref x) = meta.feather { Some(*index_map.get(x).unwrap()) } else { None }, sand: if let Some(ref x) = meta.sand { Some(*index_map.get(x).unwrap()) } else { None }, diff --git a/mona_generate/src/gen_meta/gen_locale.rs b/mona_generate/src/gen_meta/gen_locale.rs index 4a890e11..8dbf52de 100644 --- a/mona_generate/src/gen_meta/gen_locale.rs +++ b/mona_generate/src/gen_meta/gen_locale.rs @@ -178,6 +178,11 @@ pub fn collect_config_locale() -> Vec { set.insert(item.title.clone()); } } + if let Some(x) = a.get_config2() { + for item in x.iter() { + set.insert(item.title.clone()); + } + } } for pf in PotentialFunctionName::iter() { diff --git a/mona_generate/templates/artifact_meta_template.js b/mona_generate/templates/artifact_meta_template.js index cead9989..bec57a21 100644 --- a/mona_generate/templates/artifact_meta_template.js +++ b/mona_generate/templates/artifact_meta_template.js @@ -82,6 +82,11 @@ export default { {{ config|e("none") }}, {% endfor %} ], + config2: [ + {% for config in a.config2 %} + {{ config|e("none") }}, + {% endfor %} + ], }, {% endfor %} } diff --git a/src/composables/artifact.ts b/src/composables/artifact.ts index 16ce13c3..a10a62b4 100644 --- a/src/composables/artifact.ts +++ b/src/composables/artifact.ts @@ -4,7 +4,7 @@ import type {ArtifactSetName, IArtifact, IArtifactWasm} from "@/types/artifact" import {artifactsData} from "@artifact" import {convertArtifact, convertArtifactName} from "@/utils/converter" import {toSnakeCase} from "@/utils/common" -import {newDefaultArtifactConfigForWasm} from "@/utils/artifacts" +import {getArtifactAllConfigsByName, newDefaultArtifactConfigForWasm} from "@/utils/artifacts" import {useI18n} from "@/i18n/i18n" export function use5Artifacts() { @@ -12,7 +12,7 @@ export function use5Artifacts() { const artifactStore = useArtifactStore() const artifactIds = ref([-1, -1, -1, -1, -1]) - // artifact set 4 config + // artifact set 2/4 config const artifactSingleConfig = ref(null) const artifactItems = computed(() => { @@ -61,9 +61,28 @@ export function use5Artifacts() { return null }) - const artifactConfig4ItemName = computed((): string | null => { - if (artifactNeedConfig4.value) { - const setNameWasm = convertArtifactName(artifactNeedConfig4.value) + const artifactNeedConfig2 = computed((): ArtifactSetName | null => { + for (let setName in artifactSetCount.value) { + const count = artifactSetCount.value[setName] + if (count >= 2) { + const data = artifactsData[setName] + if (data.config2 && data.config2.length > 0) { + return setName + } + } + } + + return null + }) + + const artifactConfigItemName = computed((): string | null => { + if (artifactNeedConfig4.value || artifactNeedConfig2.value) { + let setNameWasm; + if (artifactNeedConfig2.value) { + setNameWasm = convertArtifactName(artifactNeedConfig2.value); + } else if (artifactNeedConfig4.value) { + setNameWasm = convertArtifactName(artifactNeedConfig4.value) + } return `config_${toSnakeCase(setNameWasm)}` } return null @@ -77,6 +96,14 @@ export function use5Artifacts() { return ta(data.effect4) }) + const artifactEffect2Text = computed((): string => { + if (!artifactNeedConfig2.value) { + return "" + } + const data = artifactsData[artifactNeedConfig2.value] + return ta(data.effect2) + }) + const artifactConfig4Configs = computed(() => { if (artifactNeedConfig4.value) { const data = artifactsData[artifactNeedConfig4.value] @@ -85,6 +112,14 @@ export function use5Artifacts() { return [] }) + const artifactConfig2Configs = computed(() => { + if (artifactNeedConfig2.value) { + const data = artifactsData[artifactNeedConfig2.value] + return data.config2 + } + return [] + }) + const artifactWasmFormat = computed((): IArtifactWasm[] => { let temp: IArtifactWasm[] = [] for (let id of artifactIds.value) { @@ -103,7 +138,7 @@ export function use5Artifacts() { let base = newDefaultArtifactConfigForWasm() if (artifactNeedConfig4.value) { - let name = artifactConfig4ItemName.value as string + let name = artifactConfigItemName.value as string base[name] = artifactSingleConfig.value[name] } @@ -140,10 +175,31 @@ export function use5Artifacts() { if (!newName) { artifactSingleConfig.value = null } else { - const data = artifactsData[newName] + const configAll = getArtifactAllConfigsByName(newName) + + let defaultConfig: any = {} + for (let c of configAll) { + defaultConfig[c.name] = c.default + } + + const nameWasm = convertArtifactName(newName) + const configItemName = `config_${toSnakeCase(nameWasm)}` + artifactSingleConfig.value = { + [configItemName]: defaultConfig + } + } + }, { + flush: "sync" + }) + + watch(() => artifactNeedConfig2.value, newName => { + if (!newName) { + artifactSingleConfig.value = null + } else { + const configAll = getArtifactAllConfigsByName(newName) let defaultConfig: any = {} - for (let c of data.config4) { + for (let c of configAll) { defaultConfig[c.name] = c.default } @@ -166,13 +222,16 @@ export function use5Artifacts() { artifactItems, artifactSetCount, artifactNeedConfig4, - artifactConfig4ItemName, + artifactNeedConfig2, + artifactConfigItemName, artifactEffect4Text, + artifactEffect2Text, artifactConfig4Configs, + artifactConfig2Configs, artifactConfigForCalculator, setArtifact, removeArtifact, toggleArtifact, } -} \ No newline at end of file +} diff --git a/src/i18n/locales/en.js b/src/i18n/locales/en.js index 6d0a9e23..47fffaf4 100644 --- a/src/i18n/locales/en.js +++ b/src/i18n/locales/en.js @@ -97,6 +97,7 @@ export default { dmg: "DMG", type1: "Type", art4: "Set4: ", + art2: "Set2: ", stat: "Stat", value: "Value", stat1: "Valuable Stat", // todo @@ -230,6 +231,7 @@ export default { saveKumi: "Save as Artifact Group", useKumi: "Use Artifact Group", effect4: "Set4 Effect:", + effect2: "Set2 Effect:", dmg: "DMG Calculation", detail: "Detail", dmg2: "Transformative DMG", diff --git a/src/i18n/locales/zh-cn.js b/src/i18n/locales/zh-cn.js index 3086bda9..7f1e4725 100644 --- a/src/i18n/locales/zh-cn.js +++ b/src/i18n/locales/zh-cn.js @@ -97,6 +97,7 @@ export default { dmg: "伤害", type1: "类型", art4: "四件套:", + art2: "二件套:", stat: "词条", value: "值", stat1: "有效词条数", @@ -232,6 +233,7 @@ export default { saveKumi: "存为套装", useKumi: "应用套装", effect4: "四件套效果:", + effect2: "二件套效果:", dmg: "伤害计算", detail: "明细", dmg2: "剧变反应伤害", diff --git a/src/pages/NewArtifactPlanPage/ArtifactConfig.vue b/src/pages/NewArtifactPlanPage/ArtifactConfig.vue index c17b3531..b34a99ef 100644 --- a/src/pages/NewArtifactPlanPage/ArtifactConfig.vue +++ b/src/pages/NewArtifactPlanPage/ArtifactConfig.vue @@ -21,14 +21,29 @@

{{ item.title }}

-

- {{ t("misc.art4") }} - {{ item.effect4 }} -

+
+

+ {{ t("misc.art2") }} + {{ item.effect2 }} +

+

+ {{ t("misc.art4") }} + {{ item.effect4 }} +

+
+ 0) { + if (config4.length > 0 || config2.length > 0) { results.push({ name: name2, title: this.ta(d.nameLocale), eng: d.eng, snake: "config_" + toSnakeCase(name2), - config4: config, + config4: config4, + config2: config2, effect4: this.ta(d.effect4), + effect2: this.ta(d.effect2), thumbnail: getArtifactThumbnail(name), // chs: d.chs, }) @@ -88,18 +106,27 @@ export default { return this.data } else { const fuse = new Fuse(this.data, { - keys: ["title", "effect4"] + keys: ["title", "effect4", "effect2"] }) const results = fuse.search(this.searchString) return results.map(x => x.item) } - } + }, }, methods: { handleChangeValue(snake, value) { + // console.log(snake, value) let temp = deepCopy(this.modelValue) temp[snake] = value this.$emit("update:modelValue", temp) + }, + + hasConfig2(item) { + return item.config2 && item.config2.length > 0 + }, + + hasConfig4(item) { + return item.config4 && item.config4.length > 0 } }, setup() { @@ -149,4 +176,4 @@ export default { } } } - \ No newline at end of file + diff --git a/src/pages/NewArtifactPlanPage/NewArtifactPlanPage.vue b/src/pages/NewArtifactPlanPage/NewArtifactPlanPage.vue index e766a61a..4cae2543 100644 --- a/src/pages/NewArtifactPlanPage/NewArtifactPlanPage.vue +++ b/src/pages/NewArtifactPlanPage/NewArtifactPlanPage.vue @@ -557,6 +557,19 @@ +
+

+ {{ t("calcPage.effect2") }} + +

+ +
+

{{ t("calcPage.effect4") }} @@ -565,7 +578,7 @@

@@ -826,9 +839,12 @@ const { artifactItems, artifactSetCount, artifactNeedConfig4, - artifactConfig4ItemName, + artifactNeedConfig2, + artifactConfigItemName, artifactEffect4Text, + artifactEffect2Text, artifactConfig4Configs, + artifactConfig2Configs, artifactConfigForCalculator, setArtifact, @@ -1708,7 +1724,7 @@ watch(() => accountStore.currentAccountId.value, () => { } //artifact effect description title -.effect4 { +.effect4, .effect2 { color: #6eb7ff; } diff --git a/src/utils/artifacts.ts b/src/utils/artifacts.ts index 68f0b975..d2e19f44 100644 --- a/src/utils/artifacts.ts +++ b/src/utils/artifacts.ts @@ -39,9 +39,11 @@ export function newDefaultArtifactConfigForWasm(): any { const data = artifactsData[name] const name2 = data.name2 const config4 = data.config4 ?? [] - if (config4.length > 0) { + const config2 = data.config2 ?? [] + const configAll = config2.concat(config4) + if (configAll.length > 0) { let c: any = {} - for (let item of config4) { + for (let item of configAll) { c[item.name] = deepCopy(item.default) } @@ -341,3 +343,13 @@ export function statName2Locale(name: ArtifactStatName): string { // return data.chs return t("stat", data.name) } + +export function getArtifactAllConfigs(item: any): any { + const config2 = item.config2 ?? [] + const config4 = item.config4 ?? [] + return config2.concat(config4) +} + +export function getArtifactAllConfigsByName(name: ArtifactSetName): any { + return getArtifactAllConfigs(artifactsData[name]) +}