Zorn192 / AutoTrimps

AutoTrimps - Zek
GNU General Public License v3.0
58 stars 102 forks source link

C2 Runner gets stuck if challenge is not unlocked #95

Closed OrenAudeles closed 4 years ago

OrenAudeles commented 4 years ago

Possible relation to #61

Problem Description

When using C2 Runner with HZE 175 got stuck attempting to run the Watch C2 which is not unlocked yet. Watch unlocks at Z180. Will probably get stuck again for any other C2 where the challenge is unlocked at a higher than HZE zone.

Possible solution

Add check that the challenge is unlocked using a mapping between the Challenge name and its unlock zone. Eg. "Watch" : 180, "Lead" : 180.

EG: https://github.com/Zorn192/AutoTrimps/blob/1bfc70c6835b271c7981fa5b5eac870d89efb561/modules/portal.js#L152-L156

to

if( challenge_unlocked( "Size" ) && should_run_c2( game.c2.Size ) ) {
   [...]
}

where challenge_unlocked is along the lines of

function challenge_unlocked( challenge_name ) {
    return ( game.global.highestLevelCleared+1 ) >= challenge_unlock_zones[ challenge_name ];
}

and should_run_c2 the current condition, split off to its own function for readability purposes

function should_run_c2( c2_val ) {
    return (100*( c2_val /(game.global.highestLevelCleared+1))) < getPageSetting('c2runnerpercent')
}
OrenAudeles commented 4 years ago

My current workaround, as I don't have Watch or Lead unlocked, is to add false && at the start of their conditions.

if( false && 
    (100*(game.c2.<challenge>/(game.global.highestLevelCleared+1))) < getPageSetting('c2runnerpercent') ) {
[...]
}
Zorn192 commented 4 years ago

I added a check if challenge is completed

OrenAudeles commented 4 years ago

Awesome, thanks for the fast resolution :D