ensingm2/saliengame_idler

[Feature] Auto-select best planet available (toggable)

Harest opened this issue · 12 comments

  • Implementing the functions required.
  • Fixing CORS issue when fetching the 5 active planets. Maybe delaying the requests could work. In the meantime, we tried to prevent any issue related to these empty responses. And the feature is disabled by default. Edit : Seems like Valve fixed their issue here.

At first i thought i'd prefer to choose my planet for the games but the odds are pretty low anyway so i'd rather focus on the XP. We'd still set this as a toggable option so anyone that want to stay on a specific planet can.

The url to fetch planets info is this one : https://community.steam-api.com/ITerritoryControlMinigameService/GetPlanets/v0001/
It could be used alongside GetPlanet to search for the planet with the most high risk zones, medium risk if they're all at 0 high risk and low risk if both high & medium are at 0 everywhere.
It'd be triggered if our current zone has ended and GetBestZone() returns a difficulty zone below the previous one, or if the planet is completed.

Dunno if anyone want to do this, otherwise i'll probably* as i find this could be a good idea. Even if i think if lvl 12 isn't the lvl to get rank 6 badge, it'll not be far after.
*Later today aka somewhere after 2018-06-23 13:00 GMT. So if you want to do it before, enjoy :p.

I don't know how to do this but definitely would want this feature!

something like

foreach active planet
	foreach noncaptured zone
		if difficulty == 3
			planetscore += 10000
		if difficulty == 2
			planetscore += 100
		if difficulty == 1
			planetscore += 1

with 96 zones on each planet, this means the final planet score would reflect that any hard zones would have priority over a planet with all medium zones and so on.

Actually, since switching planets would mean almost no extra work, we don't need to find the "best" planet. Just any planet that still has Hard zones. Failing that, any Medium zone. Failing that, any zone.

We could just run the planet switcher between every game, just like the zone switcher.

@Zazcallabah : I thought the same thing as your solution (planet score based).
And about when to run it, i indeed thought to run it when we switch the zone because it has ended, but i think we may want to also do a check every now and then if we're in a difficulty inferior to 3. Like every 10 minutes for instance.
If nobody started on it, i'll in 20/30 minutes.

Just finished, testing my script and i'll do a pull request soon.

I've issues with CORS strangely. When i request info on the different planets it just returns info on the current one and all the others are blocked atm.

Merged in as a disabled-by-default, console-toggleable only feature.

Calling CheckSwitchBetterPlanet() to run once or setting auto_switch_planet=true(E: see below) should enable this.

Leaving disabled by default until CORS issues are sorted though.

^ This. Except to enable it, it's auto_switch_planet.active = true (you can also modify it at the start of the script after you pasted it).
Atm, i'd recommend enabling this only if you'll be afk for a long period of time.
Also, if you're calling CheckSwitchBetterPlanet(), use this call CheckSwitchBetterPlanet(true). Otherwise you'll not be able to go back to the same area than before and if it's the best one, you'll be locked.

HOPEFULLY with the AJAX handling, we should be able to avoid this at least a bit better. I'm going to manually enable planet switching and let this run for a bit. If it seems to work fine, and I can trigger a handled CORS error, I'll probably enable it by default, add a toggle button to the gui, and close out this issue.

Oops, leaving this open unti lthat point, though.

As i said in the latest messages. It seems they fixed the CORS issues. Dunno about you ? I didn't get any in a while now, and the 10+ last calls to check for a better planet didn't trigger any CORS error. It never happened before.

I'm not getting any either currently. I wouldn't be surprised if it's linked to a misconfigured failover/load-distribution server or something, so only comes up at peak usage times.