-
Notifications
You must be signed in to change notification settings - Fork 68
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
simplify and clarify calculate_monster_score calculations #151
base: main
Are you sure you want to change the base?
Conversation
node/server.js
Outdated
if (isMerchant && simple_distance(p, player) <= 600) { | ||
// Nearby merchants reduce the points | ||
if (sameOwner) { | ||
score -= 0.2 / divisor; // -Deduct points if our merchant is nearby |
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.
Old line 2315
if (sameOwner) { | ||
score -= 0.2 / divisor; // -Deduct points if our merchant is nearby | ||
} else { | ||
score -= 0.1 / divisor; // Deduct points if a merchant in our party is nearby |
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.
Old line 2323
|
||
const isMerchant = p.type === "merchant"; | ||
if (sameOwner && sameParty && !isMerchant) { | ||
score += 0.3 / divisor; // +0.3 points for each additional non-merchant character of ours in our party (even if they are far away) |
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.
Old lines 2330 & 2337
|
||
for (const id in players) { | ||
const p = players[id]; | ||
if (p.id === player.id) { |
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.
Could skip the get call on id
of p and just use id
directly given by the for loop
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.
It might be a different ID?
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.
The proposed changes are simpler to read and appear to be logically the same. As far as I can tell, the code will produce the same outputs as the original one; however, I think it'll also be marginally more performant, too. So cleaner, leaner, and the same outputs
Pretty self-explanatory.
Can someone check that the logic ends up being the same?