It is currently 16 Apr 2024, 04:05
   
Text Size

[REL] Riiak's DotP 2014 Deck Builder v1.5.0.3

Moderator: CCGHQ Admins

Re: [REL] Riiak's DotP 2014 Deck Builder v1.5.0.3

Postby Xander9009 » 23 Apr 2019, 15:17

I've actually been considering the possibility of leveraging thefiremind's card generator for this. I've got a significant amount of free time lately, and I'm really in the mood to program. Maybe I'll actually give this a shot... The only downside is that the Deck Builder is very professionally done compared to how I code. I've never actually taken classes for programming or had any professional experience, just home-based tinkering. I can manage just about anything, but don't know how it would typically be done by someone who knows how it "should" be done, y'know? (Quotes are because I understand there's rarely a single right way. But some ways are definitely better than others.)
_______________________________
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
User avatar
Xander9009
Programmer
 
Posts: 2905
Joined: 29 Jun 2013, 07:44
Location: Indiana, United States
Has thanked: 121 times
Been thanked: 445 times

Re: [REL] Riiak's DotP 2014 Deck Builder v1.5.0.3

Postby RiiakShiNal » 24 Apr 2019, 00:39

Xander9009 wrote:I've actually been considering the possibility of leveraging thefiremind's card generator for this. I've got a significant amount of free time lately, and I'm really in the mood to program. Maybe I'll actually give this a shot... The only downside is that the Deck Builder is very professionally done compared to how I code. I've never actually taken classes for programming or had any professional experience, just home-based tinkering. I can manage just about anything, but don't know how it would typically be done by someone who knows how it "should" be done, y'know? (Quotes are because I understand there's rarely a single right way. But some ways are definitely better than others.)
While using templated abilities like thefiremind's card generator works is a decent approach (I used a similar approach in my private card generator, which I never really finished but was usable), there are several downsides. Here are the different approaches that I can think of along with the pros and cons of them:

  • Use templated abilities to allow card building by selecting from available abilities:
    • Pros:
      • Fairly simple to implement.
      • Can include a large range of abilities that can be expanded fairly quickly & simply.
      • Could even do a simplistic load ability list from available WADs to expand the list.
      • Simple user interface (UI) can be acceptable.
    • Cons:
      • Very little to no ability configuration possibilities. i.e. "Target creature gets +3/+3 until end of turn." will always be just that, you can't make it +4/+1 or make it last until end of combat or until end of opponent's turn. At least not without a lot of effort.
      • Often you will be presenting the user with a huge list of templated abilities that the user then needs to look through. While you can add a search that also increases the amount of work.
      • Abilities that are looked up may be missing pieces so may not work as intended. i.e. User found a card that has an ability that is " {T}: Add {G} to your mana pool." and adds it to their card, they could very well be missing the necessary Static and Triggered abilities required for Manual Mana as well as the Token_Registration.
      • Depending on the abilities selected they could end up with duplicate support abilities or token registrations.
      • Difficult to allow for proper loading and editing after having been saved though this can be worked around by writing meta-data block starts and ends.
  • Use templated ability parts (simple ability builder):
    • Pros:
      • Allows user to customize an ability a part at a time. i.e. User can select a cost, targeting (if any), select from a range of ability pieces which can be done at play time, resolution time, continuous, and can rearrange the parts within the ability.
      • Allows for building a much larger array of abilities, while limiting list sizes for the user.
      • Customizable values and registers becomes more viable.
      • Can output meta-data for each piece when building allowing any created cards to be loaded back in and edited at a later time.
    • Cons:
      • Requires more knowledge from the user about what they want to do as well as how to break the steps down.
      • More difficult to code and requires a much better user interface (UI).
      • More difficult to add ability parts and have them work in the UI. i.e. You need to code how to read what can be plugged in as a parameter, how to present it to the user, what are valid values, what other pieces might be required (other ability parts or registrations for example), etc....
  • Hard-coded ability configurations:
    • Pros:
      • Each ability made available can be uniquely handled with as few or as many options as are made available.
      • This can have one of the best/easiest user experiences (UX) of any of the methods primarily because each ability configuration can have its own UX.
      • Can write out meta-data while creating the card allowing them to be loaded back up and edited at a later time.
      • Customized values and registers are quite easy.
      • Options to the user will be more limited, reducing user confusion.
    • Cons:
      • All ability configurations may need their own unique UIs meaning there will be huge amounts of code.
      • Adding new ability configurations is very difficult because each one needs to be coded in.
      • Likely to begin with at least there would not be that many ability configurations to choose from due to the effort and code required to add them.
  • Ability analysis with intelligent editing:
    • Pros:
      • Can analyze individual abilities, their parts, and required pieces allowing for loading of currently coded cards/abilities.
      • Adaptive UIs based on what the analysis of the an ability uncovers. i.e. When it analyzes " {T}: Add {G} to your mana pool." it could automatically add controls allowing the user to customize the color(s) and token registration(s), as well as the cost(s) (if any).
      • Little to no need to code any ability templates as it can offer selection of virtually any ability it can find in already coded cards that it loads.
      • Depending on how coded could even combine multiple existing abilities.
      • Can load and edit cards after creation even without any meta-data.
    • Cons:
      • By far the most complex to code.
      • Fixing bugs that are generated by the builder after ability analysis may be nigh impossible to fix from the generator. Obviously they could still be fixed manually by someone who knows how to code cards.
      • Generally, the loading and analysis would take a very long time (though all of this analysis work could be saved then loaded on subsequent runs so that repeated analyses are not required).
      • If you are going to go this far your talents and abilities would be far better put to use on other projects like Forge or creating your own magic engine.

If I were to approach the problem realistically then I would probably go the templated ability parts route. For someone who's not sure if they can do it, then just using templated abilities is probably the best approach. Someone who has lots of time on their hands and wants to make a really polished creator would probably be better off with the hard-coded ability configurations approach.

If the Deck Builder looks professionally done, then I guess I did some things right. I am actually a professional software engineer, though the Deck Builder was just a hobby project of mine. I haven't necessarily spent the time for due diligence on all of the parts of the Deck Builder and some parts of the code I look at and cringe.
RiiakShiNal
Programmer
 
Posts: 2185
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 496 times

Re: [REL] Riiak's DotP 2014 Deck Builder v1.5.0.3

Postby Xander9009 » 16 May 2019, 20:20

I've made several updates to the deck builder.

  • AI Personality is exported if the source of the personality isn't an official wad file.
  • Filter cards that begin with an underscore (underscore cards shouldn't be put into decks)
  • Filter vanguards
  • Edit existing deck in-place without creating a new one.
  • Fixed planeswalker/enchantment mixup (because planeswalkers are internally enchantments)
  • Can now use * as a wildcard in the ability simple filter and in advanced string filters
  • Can use ~ in the ability simple ability filter to stand in for the card's name. Example: "Sacrifice ~" would return Abandoned Outpost and Abzan Banner.
  • Error log resets when you use Refresh Data menu item and shows again.
  • Move Up and Move Down buttons now move the selection with the card being moved (it stays selected, so you can use the buttons to more conveniently move the cards several slots)
  • Create From Existing window now has an option to only show decks that match your ID Block in the settings
  • Cards with a REVERSE_FACE tag will now show a button to flip to the other side of the card.
  • hidalgo added Forge deck format importing

Download here
_______________________________
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
User avatar
Xander9009
Programmer
 
Posts: 2905
Joined: 29 Jun 2013, 07:44
Location: Indiana, United States
Has thanked: 121 times
Been thanked: 445 times

Re: [REL] Riiak's DotP 2014 Deck Builder v1.5.0.3

Postby LexilconCondran » 18 May 2019, 16:40

RiiakShiNal wrote:If the Deck Builder looks professionally done, then I guess I did some things right. I am actually a professional software engineer, though the Deck Builder was just a hobby project of mine. I haven't necessarily spent the time for due diligence on all of the parts of the Deck Builder and some parts of the code I look at and cringe.
Dude i have a huge bug with it, if i refresh data, it must be doing something awful because it was eating up 14.500.900kb of data in my memory
i have 21gb ram, but still, thts 14gb of ram usage from the deck builder
this is a huge bug, no idea how it happens, but if i refresh data, it might have been the issue
#-o "I Dont Know What to Do with my Life"

[-o< "So here iam"
User avatar
LexilconCondran
 
Posts: 58
Joined: 23 Apr 2019, 07:53
Has thanked: 15 times
Been thanked: 1 time

Re: [REL] Riiak's DotP 2014 Deck Builder v1.5.0.3

Postby aidscoi168 » 24 May 2019, 05:14

Hi, it's been a long time i using deckbuilder ( patched version to use with Mtbdb.Gui of Hidalgo ) and now i got this error not for new deck create by import forge deck format but also old deck files. The Export function been freeze so i can't export to wad file. Anyone can help ?
Attachments
error.jpg
Can't export
aidscoi168
 
Posts: 211
Joined: 31 Dec 2016, 17:49
Has thanked: 58 times
Been thanked: 28 times

Re: [REL] Riiak's DotP 2014 Deck Builder v1.5.0.3

Postby RiiakShiNal » 24 May 2019, 10:18

aidscoi168 wrote:Hi, it's been a long time i using deckbuilder ( patched version to use with Mtbdb.Gui of Hidalgo ) and now i got this error not for new deck create by import forge deck format but also old deck files. The Export function been freeze so i can't export to wad file. Anyone can help ?
If the export is disabled then the builder doesn't have appropriate write access to the game directory. You could likely work around the problem by running the builder as Administrator or you could change the permissions for the game directory to allow creation of files and directories, delete permissions (which allows the builder to delete a wad/directory and rebuild it), and write permissions.

For those interested this is the relevant piece of code in the builder:
Permissions checking | Open
Code: Select all
         // Check to see if we have read/write access to directory.
         bool bHasWriteAccess = false;   // We assume no access by default.
         try
         {
            DirectorySecurity dsDir = Directory.GetAccessControl(m_gdWads.GameDir);
            if (dsDir != null)
            {
               AuthorizationRuleCollection arcRules = dsDir.GetAccessRules(true, true, typeof(SecurityIdentifier));
               bool bHasCreateDirs = false;
               bool bHasCreateFiles = false;
               bool bHasDelete = false;
               bool bHasWrite = false;
               foreach (FileSystemAccessRule fsarRule in arcRules)
               {
                  // Create Directories
                  if ((fsarRule.FileSystemRights & FileSystemRights.CreateDirectories) == FileSystemRights.CreateDirectories)
                  {
                     if (fsarRule.AccessControlType == AccessControlType.Allow)
                     {
                        // We will allow access if there is an Allow.
                        bHasCreateDirs = true;
                     }
                     else if (fsarRule.AccessControlType == AccessControlType.Deny)
                     {
                        // If there is a Deny then it doesn't matter if we have previously come across any Allows.
                        bHasCreateDirs = false;
                        break;
                     }
                  }
                  // Create Files
                  if ((fsarRule.FileSystemRights & FileSystemRights.CreateFiles) == FileSystemRights.CreateFiles)
                  {
                     if (fsarRule.AccessControlType == AccessControlType.Allow)
                     {
                        // We will allow access if there is an Allow.
                        bHasCreateFiles = true;
                     }
                     else if (fsarRule.AccessControlType == AccessControlType.Deny)
                     {
                        // If there is a Deny then it doesn't matter if we have previously come across any Allows.
                        bHasCreateFiles = false;
                        break;
                     }
                  }
                  // Delete
                  if ((fsarRule.FileSystemRights & FileSystemRights.DeleteSubdirectoriesAndFiles) == FileSystemRights.DeleteSubdirectoriesAndFiles)
                  {
                     if (fsarRule.AccessControlType == AccessControlType.Allow)
                     {
                        // We will allow access if there is an Allow.
                        bHasDelete = true;
                     }
                     else if (fsarRule.AccessControlType == AccessControlType.Deny)
                     {
                        // If there is a Deny then it doesn't matter if we have previously come across any Allows.
                        bHasDelete = false;
                        break;
                     }
                  }
                  // Write
                  if ((fsarRule.FileSystemRights & FileSystemRights.Write) == FileSystemRights.Write)
                  {
                     if (fsarRule.AccessControlType == AccessControlType.Allow)
                     {
                        // We will allow access if there is an Allow.
                        bHasWrite = true;
                     }
                     else if (fsarRule.AccessControlType == AccessControlType.Deny)
                     {
                        // If there is a Deny then it doesn't matter if we have previously come across any Allows.
                        bHasWrite = false;
                        break;
                     }
                  }
               }
               bHasWriteAccess = bHasCreateDirs && bHasCreateFiles && bHasDelete && bHasWrite;
            }
         }
         catch (Exception e)
         {
            Settings.ReportError(e, ErrorPriority.High, "Builder does not have Write access to game directory, exporting and some other features will be disabled.");
         }
         if (bHasWriteAccess)
         {
            mnuiFileExportTo.Enabled = true;
         }
         else
         {
            mnuiFileExportTo.Enabled = false;
         }
RiiakShiNal
Programmer
 
Posts: 2185
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 496 times

Re: [REL] Riiak's DotP 2014 Deck Builder v1.5.0.3

Postby aidscoi168 » 24 May 2019, 12:09

I've change the ownership of the folder set permission for each account to full control, set the deckbuilder run as admin permission but nothing work
aidscoi168
 
Posts: 211
Joined: 31 Dec 2016, 17:49
Has thanked: 58 times
Been thanked: 28 times

Re: [REL] Riiak's DotP 2014 Deck Builder v1.5.0.3

Postby Xander9009 » 26 May 2019, 22:13

Hey, Riiak, I'm having an issue that I'm not sure how to solve. It's actually an issue that I had previously, too, but that time I just gave up because what I was trying to do was... out there. This time, however, I'm trying to add a new advanced filter tab for legality. Every card in the CW now has legalities set up, and I can import them into CardInfo with no real issue. It's all working fine up until I try to hit Apply. It tries to save the serializable setting:
Code: Select all
public static void SaveSerializableSetting<T>(string strSettingName, T oSave)
However, at this line, it throws an error:
Code: Select all
xsSave.Serialize(swSave, oSave);

The type RSN.DotP.CardFilterLegalityProp was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.
I tried looking to see what you did for the other filter types, but can't figure out why they're accepted and the new one isn't. Any thoughts? I could just try and use XmlInclude normally as the exception suggests, but I'd rather have it done the same way as the original ones to everything consistent.
_______________________________
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
User avatar
Xander9009
Programmer
 
Posts: 2905
Joined: 29 Jun 2013, 07:44
Location: Indiana, United States
Has thanked: 121 times
Been thanked: 445 times

Re: [REL] Riiak's DotP 2014 Deck Builder v1.5.0.3

Postby Xander9009 » 27 May 2019, 18:45

LexilconCondran wrote:Dude i have a huge bug with it, if i refresh data, it must be doing something awful because it was eating up 14.500.900kb of data in my memory
i have 21gb ram, but still, thts 14gb of ram usage from the deck builder
this is a huge bug, no idea how it happens, but if i refresh data, it might have been the issue
I've tried to improve the efficiency without breaking anything in the program. The result is this: https://drive.google.com/open?id=1gGHma ... NR6ntNCwC8

If you would mind, could you give it a try and see if it works on your end? It's working very well for me, but I don't want to replace the current version if it's going to break on other's machines. Just unzip the version you need to a new directory. Don't overwrite your current Deck Builder folder; they can work alongside each other just fine so long as they aren't both open at the same time.

The improvements were quite large. Roughly a 50% decrease in memory usage, and when it refreshes data, it completely wipes the old data from memory, preventing it from having large increases when the refresh menu item is used. It does technically leave a few megabytes worth when refreshing, but this is because the garbage collector doesn't seem to be able to collect everything like it's supposed to. I suspect there's an event or some circular reference that's still not being freed, but I can't track it down. Even so, in a program that takes nearly a GB of ram, <5 MB isn't going to be noticable or impact anything. You could refresh dozens of times before noticing any issues.
_______________________________
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
User avatar
Xander9009
Programmer
 
Posts: 2905
Joined: 29 Jun 2013, 07:44
Location: Indiana, United States
Has thanked: 121 times
Been thanked: 445 times

Re: [REL] Riiak's DotP 2014 Deck Builder v1.5.0.3

Postby hidalgo » 27 May 2019, 19:46

Xander9009 wrote:
LexilconCondran wrote:I suspect there's an event or some circular reference that's still not being freed, but I can't track it down.
Circularly referenced objects do not cause memory leaks, they are collected by .NET Gargbage Collector just as any other non used objects.

A sidenote, if you want to optimise memory usage, then a memory profiler application makes it hugely easier, it shows directly what is consuming the memory and how much. It also detects common memory leakage patterns such as duplicate string objects, events subscriptions which are not unsubscribed and etc.

Personally I use jetBrains dotMemory profiler, which can be used for free for open source projects.
User avatar
hidalgo
 
Posts: 354
Joined: 17 Oct 2016, 21:51
Location: Russia, Moscow
Has thanked: 58 times
Been thanked: 80 times

Re: [REL] Riiak's DotP 2014 Deck Builder v1.5.0.3

Postby Xander9009 » 27 May 2019, 20:12

Circular reference was just a guess. I'm not especially familiar with the Garbage Collector or how it works. I was aware that a memory profiler would help a lot, but I was led to believe there weren't any decent free options, so I hadn't yet looked into any. I'll check that one out and see if I can figure out why it's not releasing the memory properly. Thanks.

----

Edit: Updated the files after using dotMemory to find the remaining variables that weren't being collected. It's still not perfect because I'm brand new to using dotMemory, but it's now retaining about 50 KB of data between refreshes, so I'd call that good enough. Now, I just need someone to let me know I didn't break everything lol.

Unfortunately, the free license requires an actual application and not just the honor system. I'll apply for it, but really, I just needed it to see what I was missing. Maintaining it shouldn't be difficult, and I should have VS Enterprise before long, anyway.
_______________________________
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
User avatar
Xander9009
Programmer
 
Posts: 2905
Joined: 29 Jun 2013, 07:44
Location: Indiana, United States
Has thanked: 121 times
Been thanked: 445 times

Re: [REL] Riiak's DotP 2014 Deck Builder v1.5.0.3

Postby RiiakShiNal » 28 May 2019, 10:31

aidscoi168 wrote:I've change the ownership of the folder set permission for each account to full control, set the deckbuilder run as admin permission but nothing work
You can check whether permissions is the problem by checking the Errors.log file if you see "Builder does not have Write access to game directory, exporting and some other features will be disabled." in the log then permissions is most likely your problem (the only other possibility is that the game directory is pointing to a bad/non-existant directory, though if that was the case it likely would not load cards correctly), if not then your problem likely stems from somewhere else (possibly resulting from a custom version of the builder).

Xander9009 wrote:Hey, Riiak, I'm having an issue that I'm not sure how to solve. It's actually an issue that I had previously, too, but that time I just gave up because what I was trying to do was... out there. This time, however, I'm trying to add a new advanced filter tab for legality. Every card in the CW now has legalities set up, and I can import them into CardInfo with no real issue. It's all working fine up until I try to hit Apply. It tries to save the serializable setting:
Code: Select all
public static void SaveSerializableSetting<T>(string strSettingName, T oSave)
However, at this line, it throws an error:
Code: Select all
xsSave.Serialize(swSave, oSave);

The type RSN.DotP.CardFilterLegalityProp was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.
I tried looking to see what you did for the other filter types, but can't figure out why they're accepted and the new one isn't. Any thoughts? I could just try and use XmlInclude normally as the exception suggests, but I'd rather have it done the same way as the original ones to everything consistent.
That error probably means you haven't added CardFilterLegalityProp to the XmlArrayItem attribute list for CardFilterSet::Filters. There is a note there that to properly serialize and deserialize all possible derived types must be listed there, since you've added a new type it also needs to be added to that list.
RiiakShiNal
Programmer
 
Posts: 2185
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 496 times

Re: [REL] Riiak's DotP 2014 Deck Builder v1.5.0.3

Postby aidscoi168 » 30 May 2019, 18:29

I'm get rid of export issue but after update of CW ( or another event that i not yet figure out ) the game or deck builder have problem. The deck export succesfully but error when load in game ( show just 3 cards and crash when creating match )
i attach here the screenshot and the file
Attachments
error2.jpg
missing cards with normal number of cards exactly like deck list
deck.rar
deck file
(1015.78 KiB) Downloaded 352 times
aidscoi168
 
Posts: 211
Joined: 31 Dec 2016, 17:49
Has thanked: 58 times
Been thanked: 28 times

Re: [REL] Riiak's DotP 2014 Deck Builder v1.5.0.3

Postby Xander9009 » 31 May 2019, 04:21

When did you update the CW? This was an issue in the version that was up a couple of days ago, but it's been fixed since then.
_______________________________
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
User avatar
Xander9009
Programmer
 
Posts: 2905
Joined: 29 Jun 2013, 07:44
Location: Indiana, United States
Has thanked: 121 times
Been thanked: 445 times

Re: [REL] Riiak's DotP 2014 Deck Builder v1.5.0.3

Postby aidscoi168 » 31 May 2019, 08:01

I update CW day by day, and the report from the CW version i downloaded 30 may in my timezone i think
aidscoi168
 
Posts: 211
Joined: 31 Dec 2016, 17:49
Has thanked: 58 times
Been thanked: 28 times

PreviousNext

Return to Utilities

Who is online

Users browsing this forum: No registered users and 16 guests


Who is online

In total there are 16 users online :: 0 registered, 0 hidden and 16 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 16 guests

Login Form