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

Adding a change to limit how often users are prompted about strange fruits #19

Merged
merged 2 commits into from
Oct 25, 2023

Conversation

Profesor-Caos
Copy link
Contributor

When a strange fruit spawns, we would check a few more things now before notifying the user

  • Have we been logged in longer than 5 minutes?
  • Has it an hour since we got a random event?
  • Are we within 15 seconds of an event window (the 5 minute intervals)?

The 3rd one will probably prevent the most unnecessary notifications from being seen by the user (especially at shooting stars where there are tons of events happening)

@Profesor-Caos
Copy link
Contributor Author

@zmanowar Tagging you in case you don't get a notification for this.

@Profesor-Caos
Copy link
Contributor Author

Also, the window being within 15 seconds of the 5 minute intervals is based on your thread for issue 3. If time since login was logged in the log files, it would be possible to narrow this down, because I think the window is probably smaller than that.


The minimum of 1 hour between random events is based on the wiki, which is based on a Mod Ash reply to a tweet where he said the time between randoms is "about 1-2 hours". I think with enough data in log files, the actual minimum could be determined.

I don't have a lot of events logged on my computer, and the shortest is invalid data, because it's the first one. It essentially gives the time since logging instead of the time since the previous random since there was no previous random.

Copy link
Owner

@zmanowar zmanowar left a comment

Choose a reason for hiding this comment

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

Also, the window being within 15 seconds of the 5 minute intervals [...]

I think, technically, it can be delayed by any Make-X action, though I'm not sure what the longest Make-X action is...

From the Wiki:

It is possible to briefly stall an event spawn if the player has an interface open or is in the middle of a repeated skilling action (through the "Make-X" option) when they are awarded an event, in which case its spawn will be delayed until the player becomes available again

I'm good with 15 seconds for now though!


Excellent work!

I'm good to merge, but it's worth having a conversation about first-time-randoms as this may prevent a user from logging a random if they're using the plugin for the first time, or on a new computer, etc.

return false;
}

int secondsInAnHour = 60 /*seconds in a minute*/ * 60 /*minutes in an hour*/;
Copy link
Owner

Choose a reason for hiding this comment

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

Nit: secondsInAnHour May make more sense as a static constant.

@@ -100,6 +101,26 @@ public int getNextRandomEventEstimation()
return SPAWN_INTERVAL_SECONDS - secondsMod;
}

public boolean isPossibleTimeForRandomEvent()
{
if (!hasLoggedInLongEnoughForSpawn())
Copy link
Owner

Choose a reason for hiding this comment

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

What are your thoughts about checking if there is a previously logged random here as well, as part of a solve for:

[...] the shortest is invalid data, because it's the first one. It essentially gives the time since logging instead of the time since the previous random since there was no previous random.

eg

private boolean isEligibleForRandom() { // TODO: Better method name, and maybe closure/lambda in isPossibleTimeForRandomEvent
  int loginTime = getSecondsSinceLogin();
  int secondsMod = loginTime % SPAWN_INTERVAL_SECONDS;
  // If we're within 15 seconds of an event window, it's considered a possible time.
  return secondsMod <= SPAWN_INTERVAL_TIMEFRAME_SECONDS || secondsMod >= SPAWN_INTERVAL_SECONDS - SPAWN_INTERVAL_TIMEFRAME_SECONDS;
}

public boolean isPossibleTimeForRandomEvent() {
  if (this.lastRandomSpawnInstant == null) { // This should determine if there's a previous random.
    return this.isEligibleForRandom();
  }
  // ...
  // your existing checks here
  return this.isEligibleForRandom();
}

Though I may be getting too edge-casey; there are probably other existing facets of this class that do not properly account for first time events. 😓

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that is an issue with this, so I say good catch.

I think isEligibleForRandom sounds like it would check if enough time has passed since the last random. I think it should be isInsideRandomEventWindow or something like that

@Profesor-Caos
Copy link
Contributor Author

I think, technically, it can be delayed by any Make-X action, though I'm not sure what the longest Make-X action is...

From the Wiki:

It is possible to briefly stall an event spawn if the player has an interface open or is in the middle of a repeated skilling action (through the "Make-X" option) when they are awarded an event, in which case its spawn will be delayed until the player becomes available again

I think that might just prevent getting the random, like you get it on the next 5 minute interval. I remember some snowflake iron's video where they were training cooking by churning cheese which is a super long make-X action, and they were just basically always in make-X actions and got very few randoms.

Actually I found it. This video at the linked time has like a 30 second bit about it. They tweeted mod ash about it, which is the source of that bit on the wiki.

@zmanowar
Copy link
Owner

Great find!

@Profesor-Caos
Copy link
Contributor Author

@zmanowar
I made changes based on your comments if you want to have a look and get it merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants