Page 1 of 2

generateChallenges

PostPosted: 24 Sep 2011, 13:07
by Sloth
There were some bug reports on the forum and in the mantis tracker about this function in QuestEventManager. I can see what's going wrong here, but I'm not really sure what this function is supposed to do. Can you explain a little bit DoubleStrike?

Re: generateChallenges

PostPosted: 26 Sep 2011, 00:15
by Doublestrike
Hi everyone, had some real-life stuff to do. Was playing quest and found some bugs so now I'm back here to fix.

Unfortunately I'm at work right now (again) so I'll check this evening and get back to fixing these bugs.

@Sloth - For a knee-jerk response, from what I remember, QuestEventManager generates any "event" (such as duels and challenges) which are used by the current view for display. But I'll check later tonight and fix everything that comes up. My schedule is clear again so I can work this code all week.

Will get back to you soon.

Re: generateChallenges

PostPosted: 26 Sep 2011, 06:27
by Sloth
Doublestrike wrote:@Sloth - For a knee-jerk response, from what I remember, QuestEventManager generates any "event" (such as duels and challenges) which are used by the current view for display. But I'll check later tonight and fix everything that comes up. My schedule is clear again so I can work this code all week.

Will get back to you soon.
I can see that it generates a List<QuestChallenge> and I assume that it returns all available challenges for the player. There seems to be a maxChallenges (that is capped at 5) and some randomness involved. Can you explain how it makes the choice?

Re: generateChallenges

PostPosted: 26 Sep 2011, 07:48
by Doublestrike
That code was slightly adapted from the previous version, it now allows allow 2 challenges to be shown for 20 wins.

Still at my job now but if I remember, that code should display x challenges for y wins:

Code: Select all
Wins     Challenges Available
=====    ====================
20 - 29  2
30 - 39  3
40 - 49  4
>= 50    5
I don't recall any randomness...my curiousity is piqued now. What seems to be the problem? The immediate one I'm setting out to fix is at the end of an event, for some wins, the win count is rolled over somehow and the next match is assumed won.

Anyway, looking forward to getting back into it.

Re: generateChallenges

PostPosted: 26 Sep 2011, 08:24
by Sloth
To my understanding of the quest mode there should be two variables for challenges:

1. The number of challenges available (an integer). This is what you describe.

2. A list of available challenges to chose from (those that are both unlocked and not finished or repeatable).

I thought generateChallenges would manage 2, but I would have imagined it to be much simpler.

Re: generateChallenges

PostPosted: 26 Sep 2011, 08:45
by Sloth
Ok, I think I finally understand what this function does:

From the list of challenges that should be available (variable 2) this function choses a fixed number (maxChallenges = questData.getWin() / 10 capped at 5) of challenges at random, saves the chosen list and returns a copy of it.
Whenever a match is finished the data is cleared and generateChallenges generates a new list.

The problem is this part:
| Open
Code: Select all
            for (int i = 0; i < maxChallenges; i++) {
                availableChallengeIds.add(unlockedChallengeIds.get(i));
            }
If the player has 10 wins maxChallenges will become 1, but the first quests start at 20, so unlockedChallengeIds is empty. The game crashes.

I will fix this by using the min of maxChallenges and unlockedChallengeIds.size().

Re: generateChallenges

PostPosted: 26 Sep 2011, 08:53
by Doublestrike
Yep exactly. generateDuels does a similar operation.

Thanks for jumping in there while I've been away! Your analysis sounds spot on, I didn't test at that critical condition. :(

Re: generateChallenges

PostPosted: 26 Sep 2011, 08:55
by Doublestrike
Incidentally, it looked like the "repeatable" condition was largely ignored in the previous code, since perhaps there weren't enough quests in general to meet the demand.

The corresponding JLabel is commented out in the view (I think it's called "QuestChallengePanel", a subclass of "QuestEventPanel") but is ready for action.

Re: generateChallenges

PostPosted: 26 Sep 2011, 09:14
by Sloth
Doublestrike wrote:Incidentally, it looked like the "repeatable" condition was largely ignored in the previous code, since perhaps there weren't enough quests in general to meet the demand.

The corresponding JLabel is commented out in the view (I think it's called "QuestChallengePanel", a subclass of "QuestEventPanel") but is ready for action.
Well, I think it's not so important. But if you want to change it back in, go ahead.

Re: generateChallenges

PostPosted: 26 Sep 2011, 11:25
by Doublestrike
@Sloth - had a look at the generateChallenges method, and with your latest tweaks it doesn't look too bad in terms of complexity.

About repeatability, my view on that was that it could be a good thing to have later. So, I reckon it'll stay commented out until someone needs it.

With my work on splitting up the model/view, it's pretty easy now to add custom bits and bobs to the event panels, since they're just subclasses of QuestSelectablePanel.

IMHO, QuestSelectablePanel should actually be just SelectablePanel, and moved into the main forge GUI area as a part of the view "toolbox". Surely there's lots of places (potentially) where a selectable panel could be useful. So, it's there if people need it, and pretty easy to change.

Re: generateChallenges

PostPosted: 26 Sep 2011, 13:12
by Sloth
I thought about it again and if it is no hard task, it would be a good idea to enable repeatable challenges again, so the long time questers will never run out of challenges.

EDIT: Or did I get it wrong and all challenges are repeatable?

Re: generateChallenges

PostPosted: 26 Sep 2011, 14:22
by friarsol
Sloth wrote:EDIT: Or did I get it wrong and all challenges are repeatable?
If the new Challenge code is like the old Challenge code, repeatable didn't actually mean anything. I could play a non-repeatable quest (like the sheep wolf one) and then a few games later have it available again.

Re: generateChallenges

PostPosted: 26 Sep 2011, 17:01
by lazylockie
I suppose then if I "skip" the 10th victory it's going to be fine? I'm gonna try it now with Cheat Engine.

Re: generateChallenges

PostPosted: 26 Sep 2011, 18:11
by Sloth
lazylockie wrote:I suppose then if I "skip" the 10th victory it's going to be fine? I'm gonna try it now with Cheat Engine.
You have to skip to 20 wins I think.

Re: generateChallenges

PostPosted: 27 Sep 2011, 00:08
by Doublestrike
friarsol wrote:If the new Challenge code is like the old Challenge code, repeatable didn't actually mean anything.
Yes, this is why I left it out (temporarily). I think the problem was that there weren't enough challenges to make this feasible.

Sloth wrote:I thought about it again and if it is no hard task, it would be a good idea to enable repeatable challenges again, so the long time questers will never run out of challenges.
Yep, I'll do that then, no worries. We'll need some more quest decks, I think, but since everyone can make them now fairly easily, there should be some more coming in anyway.