Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

earthiverse
Copy link
Contributor

Pretty self-explanatory.

Can someone check that the logic ends up being the same?

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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)
Copy link
Contributor Author

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) {
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@ATLUSio ATLUSio left a 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

@Telokis Telokis added Type: enhancement Changes the existing content of the game Scope: game server The game server is impacted Status: waiting for review This PR is waiting for a maintainer to review it labels Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: game server The game server is impacted Status: waiting for review This PR is waiting for a maintainer to review it Type: enhancement Changes the existing content of the game
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants