Skip to content

Commit

Permalink
feat: Add some weapons
Browse files Browse the repository at this point in the history
  • Loading branch information
wormtql committed Aug 28, 2024
1 parent 660eec0 commit 817d0a1
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 1 deletion.
2 changes: 2 additions & 0 deletions mona_core/src/weapon/weapon_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ pub enum WeaponConfig {
TomeOfTheEternalFlow { stack: f64 },
CranesEchoingCall { rate: f64 },
RingOfYaxche { rate: f64 },
SurfsUp { stack: f64 },

// Bow
PolarStar { stack: usize },
Expand Down Expand Up @@ -137,6 +138,7 @@ pub enum WeaponConfig {
RangeGauge { stack: f64 },
Cloudforged { stack: f64 },
SilvershowerHeartstrings { stack: f64, stack3_rate: f64 },
ChainBreaker { count: usize },
}

impl Default for WeaponConfig {
Expand Down
2 changes: 2 additions & 0 deletions mona_core/src/weapon/weapon_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ pub enum WeaponName {
CranesEchoingCall,
AshGravenDrinkingHorn,
RingOfYaxche,
SurfsUp,

// bows
PolarStar,
Expand Down Expand Up @@ -213,4 +214,5 @@ pub enum WeaponName {
RangeGauge,
Cloudforged,
SilvershowerHeartstrings,
ChainBreaker,
}
72 changes: 72 additions & 0 deletions mona_core/src/weapon/weapons/bows/chain_breaker.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
use crate::attribute::{Attribute, AttributeCommon, AttributeName};
use crate::character::character_common_data::CharacterCommonData;
use crate::common::i18n::locale;
use crate::common::item_config_type::{ItemConfig, ItemConfigType};
use crate::common::WeaponType;
use crate::weapon::weapon_common_data::WeaponCommonData;
use crate::weapon::weapon_effect::WeaponEffect;
use crate::weapon::weapon_static_data::WeaponStaticData;
use crate::weapon::weapon_trait::WeaponTrait;
use crate::weapon::{WeaponConfig, WeaponName};
use crate::weapon::weapon_base_atk::WeaponBaseATKFamily;
use crate::weapon::weapon_sub_stat::WeaponSubStatFamily;

struct ChainBreakerEffect {
pub count: usize,
}

impl<A: Attribute> WeaponEffect<A> for ChainBreakerEffect {
fn apply(&self, data: &WeaponCommonData, attribute: &mut A) {
let refine = data.refine as f64;

let step = 0.036 + 0.012 * refine;
attribute.add_atk_percentage("碎链被动", step * self.count as f64);
if self.count >= 3 {
attribute.set_value_by(AttributeName::ElementalMastery, "碎链被动", 18.0 + 6.0 * refine);
}
}
}

pub struct ChainBreaker;

impl WeaponTrait for ChainBreaker {
const META_DATA: WeaponStaticData = WeaponStaticData {
name: WeaponName::ChainBreaker,
internal_name: "Bow_Isikhulu",
weapon_type: WeaponType::Bow,
weapon_sub_stat: Some(WeaponSubStatFamily::ATK60),
weapon_base: WeaponBaseATKFamily::ATK565,
star: 4,
#[cfg(not(target_family = "wasm"))]
effect: Some(locale!(
zh_cn: "队伍中每有一名纳塔角色或与装备者元素类型不同的角色,装备者获得<span style=\"color: #409EFF;\">4.8%-6%-7.2%-8.4%-9.6%</span>攻击力提升;上述角色不少于3名时,装备者的元素精通提升<span style=\"color: #409EFF;\">24-30-36-42-48</span>点。",
en: "For every party member from Natlan or who has a different Elemental Type from the equipping character, the equipping character gains <span style=\"color: #409EFF;\">4.8%-6%-7.2%-8.4%-9.6%</span> increased ATK. When there are no less than 3 of the aforementioned characters, the equipping character gains <span style=\"color: #409EFF;\">24-30-36-42-48</span> Elemental Mastery."
)),
#[cfg(not(target_family = "wasm"))]
name_locale: locale!(
zh_cn: "碎链",
en: "Chain Breaker"
),
};

#[cfg(not(target_family = "wasm"))]
const CONFIG_DATA: Option<&'static [ItemConfig]> = Some(&[
ItemConfig {
name: "count",
title: locale!(
zh_cn: "纳塔角色或与装备者元素类型不同的角色数量",
en: "Characters number from Natlan or who has a different Elemental Type from the equipping character"
),
config: ItemConfigType::Int { min: 0, max: 4, default: 4 }
}
]);

fn get_effect<A: Attribute>(character: &CharacterCommonData, config: &WeaponConfig) -> Option<Box<dyn WeaponEffect<A>>> {
match *config {
WeaponConfig::ChainBreaker { count } => Some(Box::new(ChainBreakerEffect {
count
})),
_ => None
}
}
}
2 changes: 2 additions & 0 deletions mona_core/src/weapon/weapons/bows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub use song_of_stillness::SongOfStillness;
pub use range_gauge::RangeGauge;
pub use cloudforged::Cloudforged;
pub use silvershower_heartstrings::SilvershowerHeartstrings;
pub use chain_breaker::ChainBreaker;

pub mod polar_star;
pub mod thundering_pulse;
Expand Down Expand Up @@ -77,3 +78,4 @@ pub mod song_of_stillness;
pub mod range_gauge;
pub mod cloudforged;
pub mod silvershower_heartstrings;
mod chain_breaker;
2 changes: 2 additions & 0 deletions mona_core/src/weapon/weapons/catalysts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub use tome_of_the_eternal_flow::TomeOfTheEternalFlow;
pub use cranes_echoing_call::CranesEchoingCall;
pub use ash_graven_drinking_horn::AshGravenDrinkingHorn;
pub use ring_of_yaxche::RingOfYaxche;
pub use surfs_up::SurfsUp;

pub mod lost_prayer_to_the_sacred_winds;
pub mod skyward_atlas;
Expand Down Expand Up @@ -77,3 +78,4 @@ pub mod tome_of_the_eternal_flow;
pub mod cranes_echoing_call;
mod ash_graven_drinking_horn;
mod ring_of_yaxche;
mod surfs_up;
2 changes: 1 addition & 1 deletion mona_core/src/weapon/weapons/catalysts/ring_of_yaxche.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl<A: Attribute> WeaponEffect<A> for RingOfYaxcheEffect {
attribute.add_edge1(
AttributeName::HP,
AttributeName::BonusNormalAttack,
Box::new(|hp, _| ((hp / 1000.0).floor() * step).min(max)),
Box::new(move |hp, _| ((hp / 1000.0).floor() * step).min(max)),
Box::new(|_x, _y, _grad| (0.0, 0.0)),
"木棉之环被动"
);
Expand Down
63 changes: 63 additions & 0 deletions mona_core/src/weapon/weapons/catalysts/surfs_up.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
use crate::attribute::{Attribute, AttributeCommon, AttributeName};
use crate::character::character_common_data::CharacterCommonData;
use crate::common::i18n::locale;
use crate::common::item_config_type::ItemConfig;
use crate::common::WeaponType;
use crate::weapon::weapon_common_data::WeaponCommonData;
use crate::weapon::weapon_effect::WeaponEffect;
use crate::weapon::weapon_static_data::WeaponStaticData;
use crate::weapon::weapon_trait::WeaponTrait;
use crate::weapon::{WeaponConfig, WeaponName};
use crate::weapon::weapon_base_atk::WeaponBaseATKFamily;
use crate::weapon::weapon_sub_stat::WeaponSubStatFamily;

struct SurfsUpEffect {
pub stack: f64,
}

impl<A: Attribute> WeaponEffect<A> for SurfsUpEffect {
fn apply(&self, data: &WeaponCommonData, attribute: &mut A) {

let refine = data.refine as f64;

attribute.add_hp_percentage("冲浪时光被动", 0.15 + 0.05 * refine);
attribute.set_value_by(AttributeName::BonusNormalAttack, "冲浪时光被动", (0.09 + 0.03 * refine) * self.stack);
}
}

pub struct SurfsUp;

impl WeaponTrait for SurfsUp {
const META_DATA: WeaponStaticData = WeaponStaticData {
name: WeaponName::SurfsUp,
internal_name: "Catalyst_MechaPufferfish",
weapon_type: WeaponType::Catalyst,
weapon_sub_stat: Some(WeaponSubStatFamily::CriticalDamage192),
weapon_base: WeaponBaseATKFamily::ATK542,
star: 5,
#[cfg(not(target_family = "wasm"))]
effect: Some(locale!(
zh_cn: "生命值上限提高<span style=\"color: #409EFF;\">20%-25%-30%-35%-40%</span>。每15秒一次,施放元素战技后的14秒内,产生如下效果:获得4层「炽夏」,每层使普通攻击造成的伤害提升<span style=\"color: #409EFF;\">12%-15%-18%-21%-24%</span>。持续期间内,每1.5秒一次:普通攻击命中敌人后,移除1层;每1.5秒一次:对敌人触发蒸发反应后,增加1层。「炽夏」效果至多叠加4层。",
en: "Max HP increased by <span style=\"color: #409EFF;\">20%-25%-30%-35%-40%</span>. Once every 15s, for the 14s after using an Elemental Skill: Gain 4 Scorching Summer stacks. Each stack increases Normal Attack DMG by <span style=\"color: #409EFF;\">12%-15%-18%-21%-24%</span>. For the duration of the effect, once every 1.5s, lose 1 stack after a Normal Attack hits an opponent; once every 1.5s, gain 1 stack after triggering a Vaporize reaction on an opponent. Max 4 Scorching Summer stacks."
)),
#[cfg(not(target_family = "wasm"))]
name_locale: locale!(
zh_cn: "冲浪时光",
en: "Surf’s Up"
),
};

#[cfg(not(target_family = "wasm"))]
const CONFIG_DATA: Option<&'static [ItemConfig]> = Some(&[
ItemConfig::STACK04
]);

fn get_effect<A: Attribute>(character: &CharacterCommonData, config: &WeaponConfig) -> Option<Box<dyn WeaponEffect<A>>> {
match *config {
WeaponConfig::SurfsUp { stack } => Some(Box::new(SurfsUpEffect {
stack
})),
_ => None
}
}
}

0 comments on commit 817d0a1

Please sign in to comment.