Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Option active variants #42

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 64 additions & 15 deletions src/perks/perk_options_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@ use std::collections::HashMap;
use serde::Serialize;

use super::{enhanced_check, Perk, Perks};

#[derive(Debug, Clone, Serialize, Default)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum PerkValueVariant {
#[default]
STATIC,
TOGGLE,
SLIDER,
OPTIONS,
Static,
Toggle,
ActiveToggle,
Slider,
ActiveSlider,
Options,
ActiveOptions,
}


#[derive(Debug, Clone, Serialize)]
pub struct PerkOptionData {
stacks: (u32, u32),
Expand All @@ -25,28 +29,49 @@ impl PerkOptionData {
PerkOptionData {
stacks: (0, 0),
options: vec![],
option_type: PerkValueVariant::STATIC,
option_type: PerkValueVariant::Static,
}
}
pub fn toggle() -> PerkOptionData {
PerkOptionData {
stacks: (0, 1),
options: vec![],
option_type: PerkValueVariant::TOGGLE,
option_type: PerkValueVariant::Toggle,
}
}
pub fn active_toggle() -> PerkOptionData {
PerkOptionData {
stacks: (0, 1),
options: vec![],
option_type: PerkValueVariant::ActiveToggle,
}
}
pub fn stacking(_stacks: u32) -> PerkOptionData {
PerkOptionData {
stacks: (0, _stacks),
options: vec![],
option_type: PerkValueVariant::SLIDER,
option_type: PerkValueVariant::Slider,
}
}
pub fn active_stacking(_stacks: u32) -> PerkOptionData {
PerkOptionData {
stacks: (0, _stacks),
options: vec![],
option_type: PerkValueVariant::ActiveSlider,
}
}
pub fn stacking_min(_stacks: u32, _min_stacks: u32) -> PerkOptionData {
PerkOptionData {
stacks: (_min_stacks, _stacks),
options: vec![],
option_type: PerkValueVariant::SLIDER,
option_type: PerkValueVariant::Slider,
}
}
pub fn active_stacking_min(_stacks: u32, _min_stacks: u32) -> PerkOptionData {
PerkOptionData {
stacks: (_min_stacks, _stacks),
options: vec![],
option_type: PerkValueVariant::ActiveSlider,
}
}
pub fn options(_options: Vec<&str>) -> PerkOptionData {
Expand All @@ -57,7 +82,18 @@ impl PerkOptionData {
PerkOptionData {
stacks: (0, options.len() as u32 - 1),
options,
option_type: PerkValueVariant::OPTIONS,
option_type: PerkValueVariant::Options,
}
}
pub fn active_options(_options: Vec<&str>) -> PerkOptionData {
let mut options = vec!["None".to_string()];
for option in _options {
options.push(option.to_string());
}
PerkOptionData {
stacks: (0, options.len() as u32 - 1),
options,
option_type: PerkValueVariant::ActiveOptions,
}
}
pub fn options_raw(_options: Vec<&str>) -> PerkOptionData {
Expand All @@ -68,7 +104,18 @@ impl PerkOptionData {
PerkOptionData {
stacks: (0, options.len() as u32 - 1),
options,
option_type: PerkValueVariant::OPTIONS,
option_type: PerkValueVariant::Options,
}
}
pub fn active_options_raw(_options: Vec<&str>) -> PerkOptionData {
let mut options = vec![];
for option in _options {
options.push(option.to_string());
}
PerkOptionData {
stacks: (0, options.len() as u32 - 1),
options,
option_type: PerkValueVariant::ActiveOptions,
}
}
}
Expand Down Expand Up @@ -283,16 +330,18 @@ fn hash_to_perk_option_data(_hash: u32) -> Option<PerkOptionData> {
Perks::UnsatedHunger => Some(PerkOptionData::toggle()),
Perks::Discord => Some(PerkOptionData::toggle()),
//season 22 | year 6
Perks::PrecisionInstrument => Some(PerkOptionData::stacking(6)),
Perks::PrecisionInstrument => Some(PerkOptionData::active_stacking(6)),
Perks::LooseChange => Some(PerkOptionData::toggle()),
Perks::HighGround => Some(PerkOptionData::toggle()),
Perks::HeadRush => Some(PerkOptionData::toggle()),
Perks::EnlightendAction => Some(PerkOptionData::stacking(5)),
Perks::EnlightendAction => Some(PerkOptionData::active_stacking(5)),
Perks::SwordLogic => Some(PerkOptionData::stacking(4)),

//exotics
Perks::CranialSpike => Some(PerkOptionData::stacking(5)),
Perks::DarkForgedTrigger => Some(PerkOptionData::options_raw(["Hip-Fire", "ADS"].to_vec())),
Perks::CranialSpike => Some(PerkOptionData::active_stacking(5)),
Perks::DarkForgedTrigger => Some(PerkOptionData::active_options_raw(
["Hip-Fire", "ADS"].to_vec(),
)),
Perks::AgersCall => Some(PerkOptionData::static_()),
Perks::LagragianSight => Some(PerkOptionData::toggle()),
Perks::StringofCurses => Some(PerkOptionData::stacking(5)),
Expand Down