It is currently 14 Aug 2025, 05:39
   
Text Size

generateChallenges

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

generateChallenges

Postby 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?
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: generateChallenges

Postby 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.
---
A joke is a very serious thing.
User avatar
Doublestrike
UI Programmer
 
Posts: 715
Joined: 08 Aug 2011, 09:07
Location: Bali
Has thanked: 183 times
Been thanked: 161 times

Re: generateChallenges

Postby Sloth » 26 Sep 2011, 06:27

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?
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: generateChallenges

Postby 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:

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.
---
A joke is a very serious thing.
User avatar
Doublestrike
UI Programmer
 
Posts: 715
Joined: 08 Aug 2011, 09:07
Location: Bali
Has thanked: 183 times
Been thanked: 161 times

Re: generateChallenges

Postby 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.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: generateChallenges

Postby 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:
| 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().
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: generateChallenges

Postby 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. :(
---
A joke is a very serious thing.
User avatar
Doublestrike
UI Programmer
 
Posts: 715
Joined: 08 Aug 2011, 09:07
Location: Bali
Has thanked: 183 times
Been thanked: 161 times

Re: generateChallenges

Postby 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.
---
A joke is a very serious thing.
User avatar
Doublestrike
UI Programmer
 
Posts: 715
Joined: 08 Aug 2011, 09:07
Location: Bali
Has thanked: 183 times
Been thanked: 161 times

Re: generateChallenges

Postby Sloth » 26 Sep 2011, 09:14

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.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: generateChallenges

Postby 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.
---
A joke is a very serious thing.
User avatar
Doublestrike
UI Programmer
 
Posts: 715
Joined: 08 Aug 2011, 09:07
Location: Bali
Has thanked: 183 times
Been thanked: 161 times

Re: generateChallenges

Postby 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?
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: generateChallenges

Postby friarsol » 26 Sep 2011, 14:22

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.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: generateChallenges

Postby 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

Postby Sloth » 26 Sep 2011, 18:11

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.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: generateChallenges

Postby Doublestrike » 27 Sep 2011, 00:08

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.
---
A joke is a very serious thing.
User avatar
Doublestrike
UI Programmer
 
Posts: 715
Joined: 08 Aug 2011, 09:07
Location: Bali
Has thanked: 183 times
Been thanked: 161 times

Next

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 44 guests

cron

Main Menu

User Menu

Our Partners


Who is online

In total there are 44 users online :: 0 registered, 0 hidden and 44 guests (based on users active over the past 10 minutes)
Most users ever online was 7303 on 15 Jul 2025, 20:46

Users browsing this forum: No registered users and 44 guests

Login Form