operator-poe / TujenMem

6 stars 4 forks source link

[Proposed Change] targetOffer multiplier to calculate within bounds of current min and maxOffer #8

Closed Arecurius0 closed 11 months ago

Arecurius0 commented 11 months ago

Currently, the multiplier from the Settings for the targetOffer is calculated based on the Min and MaxOffer of the initial bounds, e.g. 0 artifacts and 500 artifacts. After giving your initial offer of let's say 50% => 250 artifacts, Tujen declines and gives you a new range. Let's say the new range you can haggle in is: min=300 and max= 400. As a user, I expect my multiplier for the 2nd haggle attempt to be applied to the new bounds. Lets assume the multiplier for 2nd haggle attempt is 40%. 40% of the initial bounds is out of range and cant be achieved. However 40% from 300 to 400 would be achievable by the following formula: CurrentMinOffer + (CurrentMaxOffer - CurrentMinOffer)multiplier. In this example: 300 + (400-300)0.4 = 300 + 100*0.4 = 300 + 40 = 340

https://github.com/operator-poe/TujenMem/blob/49f541c3849d808f9d6115dfe0a911ac51dfaa39/HaggleProcessWindow.cs#L409

Doing something like the following does the trick, very small simple change.

            int targetOffer = (int)(minOffer + Math.Ceiling((maxOffer - minOffer) * multiplier));
            while (currentOffer > targetOffer && currentOffer > minOffer)

I have this implemented in my fork of your plugin, but you seem to have a non-standard formatting in your editor which makes commits look incredibly bad cause of the auto-formatting changes from Visual Studio obstructing any code change visibility.

Anyway, you created a very nice Plugin and a good use of the Expedition API, I added to ExileAPI some time ago. Keep going!

operator-poe commented 11 months ago

Thank you for the feedback. This behavior is definitely a bug (I must have messed up converting my AHK stuff somewhere), so I'll be sure to fix that.

About the formatting: Yeah I don't know what that is. I work on Windows with VSCode & CRLF. Is that not the standard for .NET projects? It's my first time touching .NET in like 10 years.

Arecurius0 commented 11 months ago

From just looking at it, my guess is you have set up 2 spaces per tab while standard is 4 I think.

Image