Skip to content

Commit

Permalink
feat: Add Xianyun buffs
Browse files Browse the repository at this point in the history
  • Loading branch information
wormtql committed Jan 30, 2024
1 parent 2b13b83 commit 018d649
Show file tree
Hide file tree
Showing 7 changed files with 210 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mona_core/src/buffs/buff_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ pub enum BuffConfig {
KavehQ { q_level: usize, rate: f64 },
BaizhuTalent2 { hp: f64, rate: f64 },
BaizhuC4 { rate: f64 },
XianyunTalent1 { stack: f64 },
XianyunTalent2 { rate: f64, c2: bool, atk: f64 },

FreedomSworn { refine: usize },
SongOfBrokenPines { refine: usize },
Expand Down
2 changes: 2 additions & 0 deletions mona_core/src/buffs/buff_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ pub enum BuffName {
KavehQ,
BaizhuTalent2,
BaizhuC4,
XianyunTalent1,
XianyunTalent2,

// weapon
FreedomSworn,
Expand Down
2 changes: 2 additions & 0 deletions mona_core/src/buffs/buffs/character/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub use faruzan::BuffFaruzanQ;
pub use mika::BuffMika;
pub use kaveh::BuffKavehQ;
pub use baizhu::{BuffBaizhuC4, BuffBaizhuTalent2};
pub use xianyun::{BuffXianyunTalent1, BuffXianyunTalent2};

pub mod albedo;
pub mod aloy;
Expand Down Expand Up @@ -89,3 +90,4 @@ pub mod faruzan;
pub mod mika;
pub mod kaveh;
pub mod baizhu;
pub mod xianyun;
136 changes: 136 additions & 0 deletions mona_core/src/buffs/buffs/character/xianyun.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
use crate::attribute::{Attribute, AttributeName};
use crate::buffs::{Buff, BuffConfig};
use crate::buffs::buff::BuffMeta;
use crate::buffs::buff_meta::{BuffFrom, BuffGenre, BuffImage, BuffMetaData};
use crate::buffs::buff_name::BuffName;
use crate::character::CharacterName;
use crate::common::i18n::locale;
use crate::common::item_config_type::{ItemConfig, ItemConfigType};
use crate::enemies::Enemy;

pub struct BuffXianyunTalent1 {
pub stack: f64,
}

impl<A: Attribute> Buff<A> for BuffXianyunTalent1 {
fn change_attribute(&self, attribute: &mut A) {
let bonus = if self.stack < 1e-6 {
0.0
} else if self.stack >= 1e-6 && self.stack < 1.0 {
self.stack * 0.04
} else {
0.02 + self.stack * 0.02
};
attribute.set_value_by(AttributeName::CriticalBase, "BUFF: 闲云天赋1「霜翎高逐祥风势」", bonus);
}
}

impl BuffMeta for BuffXianyunTalent1 {
#[cfg(not(target_family = "wasm"))]
const META_DATA: BuffMetaData = BuffMetaData {
name: BuffName::XianyunTalent1,
name_locale: locale!(
zh_cn: "闲云-「霜翎高逐祥风势」",
en: "Xianun-「Galefeather Pursuit」"
),
image: BuffImage::Avatar(CharacterName::Xianyun),
genre: BuffGenre::Character,
description: Some(locale!(
zh_cn: "朝起鹤云的闲云冲击波每命中一个敌人,都将为队伍中附近的所有角色产生一层持续20秒,至多叠加4层的「风翎」效果,使角色的下落攻击的暴击率提升4%/6%/8%/10%。每次命中敌人产生的「风翎」的持续时间独立计算。",
en: "Each opponent hit by Driftcloud Waves from White Clouds at Dawn will grant all nearby party members 1 stack of Storm Pinion for 20s. Max 4 stacks. These will cause the characters' Plunging Attack CRIT Rate to increase by 4%/6%/8%/10% respectively. Each Storm Pinion created by hitting an opponent has an independent duration."
)),
from: BuffFrom::Character(CharacterName::Xianyun)
};

#[cfg(not(target_family = "wasm"))]
const CONFIG: Option<&'static [ItemConfig]> = Some(&[
ItemConfig {
name: "stack",
title: locale!(
zh_cn: "层数",
en: "Stack"
),
config: ItemConfigType::Float { min: 0.0, max: 4.0, default: 4.0 }
}
]);

fn create<A: Attribute>(b: &BuffConfig) -> Box<dyn Buff<A>> {
let stack = match *b {
BuffConfig::XianyunTalent1 { stack } => stack,
_ => 0.0
};
Box::new(BuffXianyunTalent1 {
stack
})
}
}

pub struct BuffXianyunTalent2 {
pub rate: f64,
pub c2: bool,
pub atk: f64,
}

impl<A: Attribute> Buff<A> for BuffXianyunTalent2 {
fn change_attribute(&self, attribute: &mut A) {
let factor = if self.c2 { 2.0 } else { 1.0 };
let dmg = (9000.0_f64 * factor).min(self.atk * 2.0 * factor);
attribute.set_value_by(AttributeName::ExtraDmgPlungingAttack3, "闲云天赋2「细想应是洞中仙」", dmg);
}
}

impl BuffMeta for BuffXianyunTalent2 {
#[cfg(not(target_family = "wasm"))]
const META_DATA: BuffMetaData = BuffMetaData {
name: BuffName::XianyunTalent2,
name_locale: locale!(
zh_cn: "闲云-「细想应是洞中仙」",
en: "Xianyun-「Consider, the Adeptus in Her Realm」"
),
image: BuffImage::Avatar(CharacterName::Xianyun),
genre: BuffGenre::Character,
description: Some(locale!(
zh_cn: "暮集竹星的竹星拥有仙力助推时,附近的当前场上角色的下落攻击坠地冲击造成的伤害提升,提升值相当于闲云的攻击力的200%。通过这种方式,至多使附近的当前场上角色的下落攻击坠地冲击伤害提升9000。<br>C2:固有天赋「细想应是洞中仙」的效果获得提升:暮集竹星的竹星拥有仙力助推时,附近的当前场上角色的下落攻击坠地冲击造成的伤害提升,提升值相当于闲云的攻击力的400%。通过这种方式,至多使附近的当前场上角色的下落攻击坠地冲击伤害提升18000。",
en: "When the Starwicker created by Stars Gather at Dusk has Adeptal Assistance stacks, nearby active characters' Plunging Attack shockwave DMG will be increased by 200% of Xianyun's ATK. The maximum DMG increase that can be achieved this way is 9,000.<br>C2: the effects of the Passive Talent \"Consider, the Adeptus in Her Realm\" will be enhanced: When the Starwicker created by Stars Gather at Dusk has Adeptal Assistance stacks, nearby active characters' Plunging Attack shockwave DMG will be increased by 400% of Xianyun's ATK. The maximum DMG increase that can be achieved this way is 18,000."
)),
from: BuffFrom::Character(CharacterName::Xianyun)
};

#[cfg(not(target_family = "wasm"))]
const CONFIG: Option<&'static [ItemConfig]> = Some(&[
ItemConfig {
name: "rate",
title: locale!(
zh_cn: "应用比例",
en: "Ratio"
),
config: ItemConfigType::Float { min: 0.0, max: 1.0, default: 1.0 }
},
ItemConfig {
name: "c2",
title: locale!(
zh_cn: "命座2「鹤唳远人间」",
en: "C2"
),
config: ItemConfigType::Bool { default: false }
},
ItemConfig {
name: "atk",
title: locale!(
zh_cn: "闲云的攻击力",
en: "ATK of Xianyun"
),
config: ItemConfigType::Float { min: 0.0, max: 10000.0, default: 2000.0 }
}
]);

fn create<A: Attribute>(b: &BuffConfig) -> Box<dyn Buff<A>> {
let (rate, c2, atk) = match *b {
BuffConfig::XianyunTalent2 { rate, c2, atk } => (rate, c2, atk),
_ => (0.0, false, 0.0)
};
Box::new(BuffXianyunTalent2 {
rate, c2, atk
})
}
}
1 change: 1 addition & 0 deletions mona_core/src/target_functions/target_function_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,5 @@ pub enum TargetFunctionName {
WriothesleyDefault,
FurinaDefault,
NaviaDefault,
XianyunDefault,
}
2 changes: 2 additions & 0 deletions mona_core/src/target_functions/target_functions/anemo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub mod xiao_default;
pub mod shikanoin_heizou_default;
pub mod wanderer_default;
pub mod faruzan_damage;
pub mod xianyun_default;

pub use jean_default::JeanDefaultTargetFunction;
pub use kaedehara_kazuha_damage::KaedeharaKazuhaDamageTargetFunction;
Expand All @@ -19,3 +20,4 @@ pub use xiao_default::XiaoDefaultTargetFunction;
pub use shikanoin_heizou_default::ShikanoinHeizouDefaultTargetFunction;
pub use wanderer_default::WandererDefaultTargetFunction;
pub use faruzan_damage::FaruzanDamageTargetFunction;
pub use xianyun_default::XianyunDefaultTargetFunction;
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
use crate::artifacts::Artifact;
use crate::artifacts::effect_config::ArtifactEffectConfig;
use crate::attribute::SimpleAttributeGraph2;
use crate::character::{Character, CharacterName};
use crate::character::character_common_data::CharacterCommonData;
use crate::character::characters::Xianyun;
use crate::character::skill_config::CharacterSkillConfig;
use crate::character::traits::CharacterTrait;
use crate::common::i18n::locale;
use crate::damage::{DamageContext, SimpleDamageBuilder};
use crate::enemies::Enemy;
use crate::target_functions::target_function::TargetFunctionMetaTrait;
use crate::target_functions::target_function_meta::{TargetFunctionFor, TargetFunctionMeta, TargetFunctionMetaImage};
use crate::target_functions::target_function_opt_config::TargetFunctionOptConfig;
use crate::target_functions::{TargetFunction, TargetFunctionConfig, TargetFunctionName};
use crate::team::TeamQuantization;
use crate::weapon::Weapon;
use crate::weapon::weapon_common_data::WeaponCommonData;

pub struct XianyunDefaultTargetFunction;

impl TargetFunction for XianyunDefaultTargetFunction {
fn get_target_function_opt_config(&self) -> TargetFunctionOptConfig {
unimplemented!()
}

fn get_default_artifact_config(&self, team_config: &TeamQuantization) -> ArtifactEffectConfig {
Default::default()
}

fn target(&self, attribute: &SimpleAttributeGraph2, character: &Character<SimpleAttributeGraph2>, weapon: &Weapon<SimpleAttributeGraph2>, artifacts: &[&Artifact], enemy: &Enemy) -> f64 {
let context: DamageContext<'_, SimpleAttributeGraph2> = DamageContext {
character_common_data: &character.common_data,
attribute, enemy
};

type S = <Xianyun as CharacterTrait>::DamageEnumType;
let damage = Xianyun::damage::<SimpleDamageBuilder>(
&context, S::E4, &CharacterSkillConfig::NoConfig, None
);
damage.normal.expectation
}
}

impl TargetFunctionMetaTrait for XianyunDefaultTargetFunction {
#[cfg(not(target_family = "wasm"))]
const META_DATA: TargetFunctionMeta = TargetFunctionMeta {
name: TargetFunctionName::XianyunDefault,
name_locale: locale!(
zh_cn: "闲云-鸾音鹤信",
en: "Xianyun-Passerine Herald"
),
description: locale!(
zh_cn: "最大化闲云冲击波",
en: "Maximize Driftcloud Wave DMG"
),
tags: "",
four: TargetFunctionFor::SomeWho(CharacterName::Xianyun),
image: TargetFunctionMetaImage::Avatar
};

fn create(character: &CharacterCommonData, weapon: &WeaponCommonData, config: &TargetFunctionConfig) -> Box<dyn TargetFunction> {
Box::new(XianyunDefaultTargetFunction)
}
}

0 comments on commit 018d649

Please sign in to comment.