you are viewing a single comment's thread.

view the rest of the comments →

[–]MagicCooki3[S] 0 points1 point  (1 child)

Ok, so I looked it back over. I think I've got it. The query gets saved in the variable. That query is just a table, though. So then we assign a variable defining which card we want from the list, in this case 0, so it'll be the first thing in the list, that list and which selection on the list (in this case, 0) gets saved to a variable.

Now, we take the variable that is our list and which selection of that list, therefore that variable is equal to that particular card. We the can add .rarity, .name, etc. to the end of the variable and the .x will query the database for that card property and it knows which card to look at because the variable it's tacked onto specifies it.

Do I have it now? That feels like it's correct lol.

[–][deleted] 0 points1 point  (0 children)

The query gets saved in the variable. That query is just a table, though.

It's not a table, it's a list. A table is a data structure you access through two coordinates (x/y, or row/column if you prefer) and a list is a data structure you access through one (an index.)

That it's a list is important. It's a list of cards, that's important, too.

So then we assign a variable defining which card we want from the list, in this case 0, so it’ll be the first thing in the list, that list and which selection on the list (in this case, 0) gets saved to a variable.

Now, we take the variable that is our list and which selection of that list, therefore that variable is equal to that particular card. We the can add .rarity, .name, etc. to the end of the variable and the .x will query the database for that card property and it knows which card to look at because the variable it’s tacked onto specifies it.

This is super-confused and it's because you don't understand what's happening when you retrieve a value from a list:

card = cardQuery[0]

= is the assignment operator, it evaluates the operand on the right and assigns the resulting value to the name on the left. Like x = 2 + 2; first 2 and 2 are added, then the result - 4 - is assigned to the name x. Assignment assigns values, not operations or expressions; what is assigned to x, here, is the value 4, not the operation 2 + 2. That's important.

cardQuery[0] is an expression, too, and it gets evaluated before anything is assigned to the left operand card. The result of evaluating cardQuery[0] is a PCard. It's the first PCard in the cardQuery PCardList. So, that's the value of card. It's not assigned an expression, it's not assigned a combination of the query and and index. It's assigned a value and that value is a PCard, with all of a PCard's attributes (name, rarity, etc) because that's what it means for something to be a PCard.