iagd icon indicating copy to clipboard operation
iagd copied to clipboard

Suffix isn't fix! I'm really sorry!

Open misternobousi opened this issue 1 year ago • 2 comments

I'm really sorry! The code I just wrote didn't fix it! The fix was probably a bug, just a coincidence! (I hit the language switch button too many times.) The Replace had to be placed right after the foreach. It gets sucked up by the if above. Anyway, \r should not be mixed in, so please create a local variable and Replace!

Originally posted by @misternobousi in https://github.com/marius00/iagd/issues/141#issuecomment-2002333799

misternobousi avatar Mar 17 '24 06:03 misternobousi

I'm not really sure what you mean here..

marius00 avatar May 24 '24 17:05 marius00

It's a very dirty code and I don't want you to imitate it, but this is what I mean.

        foreach (var entry in entries) {
            int fixIndex;
            // NaN specifies this is a gender based entry
            if (entry.Replace("\r", "").Length == 3 && char.IsDigit(entry[0])) {
                int genderIndex;
                if (int.TryParse(entry.Substring(0, 1), out genderIndex)) {
                    var genderTag = DetermineGender(fixes[genderIndex]);

                    if (int.TryParse(entry.Substring(2, 1), out fixIndex)) {
                        itemName[pos] = GetGendered(fixes[fixIndex], genderTag);
                    }
                }

                pos++;
            }
            // 'sN'
            else if (entry.Replace("\r", "").Length == 2) {
                if (int.TryParse(entry.Replace("s", "").Replace("\r", ""), out fixIndex)) {
                    itemName[pos] = FilterGenderTag(fixes[fixIndex]);
                }

                pos++;
            }
        }

misternobousi avatar May 24 '24 22:05 misternobousi