dhusemann / idlecombos

55 stars 17 forks source link

Mismatched core to instance in adventure list+ Core XP/level calculation performance #24

Open Fmagdi opened 2 years ago

Fmagdi commented 2 years ago

Depending on core assignments, the Adventures tab often shows the wrong core to adventure assignment. This is due to the info being assigned to the adventures by two separate loops, one for instances and the other for cores, without using the instance id to link progression in both loops.

I modified the function to solve the issue, as well as replace the loop-based calculation of core level/experience with their mathematical direct equivalent which is more efficient at high levels. I also changed the display of the total core XP to use suffixes (K, M, etc) to better suit high levels.

ParseAdventureData() {

    InstanceList := [{},{},{},{}]
    CoreList := ["Modest","Strong","Fast","Magic"]
    MagList := ["K","M","B","t"]

    for k, v in UserDetails.details.game_instances {
        InstanceList[v.game_instance_id].current_adventure_id := v.current_adventure_id
        InstanceList[v.game_instance_id].current_area := v.current_area
        InstanceList[v.game_instance_id].Patron := PatronFromID(v.current_patron_id)
    }
    for k, v in UserDetails.details.modron_saves {
        InstanceList[v.instance_id].core := "Core: " Corelist[v.core_id]
        if (v.properties.toggle_preferences.reset == true)
            InstanceList[v.instance_id].core := InstanceList[v.instance_id].core " (Reset at " v.area_goal ")"
        core_level := ceil((sqrt(36000000+8000*v.exp_total)-6000)/4000)
        core_tolevel := v.exp_total-(2000*(core_level-1)**2+6000*(core_level-1))
        core_levelxp := 4000*(core_level+1)
        core_pcttolevel := Floor((core_tolevel / core_levelxp) * 100)

        core_humxp := Format("{:.2f}",v.exp_total / (1000 ** Floor(log(v.exp_total)/3))) MagList[Floor(log(v.exp_total)/3)]
        if (core_level > 15) 
            core_level := core_level " - Max 15"
        InstanceList[v.instance_id].core := InstanceList[v.instance_id].core "`nXP: " core_humxp " (Lv " core_level ")`n" core_tolevel "/" core_levelxp " (" core_pcttolevel "%)"
    }

    bginstance := 0
    FGCore := "`n"
    BGCore := "`n"
    BG2Core := "`n"
    BG3Core := "`n"

    for k, v in InstanceList {
        if (k == ActiveInstance) {
            CurrentAdventure := v.current_adventure_id
            CurrentArea := v.current_area
            CurrentPatron := v.Patron
            FGCore := v.core
        }
        else if (bginstance == 0){
            BackgroundAdventure := v.current_adventure_id
            BackgroundArea := v.current_area
            BackgroundPatron := v.Patron
            BGCore := v.core
            bginstance += 1
        }
        else if (bginstance == 1){
            Background2Adventure := v.current_adventure_id
            Background2Area := v.current_area
            Background2Patron := v.Patron
            BG2Core := v.core
            bginstance += 1
        }
        else if (bginstance == 2){
            Background3Adventure := v.current_adventure_id
            Background3Area := v.current_area
            Background3Patron := v.Patron
            BG3Core := v.core
        }
    }
}
djravine commented 2 years ago

I have updated my build with your more efficient processing code. My version also includes the number of champions on each adventure.

https://github.com/djravine/idlecombos/blob/26148a77729f5b27575820aefe2c9dd31a44b4bf/IdleCombos.ahk#L1850

2022-08-22 09 02 22