-
Notifications
You must be signed in to change notification settings - Fork 383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
raidboss: Lunar Subterrane--Add Ruinous Hex calls #5944
raidboss: Lunar Subterrane--Add Ruinous Hex calls #5944
Conversation
@JLGarber Thanks for your contribution! 🌵🚀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would probably be a lot simpler with matrix math, but I don't know matrices enough to implement them here, so this is what we get instead. It should be largely self-explanatory with the in-line comments, but please criticize away, since this isn't necessarily the nicest implementation.
I don't know what you mean by matrix math.
I think my only concern here is that this seems a little fragile to make assumptions about safe spot based on patterns, but if you feel convinced from your data, then I'm fine to merge it.
If you wanted an optional alternate implementation suggestion, then I'd suggest something like this approach:
let safeX = [0, 1, 2, 3];
let safeY = [0, 1, 2, 3];
for (const staff of staffs) {
// map staff positions into 0-3 row/col coordinates
const col = Math.round((staff.x - centerX) / something + something);
const row = Math.round((staff.y - centerY) / something + something);
safeX = safeX.filter((x) => x !== col);
safeY = safeY.filter((y) => y !== row);
}
const [finalX] = safeX;
const [finalY] = safeY;
if (finalX == undefined || finalY === undefined || safeX.length !== 1 || safeY.length !== 1)
return;
// use safeX and safe Y to return a square
Okay, thank you, that's a much better approach. I know the implementation I'm using here involves comparisons against numeric positions, but I think it's safe enough given that we know these positions are accurate, and that we're rounding everything. This worked perfectly in testing, and it should handle any possible staff setup regardless of whether we have seen it before. |
Thanks! Looks good to me! |
This would probably be a lot simpler with matrix math, but I don't know matrices enough to implement them here, so this is what we get instead. It should be largely self-explanatory with the in-line comments, but please criticize away, since this isn't necessarily the nicest implementation.