It is not correct, as simple as it is. Or, perhaps, because it is so simple. Consider this:
Code:
Item plexiglass pith helmet Familiar Weight: +5, HP Regen Min: 10, HP Regen Max: 12, MP Regen Min: 10, MP Regen Max: 12, Muscle Percent: +30, Familiar Effect: "1xVolley, 1xLep, cap 45"
This will grant you +5 to Familiar Weight - probably the most common search in which this will show up.
It will also gain 10-12 HP from adventure. Which is to say. the smallest amount of HP you will gain is 10, and the largest amount of HP you will gain is 12.
Compare to this:
Code:
Effect Blood Bond Familiar Weight: +5, HP Regen Min: -10, HP Regen Max: -8
This will grant you +5 to Familiar Weight - probably the most common search in which this will show up.
It will also lose 8-10 HP from adventure. Which is to say. the smallest amount of HP you will lose is 8, and the largest amount of HP you will lose is 10.
The former is expressed as: HP Regen Max: 12, MP Regen Min: 10
The latter, you coded as: HP Regen Min: -10, HP Regen Max: -8
Why? Because -10 is smaller (as in "more negative") than -8?
Or is it the absolute value of the effect which you really care about?
Or what?
If you maximize for "Familiar Weight" (which is a "use case"), both of the above will show up as "+5". The other effects will not figure in that maximization formula in any way.
If you maximize for "HP Regen", as currently coded, the helment will show up as "+10" and the effect will not show up at all. With your patch, the latter will show up as "-10" (or should it really be "-8"?) and you will autopmatically reject it, since it makes you worse at HP Regen.
This is why I asked you to give me a "use case". If, as you say, "trying to maximize HP regeneration is not uncommon", you are not interested in this effect. Which is to say, that is not actually a "use case".
The reason this patch is an "issue", for me, is that although you correctly point out that this is actually conceptually like HP Regen, you are not supporting it like HP Regen. Instead, you are hardcoding the values. Here is how the HP Regen modifiers are coded:
Code:
{ "HP Regen Min",
null,
Pattern.compile( "HP Regen Min: " + EXPR )
},
{ "HP Regen Max",
null,
Pattern.compile( "HP Regen Max: " + EXPR )
},
Those Patterns are what we parse from modifiers.txt. The nulls are the patterns - or lack thereof - for parsing from the item description. What does Blood Bond say?
Code:
Lose 8-10 HP per Adventure
What dos Modifiers.txt say?
Code:
# Blood Bond: Lose 8-10 HP per Adventure
Effect Blood Bond Familiar Weight: +5
Ah, yes. It was an unsupported "enchantment", so we put it in the comment. How about the pith helmet?
Code:
Regenerate 10-12 HP and MP per adventure
No comment for that, since we parse that "enchantment" and add HP Regen Min and Max.
You removed the comment from Blood Bond. Did you change the code which parses HP Regen to recognize both "Regenerate" and "Lose"? Nope. Instead, you hardcoded the effect in modifiers.txt, as if it were HP Regen.
Here is the pattern used by parseRegeneration:
Code:
private static final Pattern REGEN_PATTERN =
Pattern.compile( "Regenerate (\\d*)-?(\\d*)? ([HM]P)( and .*)? per [aA]dventure$" );
If you want to NOT "hardcode" the effect, you need to adjust that pattern and parseRegeneration to do the "right" thing.
Which is what? Is the HP Regen Min -10 (as you hardcoded it) or -8?
Tell me how YOU, personally, are going to use it. What is YOUR use case?