It is currently 16 Apr 2024, 11:13
   
Text Size

Foil rarity fix patch (completed)

Post MTG Forge Related Programming Questions Here

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

Re: Foil rarity fix patch (completed)

Postby Seravy » 17 Jul 2017, 19:28

1. I have no idea how to check for the game mode. Is there a function I can call for that?
...considering how OOP works, I bet the answer is "none, you have to make a new class that is used in quest mode and only add the filters in that one". Am I right?
Unless...I change the constructor to require the parameter of where it was created...yay, having to modify another dozen file :(
2. Done, took 5 seconds. We already discussed it can be done by copying the 5 lines to the other menu procedure.
3. Agreed, how did I overlook that. I guess I was too busy making sure you can read the "2" and "3", white didn't work well for those :D
...ehh making the edge of the star white made it look even worse. No way around it, I have to make that edge thicker. Nah, still ugly, I guess it needs to be a white star with a black "1" on it instead.
Seravy
 
Posts: 363
Joined: 26 Oct 2016, 21:23
Has thanked: 5 times
Been thanked: 27 times

Re: Foil rarity fix patch (completed)

Postby Seravy » 17 Jul 2017, 20:54

Success!

Here you go, everything as requested (even formatted those two new lines I had to add)
Attachments
sprite_favicons.png
sprite_favicons.png (8.71 KiB) Viewed 4412 times
RatingFilter4.txt
(30.29 KiB) Downloaded 219 times
Seravy
 
Posts: 363
Joined: 26 Oct 2016, 21:23
Has thanked: 5 times
Been thanked: 27 times

Re: Foil rarity fix patch (completed)

Postby Agetian » 18 Jul 2017, 02:52

Thanks for your effort!
Can you please apply your changes to my reformatted version of the code instead of your original one? I spent a couple hours reformatting and tweaking the code yesterday, I don't exactly feel like doing it all over again with my previous effort thrown out the window... Or please mark the exact changes you've made such that I can add them to my version of the code. ;)

- Agetian
Agetian
Programmer
 
Posts: 3471
Joined: 14 Mar 2011, 05:58
Has thanked: 676 times
Been thanked: 561 times

Re: Foil rarity fix patch (completed)

Postby Seravy » 18 Jul 2017, 07:54

...great, did I use the wrong file?
...I hate patches. There are like 5 versions of files named "ratingfilter" in my patch folder now.
Done...
Attachments
RatingFilter5.txt
(31.71 KiB) Downloaded 223 times
Seravy
 
Posts: 363
Joined: 26 Oct 2016, 21:23
Has thanked: 5 times
Been thanked: 27 times

Re: Foil rarity fix patch (completed)

Postby Agetian » 18 Jul 2017, 08:13

Nice, thanks! I'll take a look once I'm back home later today. ;)

- Agetian
Agetian
Programmer
 
Posts: 3471
Joined: 14 Mar 2011, 05:58
Has thanked: 676 times
Been thanked: 561 times

Re: Foil rarity fix patch (completed)

Postby Agetian » 18 Jul 2017, 09:01

While I'm looking at the star rating patch, I think I identified an issue with the previous submission (foil rarity patch) - for me, Booster Draft mode appears to be broken for some reason. Try making a new draft (for example, Avacyn Restored) and going through the first pack. After the first pack is exhausted, the game will hard-crash, and you will not be able to proceed to the next pack. Can you please take a look at what's causing it? (sometimes it'll also crash mid-pack, but more rarely; conversely, sometimes it won't crash when switching to the next pack, but also very rarely). If you look at how the cards in the pack are removed, they no longer go from 15 to 14 to 13 to 12 etc. down to 1, instead, they sometimes jump over or stay on the same value for whatever weird reason (15->13->12->11->11->11->9->8->6...). This might be a part of the problem.

EDIT: I think I fixed it, was caused by a line you introduced which only reduced the number of cards generated in pack for the old style boosters (why would you do that?). I reverted that to always decreasing the number of cards generated by 1 whenever a foil is generated and it now appears to work correctly, tested on an old set (7th Edition) and a newer set (Avacyn Restored). If there was some kind of reasoning behind your change, please make sure you retest everything to ensure that all sets, old and new, work correctly and do not crash.

- Agetian
Last edited by Agetian on 18 Jul 2017, 09:48, edited 1 time in total.
Agetian
Programmer
 
Posts: 3471
Joined: 14 Mar 2011, 05:58
Has thanked: 676 times
Been thanked: 561 times

Re: Foil rarity fix patch (completed)

Postby Seravy » 18 Jul 2017, 10:00

If you mean the part I think you do, it's this :
There are two kinds of packs "foil at end" and "normal".
For normal packs, generating a foil card in X rarity means 1 fewer of that rarity has to be generated.
For "end of pack" foils, that isn't true - you still generate the same amount of that rarity. Instead, you need to reduce the commons by one, which the code already did....except, now that I look at it again, it did not. The part
Code: Select all
 if (replaceCommon && slotType.startsWith(BoosterSlots.COMMON)) {
                numCards--;
Does not seem to refer to the foils, "replaceCommon" is not the same variable as "foilAtEndofPacks".
There should be
Code: Select all
if (foilAtEndofPack && hasfoil && slotType.startsWith(BoosterSlots.COMMON)) {
                numCards--; }
there in addition.

If you don't do it this way, you're probably losing the nonfoil rare from the "double rare" packs. (check if your fix does indeed give you two rares in a foil rare pack. If not, it's wrong.)

PS : I did draft with these packs and it worked fine for me - albeit I probably didn't notice the packs having 16 cards. Maybe the quest drafts aren't sensitive to packs having an extra card.

Edit : tested, it works correctly if the above modification is added.
Last edited by Seravy on 18 Jul 2017, 10:11, edited 1 time in total.
Seravy
 
Posts: 363
Joined: 26 Oct 2016, 21:23
Has thanked: 5 times
Been thanked: 27 times

Re: Foil rarity fix patch (completed)

Postby Agetian » 18 Jul 2017, 10:09

Ah, I see, I made modifications now and updated it the way you specified, seems to work well now. I haven't tested quest draft tournaments yet, but I'll do so shortly. Thanks for help!

- Agetian
Agetian
Programmer
 
Posts: 3471
Joined: 14 Mar 2011, 05:58
Has thanked: 676 times
Been thanked: 561 times

Re: Foil rarity fix patch (completed)

Postby Agetian » 18 Jul 2017, 12:21

Ok, here's the reformatted code for the star rating patch. During testing I noticed the following thing:

- If you have the Quest Deck Editor open, and you then switch to the normal (non-quest) Deck Editor tab, you will be able to choose the "Personal Rating" filter in the non-quest Deck Editor, which will do nothing (but in my tests, at the very least, it did not seem to crash). I believe that this is because a static variable QuestMode is used in CardManager, which is basically global (the same for all open deck editors). Thus, if the quest deck editor is open, it'll globally propagate the possibility of adding the Personal Rating filter to all other modes as well.

Other tests so far indicate that things are working well, but I'll test some more a bit later.

- Agetian
Attachments
RatingFilter5_reformatted.txt
(31.66 KiB) Downloaded 235 times
Agetian
Programmer
 
Posts: 3471
Joined: 14 Mar 2011, 05:58
Has thanked: 676 times
Been thanked: 561 times

Re: Foil rarity fix patch (completed)

Postby Agetian » 18 Jul 2017, 15:30

A question: are you sure that Vintage Masters Power Nine specials are actually generated and added to the boosters? :/ I tested this set and after generating several hundred boosters I haven't seen a single one, neither foil nor non-foil (in Sealed or Draft mode). Maybe it's just my luck (yeah, they're supposed to be rare - 1/53 packs), but still, I think it's worth double-checking this. Can you please try on your end?

- Agetian
Agetian
Programmer
 
Posts: 3471
Joined: 14 Mar 2011, 05:58
Has thanked: 676 times
Been thanked: 561 times

Re: Foil rarity fix patch (completed)

Postby Seravy » 18 Jul 2017, 16:01

Last time I tested, I got them fine. Wait, you are right. We moved them outside of the common subgroup. That improves Timeshifted and DFC but breaks the odds on P9 exactly as you say.

Let's calculate...there is a 1/7 chance to roll that slot initially, ignoring the invalid rerolled results. (1 rare, 2 uc, 3 common, 1 special)
To make that 1/53, we need a 7/53 chance of proceeding with the special. So change that random(53)=1 to random(53)<=7 and we're good. (assuming java random numbers are 1-53 and not 0-52, then you write <=6)
There still will be a (46/7/53)*(1/53) chance that the reroll still lands on it, if you want to avoid that, add an "else" branch that picks common to avoid a reroll.
Seravy
 
Posts: 363
Joined: 26 Oct 2016, 21:23
Has thanked: 5 times
Been thanked: 27 times

Re: Foil rarity fix patch (completed)

Postby Agetian » 18 Jul 2017, 16:04

Oh, OK! I'll go ahead and try that out!

- Agetian
Agetian
Programmer
 
Posts: 3471
Joined: 14 Mar 2011, 05:58
Has thanked: 676 times
Been thanked: 561 times

Re: Foil rarity fix patch (completed)

Postby Agetian » 18 Jul 2017, 16:08

Hmm not sure if maybe now it feels too common for whatever reason? (Not sure, once again, maybe just my luck). But anyway, I'm consistently getting 2-3 on average in a 48-booster sealed (6 packs per person, 8 players, so 48 packs generated total), got 4 a couple times.

Although strike that, just got three rolls with 1 power nine in 48 boosters, and a roll with none at all.

Hmm, can you please test with your mass generation algorithm that you're using to generate 1000 boosters or more, to see what chances we're looking at on average?

- Agetian
Agetian
Programmer
 
Posts: 3471
Joined: 14 Mar 2011, 05:58
Has thanked: 676 times
Been thanked: 561 times

Re: Foil rarity fix patch (completed)

Postby Seravy » 18 Jul 2017, 16:11

Agetian wrote:- If you have the Quest Deck Editor open, and you then switch to the normal (non-quest) Deck Editor tab, you will be able to choose the "Personal Rating" filter in the non-quest Deck Editor, which will do nothing (but in my tests, at the very least, it did not seem to crash). I believe that this is because a static variable QuestMode is used in CardManager, which is basically global (the same for all open deck editors). Thus, if the quest deck editor is open, it'll globally propagate the possibility of adding the Personal Rating filter to all other modes as well.
Arrgh, if the component created by another window is reused elsewhere, there is no way to make it work...wait, how does that even happen? The created CardManager is a local variable to the thing that created it, right? Why would different kinds of tabs then share it instead of using their own?

Edit : My mass generation algorithm is this : Start a new quest, pick "boosters, 1000". There you go, 1000 boosters, then you can filter your cards in the deck editor to count the results. Alternately, set 1000 packs for the shop, travel, and look at what was generated (this requires that set to be enforced, so it's less convenient)
Last edited by Seravy on 18 Jul 2017, 16:13, edited 1 time in total.
Seravy
 
Posts: 363
Joined: 26 Oct 2016, 21:23
Has thanked: 5 times
Been thanked: 27 times

Re: Foil rarity fix patch (completed)

Postby Agetian » 18 Jul 2017, 16:13

Seravy wrote:
Agetian wrote:- If you have the Quest Deck Editor open, and you then switch to the normal (non-quest) Deck Editor tab, you will be able to choose the "Personal Rating" filter in the non-quest Deck Editor, which will do nothing (but in my tests, at the very least, it did not seem to crash). I believe that this is because a static variable QuestMode is used in CardManager, which is basically global (the same for all open deck editors). Thus, if the quest deck editor is open, it'll globally propagate the possibility of adding the Personal Rating filter to all other modes as well.
Arrgh, if the component created by another window is reused elsewhere, there is no way to make it work...wait, how does that even happen? The created CardManager is a local variable to the thing that created it, right? Why would different kinds of tabs then share it instead of using their own?
Umm I'm sure that it is local, but QuestMode is declared "static" in the CardManager, and static things are global to the class, all instances would share the same value, as far as I understand. The problem is, it's not easy to not declare it static since you're using it from inside a static method... :/

- Agetian
Agetian
Programmer
 
Posts: 3471
Joined: 14 Mar 2011, 05:58
Has thanked: 676 times
Been thanked: 561 times

PreviousNext

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 37 guests


Who is online

In total there are 37 users online :: 0 registered, 0 hidden and 37 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 37 guests

Login Form