fix: prevent panic on negative count input strings.Repeat() fixes #7
On pawn promotion e.g. g8=Q, function pkg/util.getCapturedPieces() calculates an incorrect negative count of the promoted piece e.g. Q=-1. Using this negative count as subsequent input will cause strings.Repeat() to panic.
Add a func nonNegative() which returns an int value not less than zero and wrap the calculations of captured pieces to ensure valid input to strings.Repeat().
Acknowledging receipt of your PR. Thanks! I will take a look soon and get this merged assuming that everything looks good.
Pushed a small change to eliminate the else branch in nonNegative(int). If you have any changes you would prefer, e.g. a different name for nonNegative(int), I'm happy to make those adjustments before review.
Thanks, I know it's taking some time to get this merged, but I'm looking over the codebase as a whole, and I want to add better documentation and testing, so that's slowing down the next release. Truthfully, I need to review the logic on captured pieces fully and make sure I have that documented. Anyway, I appreciate the contribution, and rest assured, I will get the fix applied sometime soon.
@tmountain not trying to be annoying, but I just found out about uchess and it looks exactly what I want:
- CLI
- Written in a compiled language
- Nice, easy config
- Only important features no feature "creep"
So I am just asking openly here:
Is this something I should package now (for Void Linux) or should I wait for your refactor/update?
Thanks and have a good one!
Hi, you're not annoying me. I know it's taken forever for me to push an update. The project is still active, and I will do my best to package up a new release soon. I apologize for the delay, and I'll do my best to get something out the door within a week or two.