deckstats.net
You need to be logged in to do this.
The buttons above will open in a new window. Please return to this window after you have logged in. When you have logged in, click the Refresh Session button and then try again.

Author Topic: Programming MTG Stuff Questions (Need Suggestions)  (Read 1446 times)

Judaspriester

  • Hero Member
  • *****
  • Posts: 1523
  • Karma: 500
  • Decks
Re: Programming MTG Stuff Questions (Need Suggestions)
« Reply #30 on: December 16, 2019, 11:36:32 pm »
Well, for the txt import there is no framework, but the syntax is kinda easy.

lines starting with a number are cards in your deck. (Format: <amount> <name with possible spaces>)
lines starting with "SB" are Sideboard cards
lines starting with any other character are custom groups

for the cards, read until end of line, or until you hit a "#" which means everything behind is a comment

Even without regular expressions, this shouldn't be that hard to parse.
You say Prison Cell, I hear 'Holiday'.

WizardSpartan

  • Hero Member
  • *****
  • Posts: 1502
  • Karma: 838
  • Red_Wyrm's boo
  • Decks
Re: Programming MTG Stuff Questions (Need Suggestions)
« Reply #31 on: December 17, 2019, 12:41:53 am »
Ok making sure I'm not goin crazy (any more than I am already). Dunno if this is gonna be a career, but it seems interesting. I am just worried it will be too frustrating.

I have experience with finding and replacing characters, so it shouldn't be too much of a problem.

Edit: I'm trying to make a guide for my future self when I come back to this, and for whatever reason, when trying to do the same thing with sets, I'm getting errors, such as iterating the returned list (like we did with the card name) isn't possible.
Here's the link again and I would love it if somebody would give it a look.

Edit 2: Never mind, I figured it out. My best guess for why the error was occuring was because I was treating the set information the API returned as an array (and used a for function like with cards) but because I was searching for a specific set, it actually wasn't an array. As a result, it couldn't do the for function and gave me an error.
« Last Edit: December 17, 2019, 04:35:02 am by GolgariFTW »

Judaspriester

  • Hero Member
  • *****
  • Posts: 1523
  • Karma: 500
  • Decks
Re: Programming MTG Stuff Questions (Need Suggestions)
« Reply #32 on: December 17, 2019, 07:14:02 pm »
Ok making sure I'm not goin crazy (any more than I am already). Dunno if this is gonna be a career, but it seems interesting. I am just worried it will be too frustrating.

I have experience with finding and replacing characters, so it shouldn't be too much of a problem.

Edit: I'm trying to make a guide for my future self when I come back to this, and for whatever reason, when trying to do the same thing with sets, I'm getting errors, such as iterating the returned list (like we did with the card name) isn't possible.
Here's the link again and I would love it if somebody would give it a look.

Edit 2: Never mind, I figured it out. My best guess for why the error was occuring was because I was treating the set information the API returned as an array (and used a for function like with cards) but because I was searching for a specific set, it actually wasn't an array. As a result, it couldn't do the for function and gave me an error.

I'm not sure you want to hear this, but self caused problems like this are kinda common while programming. You'll need some frustration tollerance.
At worst case, leave the code be, do something else for some minutes, and then take a look at the error message. In many cases this already helps, if not, use a debugger or add some debug prints in order to see what does (not) happen in your code, and where you have to search for the mistake.
You say Prison Cell, I hear 'Holiday'.

WizardSpartan

  • Hero Member
  • *****
  • Posts: 1502
  • Karma: 838
  • Red_Wyrm's boo
  • Decks
Re: Programming MTG Stuff Questions (Need Suggestions)
« Reply #33 on: December 17, 2019, 07:33:03 pm »
Yeah I'm not too worried about frustration. I play League after all.

Any suggestions for debuggers you like to use?

Judaspriester

  • Hero Member
  • *****
  • Posts: 1523
  • Karma: 500
  • Decks
Re: Programming MTG Stuff Questions (Need Suggestions)
« Reply #34 on: December 17, 2019, 07:44:13 pm »
Yeah I'm not too worried about frustration. I play League after all.

Any suggestions for debuggers you like to use?

Like said, I haven't programmed in python until now, so you have to look for one yourself.
Otherwise, especially in script languages, add some prints in order to see what's happening in your code. I personally tend to take care of a clean code formatting, but ignore this for debug stuff. This way I take a look at the code and directly notice every debug line I've added.

Btw, I'll strongly suggest to take care of formatting and adding comments to your code. there is no need to comment every line of code, but comments for logical blocks help alot. At the moment you're writing the code, it seems logical for you, what the code is doing. But if you have to take a look at the code a half year later because you need to change something or want to look up how you solved a problem in this code, this extra work really pays off.  ;)
You say Prison Cell, I hear 'Holiday'.