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

326 ordering bug #364

Merged
merged 2 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,32 +113,36 @@ public class ChallengesManager
* This comparator orders challenges by their level, order and name.
*/
private final Comparator<Challenge> challengeComparator = (o1, o2) -> {
// Get the levels
ChallengeLevel o1Level = this.getLevel(o1.getLevel());
ChallengeLevel o2Level = this.getLevel(o2.getLevel());

if (o1Level == null && o2Level == null)
{
// Handle null levels consistently
if (o1Level == null && o2Level == null) {
// Both levels are null, compare by order
return Integer.compare(o1.getOrder(), o2.getOrder());
}
else if (o1Level == null)
{
} else if (o1Level == null) {
// If o1 level is null, it should be ordered lower
return -1;
}
else if (o2Level == null)
{
} else if (o2Level == null) {
// If o2 level is null, it should be ordered lower
return 1;
}
else if (o1Level.equals(o2Level))
{

// If both levels are non-null, compare their orders
int levelComparison = Integer.compare(o1Level.getOrder(), o2Level.getOrder());

// If levels are the same, compare by challenge order
if (levelComparison == 0) {
return Integer.compare(o1.getOrder(), o2.getOrder());
}
else
{
return Integer.compare(o1Level.getOrder(), o2Level.getOrder());
}

// Return the level comparison result
return levelComparison;
};



// ---------------------------------------------------------------------
// Section: Constructor
// ---------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ public String getPromptText(@NotNull ConversationContext conversationContext)
withFirstPrompt(confirmationPrompt).
withLocalEcho(false).
withTimeout(90).
// Use null value in consumer to detect if user has abandoned conversation.
addConversationAbandonedListener(ConversationUtils.getAbandonListener(consumer, user))
.
buildConversation(user.getPlayer()).
begin();
}
Expand Down
Loading