generateChallenges
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
21 posts
• Page 1 of 2 • 1, 2
generateChallenges
by Sloth » 24 Sep 2011, 13:07
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?
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: generateChallenges
by Doublestrike » 26 Sep 2011, 00:15
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.
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.
---
A joke is a very serious thing.
A joke is a very serious thing.
-
Doublestrike - UI Programmer
- Posts: 715
- Joined: 08 Aug 2011, 09:07
- Location: Bali
- Has thanked: 183 times
- Been thanked: 161 times
Re: generateChallenges
by Sloth » 26 Sep 2011, 06:27
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?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.
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: generateChallenges
by Doublestrike » 26 Sep 2011, 07:48
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:
Anyway, looking forward to getting back into it.
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
Anyway, looking forward to getting back into it.
---
A joke is a very serious thing.
A joke is a very serious thing.
-
Doublestrike - UI Programmer
- Posts: 715
- Joined: 08 Aug 2011, 09:07
- Location: Bali
- Has thanked: 183 times
- Been thanked: 161 times
Re: generateChallenges
by Sloth » 26 Sep 2011, 08:24
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.
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.
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: generateChallenges
by Sloth » 26 Sep 2011, 08:45
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:
I will fix this by using the min of maxChallenges and unlockedChallengeIds.size().
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));
}
I will fix this by using the min of maxChallenges and unlockedChallengeIds.size().
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: generateChallenges
by Doublestrike » 26 Sep 2011, 08:53
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.
Thanks for jumping in there while I've been away! Your analysis sounds spot on, I didn't test at that critical condition.

---
A joke is a very serious thing.
A joke is a very serious thing.
-
Doublestrike - UI Programmer
- Posts: 715
- Joined: 08 Aug 2011, 09:07
- Location: Bali
- Has thanked: 183 times
- Been thanked: 161 times
Re: generateChallenges
by Doublestrike » 26 Sep 2011, 08:55
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.
The corresponding JLabel is commented out in the view (I think it's called "QuestChallengePanel", a subclass of "QuestEventPanel") but is ready for action.
---
A joke is a very serious thing.
A joke is a very serious thing.
-
Doublestrike - UI Programmer
- Posts: 715
- Joined: 08 Aug 2011, 09:07
- Location: Bali
- Has thanked: 183 times
- Been thanked: 161 times
Re: generateChallenges
by Sloth » 26 Sep 2011, 09:14
Well, I think it's not so important. But if you want to change it back in, go ahead.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.
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: generateChallenges
by Doublestrike » 26 Sep 2011, 11:25
@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.
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.
---
A joke is a very serious thing.
A joke is a very serious thing.
-
Doublestrike - UI Programmer
- Posts: 715
- Joined: 08 Aug 2011, 09:07
- Location: Bali
- Has thanked: 183 times
- Been thanked: 161 times
Re: generateChallenges
by Sloth » 26 Sep 2011, 13:12
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?
EDIT: Or did I get it wrong and all challenges are repeatable?
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: generateChallenges
by friarsol » 26 Sep 2011, 14:22
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.Sloth wrote:EDIT: Or did I get it wrong and all challenges are repeatable?
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: generateChallenges
by lazylockie » 26 Sep 2011, 17:01
I suppose then if I "skip" the 10th victory it's going to be fine? I'm gonna try it now with Cheat Engine.
- lazylockie
- Posts: 508
- Joined: 13 Jul 2010, 22:44
- Has thanked: 74 times
- Been thanked: 15 times
Re: generateChallenges
by Sloth » 26 Sep 2011, 18:11
You have to skip to 20 wins I think.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.
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: generateChallenges
by Doublestrike » 27 Sep 2011, 00:08
Yes, this is why I left it out (temporarily). I think the problem was that there weren't enough challenges to make this feasible.friarsol wrote:If the new Challenge code is like the old Challenge code, repeatable didn't actually mean anything.
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.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.
---
A joke is a very serious thing.
A joke is a very serious thing.
-
Doublestrike - UI Programmer
- Posts: 715
- Joined: 08 Aug 2011, 09:07
- Location: Bali
- Has thanked: 183 times
- Been thanked: 161 times
21 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 44 guests