Skip to content
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ group_imports = "StdExternalCrate"
use_field_init_shorthand = true
normalize_comments = true
empty_item_single_line = false
use_small_heuristics = "max"
26 changes: 6 additions & 20 deletions benches/battle_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ fn battle_benchmark(c: &mut Criterion) {

for (name, class, dungeon, finished) in cases {
group.bench_function(name, |b| {
let progress = DungeonProgress::Open {
finished: finished - 1,
};
let progress = DungeonProgress::Open { finished: finished - 1 };

let monster =
Fighter::from(get_dungeon_monster(dungeon, progress).unwrap());
Expand Down Expand Up @@ -112,10 +110,7 @@ fn init_squad(class: Class, init_companions: bool) -> PlayerFighterSquad {
belt.type_specific_val = armor;
}

PlayerFighterSquad {
character: account,
companions,
}
PlayerFighterSquad { character: account, companions }
}

fn create_fighter(class: Class, is_companion: bool) -> UpgradeableFighter {
Expand All @@ -138,11 +133,8 @@ fn create_fighter(class: Class, is_companion: bool) -> UpgradeableFighter {

let mut equipment = Equipment::default();

equipment.0[EquipmentSlot::Hat] = Some(create_rune_item(
ItemType::Hat,
RuneType::FireResistance,
75,
));
equipment.0[EquipmentSlot::Hat] =
Some(create_rune_item(ItemType::Hat, RuneType::FireResistance, 75));
equipment.0[EquipmentSlot::BreastPlate] = Some(create_rune_item(
ItemType::BreastPlate,
RuneType::ColdResistence,
Expand All @@ -166,10 +158,7 @@ fn create_fighter(class: Class, is_companion: bool) -> UpgradeableFighter {

let weapon = Item {
typ: ItemType::Weapon { min_dmg, max_dmg },
rune: Some(Rune {
typ: RuneType::FireDamage,
value: 60,
}),
rune: Some(Rune { typ: RuneType::FireDamage, value: 60 }),
enchantment: Some(Enchantment::SwordOfVengeance),
// Defaults
model_id: 1,
Expand Down Expand Up @@ -219,10 +208,7 @@ fn create_fighter(class: Class, is_companion: bool) -> UpgradeableFighter {
fn create_rune_item(typ: ItemType, rune_typ: RuneType, value: u8) -> Item {
Item {
typ,
rune: Some(Rune {
typ: rune_typ,
value,
}),
rune: Some(Rune { typ: rune_typ, value }),
// Defaults
model_id: 1,
price: 0,
Expand Down
73 changes: 23 additions & 50 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,10 @@ fn main() {
"The_3rd_League_of_Superheroes",
"LightDungeon::ThirdLeagueOfSuperheroes",
),
(
"Dojo_of_Childhood_Heroes",
"LightDungeon::DojoOfChildhoodHeroes",
),
("Dojo_of_Childhood_Heroes", "LightDungeon::DojoOfChildhoodHeroes"),
("Monster_Grotto", "LightDungeon::MonsterGrotto"),
("City_of_Intrigues", "LightDungeon::CityOfIntrigues"),
(
"School_of_magic_Express",
"LightDungeon::SchoolOfMagicExpress",
),
("School_of_magic_Express", "LightDungeon::SchoolOfMagicExpress"),
("Ash_Mountain", "LightDungeon::AshMountain"),
("Playa_HQ", "LightDungeon::PlayaGamesHQ"),
("Training_Camp", "LightDungeon::TrainingCamp"),
Expand All @@ -78,31 +72,16 @@ fn main() {
];

let shadow_dungeons = [
(
"Shadow_Desecrated_Catacombs",
"ShadowDungeon::DesecratedCatacombs",
),
("Shadow_Desecrated_Catacombs", "ShadowDungeon::DesecratedCatacombs"),
("Shadow_Mines_of_Gloria", "ShadowDungeon::MinesOfGloria"),
("Shadow_Ruins_of_Gnark", "ShadowDungeon::RuinsOfGnark"),
("Shadow_Cutthroat_Grotto", "ShadowDungeon::CutthroatGrotto"),
(
"Shadow_Emerald_Scale_Altar",
"ShadowDungeon::EmeraldScaleAltar",
),
("Shadow_Emerald_Scale_Altar", "ShadowDungeon::EmeraldScaleAltar"),
("Shadow_Toxic_Tree", "ShadowDungeon::ToxicTree"),
("Shadow_Magma_Stream", "ShadowDungeon::MagmaStream"),
(
"Shadow_Frost_Blood_Temple",
"ShadowDungeon::FrostBloodTemple",
),
(
"Shadow_Pyramids_of_Madness",
"ShadowDungeon::PyramidsOfMadness",
),
(
"Shadow_Black_Skull_Fortress",
"ShadowDungeon::BlackSkullFortress",
),
("Shadow_Frost_Blood_Temple", "ShadowDungeon::FrostBloodTemple"),
("Shadow_Pyramids_of_Madness", "ShadowDungeon::PyramidsOfMadness"),
("Shadow_Black_Skull_Fortress", "ShadowDungeon::BlackSkullFortress"),
("Shadow_Circus_of_Horror", "ShadowDungeon::CircusOfHorror"),
("Shadow_Hell", "ShadowDungeon::Hell"),
("Shadow_The_13th_Floor", "ShadowDungeon::The13thFloor"),
Expand All @@ -113,10 +92,7 @@ fn main() {
"ShadowDungeon::TimeHonoredSchoolOfMagic",
),
("Shadow_Hemorridor", "ShadowDungeon::Hemorridor"),
(
"Continuous_Loop_of_Idols",
"ShadowDungeon::ContinuousLoopofIdols",
),
("Continuous_Loop_of_Idols", "ShadowDungeon::ContinuousLoopofIdols"),
("Shadow_Nordic", "ShadowDungeon::NordicGods"),
("Shadow_Mount_Olympus", "ShadowDungeon::MountOlympus"),
(
Expand Down Expand Up @@ -355,24 +331,21 @@ fn append_monsters(

code.push_str(" Monster {\n");
let name =
m.name
.as_ref()
.map(|n| n.replace('_', " "))
.unwrap_or_else(|| {
if is_shadow {
format!(
"Shadow {} monster #{}",
enum_variant.split("::").last().unwrap(),
idx
)
} else {
format!(
"{} monster #{}",
enum_variant.split("::").last().unwrap(),
idx
)
}
});
m.name.as_ref().map(|n| n.replace('_', " ")).unwrap_or_else(|| {
if is_shadow {
format!(
"Shadow {} monster #{}",
enum_variant.split("::").last().unwrap(),
idx
)
} else {
format!(
"{} monster #{}",
enum_variant.split("::").last().unwrap(),
idx
)
}
});
code.push_str(&format!(" name: {:?},\n", name));
code.push_str(&format!(" level: {},\n", level));
code.push_str(&format!(" class: {},\n", class_enum));
Expand Down
4 changes: 1 addition & 3 deletions examples/cached_testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ use sf_api::{gamestate::GameState, session::*, sso::SFAccount};

#[tokio::main]
pub async fn main() {
env_logger::builder()
.filter_level(log::LevelFilter::Info)
.init();
env_logger::builder().filter_level(log::LevelFilter::Info).init();

let args = Args::parse();

Expand Down
4 changes: 1 addition & 3 deletions examples/dungeons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,5 @@ pub async fn login_with_env() -> SimpleSession {
let username = std::env::var("USERNAME").unwrap();
let password = std::env::var("PASSWORD").unwrap();
let server = std::env::var("SERVER").unwrap();
SimpleSession::login(&username, &password, &server)
.await
.unwrap()
SimpleSession::login(&username, &password, &server).await.unwrap()
}
8 changes: 2 additions & 6 deletions examples/expedition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ pub async fn main() {
let remaining = time_remaining(busy_until);
if remaining.as_secs() > 60 && gs.tavern.quicksand_glasses > 0 {
println!("Skipping the {}s wait", remaining.as_secs());
Command::ExpeditionSkipWait {
typ: TimeSkip::Glass,
}
Command::ExpeditionSkipWait { typ: TimeSkip::Glass }
} else {
println!(
"Waiting {}s until next expedition step",
Expand All @@ -149,7 +147,5 @@ pub async fn login_with_env() -> SimpleSession {
let username = std::env::var("USERNAME").unwrap();
let password = std::env::var("PASSWORD").unwrap();
let server = std::env::var("SERVER").unwrap();
SimpleSession::login(&username, &password, &server)
.await
.unwrap()
SimpleSession::login(&username, &password, &server).await.unwrap()
}
4 changes: 1 addition & 3 deletions examples/gamble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,5 @@ pub async fn login_with_env() -> SimpleSession {
let username = std::env::var("USERNAME").unwrap();
let password = std::env::var("PASSWORD").unwrap();
let server = std::env::var("SERVER").unwrap();
SimpleSession::login(&username, &password, &server)
.await
.unwrap()
SimpleSession::login(&username, &password, &server).await.unwrap()
}
9 changes: 2 additions & 7 deletions examples/hellevator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ pub async fn main() {
continue;
}
HellevatorStatus::NotEntered => {
session
.send_command(Command::HellevatorEnter)
.await
.unwrap();
session.send_command(Command::HellevatorEnter).await.unwrap();
continue;
}
HellevatorStatus::NotAvailable => {
Expand All @@ -60,7 +57,5 @@ pub async fn login_with_env() -> SimpleSession {
let username = std::env::var("USERNAME").unwrap();
let password = std::env::var("PASSWORD").unwrap();
let server = std::env::var("SERVER").unwrap();
SimpleSession::login(&username, &password, &server)
.await
.unwrap()
SimpleSession::login(&username, &password, &server).await.unwrap()
}
9 changes: 2 additions & 7 deletions examples/questing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,7 @@ pub async fn main() {
continue;
}
},
CurrentAction::Quest {
quest_idx,
busy_until,
} => {
CurrentAction::Quest { quest_idx, busy_until } => {
let remaining = time_remaining(busy_until);
let mut skip = None;

Expand Down Expand Up @@ -161,7 +158,5 @@ pub async fn login_with_env() -> SimpleSession {
let username = std::env::var("USERNAME").unwrap();
let password = std::env::var("PASSWORD").unwrap();
let server = std::env::var("SERVER").unwrap();
SimpleSession::login(&username, &password, &server)
.await
.unwrap()
SimpleSession::login(&username, &password, &server).await.unwrap()
}
4 changes: 1 addition & 3 deletions examples/world_boss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ pub async fn main() -> Result<(), SFError> {
if world_boss.available_daily_chests.values().any(|a| *a > 0) {
// Automatically collect all daily chests, since that is what the
// game also does
session
.send_command(Command::WorldBossCollectDailyChests)
.await?;
session.send_command(Command::WorldBossCollectDailyChests).await?;
continue;
}

Expand Down
Loading
Loading