the-marenga / sf-api

Manage Shakes & Fidget characters via simple commands. Handles encryption, response parsing and everything else for you
MIT License
15 stars 3 forks source link

LIghtdungeon x ShadowDungeon iteration #52

Closed tiquis0290 closed 5 months ago

tiquis0290 commented 5 months ago

I am trying to iterate through dungeons, in light it was easy using strum::IntoEnumIterator and then LightDungeon::iter() but when i look at the shadow dungeon it doesn't has the #[Derive( EnumIter )] so i cannot iter same way. Is there reason why is it different or should i use something different to get similar result?

little note ShadowDungeons are with s at the end but LightDungeon isn't.

the-marenga commented 5 months ago

Yes, you are correct. Seems like I forgot to add that there.

I think this happened because LightDungeon is not continuous (17 is not a valid light dungeon), so I probably had to use enumiter to iterate the dungeons, where as for shadow dungeons I was just using (0..=29) during testing/parsing

I am going to add that derive EnumIter to them. The main branch does however contain a bunch of other new stuff, that I want to test a bit, before publishing a new release, so it might be a few days, before a new version with that fix actually gets out.

Until then, you would just have to do it the old fashioned way

    use sf_api::gamestate::dungeons::ShadowDungeons::*;
    let all = [
        DesecratedCatacombs, MinesOfGloria, RuinsOfGnark, CutthroatGrotto, EmeraldScaleAltar,
        ToxicTree, MagmaStream, FrostBloodTemple, PyramidsOfMadness, BlackSkullFortress,
        CircusOfHorror, Hell, The13thFloor, Easteros, Twister, TimeHonoredSchoolOfMagic,
        Hemorridor, ContinuousLoopofIdols, NordicGods, MountOlympus, TavernOfTheDarkDoppelgangers,
        DragonsHoard, HouseOfHorrors, ThirdLeagueofSuperheroes, DojoOfChildhoodHeroes,
        MonsterGrotto, CityOfIntrigues, SchoolOfMagicExpress, AshMountain, PlayaGamesHQ,
    ];
    for dungeon in all.into_iter() {
        // ...
    }

Yeah, the name is also annoying, but changing that would be a breaking change, which I don't want to do right now

tiquis0290 commented 5 months ago

ok thx, i will wait, and when iam looking in to it it apears that there isnt a command for fighting shadow dungeon but this is probably for new issue

the-marenga commented 5 months ago

when iam looking in to it it apears that there isnt a command for fighting shadow dungeon but this is probably for new issue

Oh, you are right. I am going to add that as well. For the time being, feel free to use this:

fn fight_shadow_dungeon(
    dungeon: ShadowDungeons,
    use_mushroom: bool,
) -> Command {
    Command::Custom {
        cmd_name: "PlayerShadowBattle".to_string(),
        values: vec![
            (dungeon as u32 + 1).to_string(),
            (use_mushroom as u32).to_string(),
        ],
    }
}
tiquis0290 commented 5 months ago

thx man